File indexing completed on 2026-05-10 08:43:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H
0020 #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
0021
0022 #include "llvm/ADT/ArrayRef.h"
0023 #include "llvm/CodeGen/GlobalISel/Utils.h"
0024 #include "llvm/CodeGen/MachineBasicBlock.h"
0025 #include "llvm/CodeGen/MachineFunction.h"
0026 #include "llvm/CodeGen/MachineInstr.h"
0027 #include "llvm/CodeGen/MachineInstrBundle.h"
0028 #include "llvm/CodeGen/MachineOperand.h"
0029 #include "llvm/CodeGen/TargetRegisterInfo.h"
0030 #include "llvm/IR/InstrTypes.h"
0031 #include "llvm/IR/Intrinsics.h"
0032 #include "llvm/Support/ErrorHandling.h"
0033 #include <cassert>
0034 #include <cstdint>
0035
0036 namespace llvm {
0037
0038 class MCInstrDesc;
0039 class MDNode;
0040
0041 namespace RegState {
0042
0043
0044 enum {
0045
0046 Define = 0x2,
0047
0048 Implicit = 0x4,
0049
0050 Kill = 0x8,
0051
0052 Dead = 0x10,
0053
0054 Undef = 0x20,
0055
0056 EarlyClobber = 0x40,
0057
0058 Debug = 0x80,
0059
0060
0061 InternalRead = 0x100,
0062
0063 Renamable = 0x200,
0064 DefineNoRead = Define | Undef,
0065 ImplicitDefine = Implicit | Define,
0066 ImplicitKill = Implicit | Kill
0067 };
0068
0069 }
0070
0071 class MachineInstrBuilder {
0072 MachineFunction *MF = nullptr;
0073 MachineInstr *MI = nullptr;
0074
0075 public:
0076 MachineInstrBuilder() = default;
0077
0078
0079
0080 MachineInstrBuilder(MachineFunction &F, MachineInstr *I) : MF(&F), MI(I) {}
0081 MachineInstrBuilder(MachineFunction &F, MachineBasicBlock::iterator I)
0082 : MF(&F), MI(&*I) {}
0083
0084
0085 operator MachineInstr*() const { return MI; }
0086 MachineInstr *operator->() const { return MI; }
0087 operator MachineBasicBlock::iterator() const { return MI; }
0088
0089
0090
0091 MachineInstr *getInstr() const { return MI; }
0092
0093
0094
0095
0096 Register getReg(unsigned Idx) const { return MI->getOperand(Idx).getReg(); }
0097
0098
0099 const MachineInstrBuilder &addReg(Register RegNo, unsigned flags = 0,
0100 unsigned SubReg = 0) const {
0101 assert((flags & 0x1) == 0 &&
0102 "Passing in 'true' to addReg is forbidden! Use enums instead.");
0103 MI->addOperand(*MF, MachineOperand::CreateReg(RegNo,
0104 flags & RegState::Define,
0105 flags & RegState::Implicit,
0106 flags & RegState::Kill,
0107 flags & RegState::Dead,
0108 flags & RegState::Undef,
0109 flags & RegState::EarlyClobber,
0110 SubReg,
0111 flags & RegState::Debug,
0112 flags & RegState::InternalRead,
0113 flags & RegState::Renamable));
0114 return *this;
0115 }
0116
0117
0118 const MachineInstrBuilder &addDef(Register RegNo, unsigned Flags = 0,
0119 unsigned SubReg = 0) const {
0120 return addReg(RegNo, Flags | RegState::Define, SubReg);
0121 }
0122
0123
0124
0125 const MachineInstrBuilder &addUse(Register RegNo, unsigned Flags = 0,
0126 unsigned SubReg = 0) const {
0127 assert(!(Flags & RegState::Define) &&
0128 "Misleading addUse defines register, use addReg instead.");
0129 return addReg(RegNo, Flags, SubReg);
0130 }
0131
0132
0133 const MachineInstrBuilder &addImm(int64_t Val) const {
0134 MI->addOperand(*MF, MachineOperand::CreateImm(Val));
0135 return *this;
0136 }
0137
0138 const MachineInstrBuilder &addCImm(const ConstantInt *Val) const {
0139 MI->addOperand(*MF, MachineOperand::CreateCImm(Val));
0140 return *this;
0141 }
0142
0143 const MachineInstrBuilder &addFPImm(const ConstantFP *Val) const {
0144 MI->addOperand(*MF, MachineOperand::CreateFPImm(Val));
0145 return *this;
0146 }
0147
0148 const MachineInstrBuilder &addMBB(MachineBasicBlock *MBB,
0149 unsigned TargetFlags = 0) const {
0150 MI->addOperand(*MF, MachineOperand::CreateMBB(MBB, TargetFlags));
0151 return *this;
0152 }
0153
0154 const MachineInstrBuilder &addFrameIndex(int Idx) const {
0155 MI->addOperand(*MF, MachineOperand::CreateFI(Idx));
0156 return *this;
0157 }
0158
0159 const MachineInstrBuilder &
0160 addConstantPoolIndex(unsigned Idx, int Offset = 0,
0161 unsigned TargetFlags = 0) const {
0162 MI->addOperand(*MF, MachineOperand::CreateCPI(Idx, Offset, TargetFlags));
0163 return *this;
0164 }
0165
0166 const MachineInstrBuilder &addTargetIndex(unsigned Idx, int64_t Offset = 0,
0167 unsigned TargetFlags = 0) const {
0168 MI->addOperand(*MF, MachineOperand::CreateTargetIndex(Idx, Offset,
0169 TargetFlags));
0170 return *this;
0171 }
0172
0173 const MachineInstrBuilder &addJumpTableIndex(unsigned Idx,
0174 unsigned TargetFlags = 0) const {
0175 MI->addOperand(*MF, MachineOperand::CreateJTI(Idx, TargetFlags));
0176 return *this;
0177 }
0178
0179 const MachineInstrBuilder &addGlobalAddress(const GlobalValue *GV,
0180 int64_t Offset = 0,
0181 unsigned TargetFlags = 0) const {
0182 MI->addOperand(*MF, MachineOperand::CreateGA(GV, Offset, TargetFlags));
0183 return *this;
0184 }
0185
0186 const MachineInstrBuilder &addExternalSymbol(const char *FnName,
0187 unsigned TargetFlags = 0) const {
0188 MI->addOperand(*MF, MachineOperand::CreateES(FnName, TargetFlags));
0189 return *this;
0190 }
0191
0192 const MachineInstrBuilder &addBlockAddress(const BlockAddress *BA,
0193 int64_t Offset = 0,
0194 unsigned TargetFlags = 0) const {
0195 MI->addOperand(*MF, MachineOperand::CreateBA(BA, Offset, TargetFlags));
0196 return *this;
0197 }
0198
0199 const MachineInstrBuilder &addRegMask(const uint32_t *Mask) const {
0200 MI->addOperand(*MF, MachineOperand::CreateRegMask(Mask));
0201 return *this;
0202 }
0203
0204 const MachineInstrBuilder &addMemOperand(MachineMemOperand *MMO) const {
0205 MI->addMemOperand(*MF, MMO);
0206 return *this;
0207 }
0208
0209 const MachineInstrBuilder &
0210 setMemRefs(ArrayRef<MachineMemOperand *> MMOs) const {
0211 MI->setMemRefs(*MF, MMOs);
0212 return *this;
0213 }
0214
0215 const MachineInstrBuilder &cloneMemRefs(const MachineInstr &OtherMI) const {
0216 MI->cloneMemRefs(*MF, OtherMI);
0217 return *this;
0218 }
0219
0220 const MachineInstrBuilder &
0221 cloneMergedMemRefs(ArrayRef<const MachineInstr *> OtherMIs) const {
0222 MI->cloneMergedMemRefs(*MF, OtherMIs);
0223 return *this;
0224 }
0225
0226 const MachineInstrBuilder &add(const MachineOperand &MO) const {
0227 MI->addOperand(*MF, MO);
0228 return *this;
0229 }
0230
0231 const MachineInstrBuilder &add(ArrayRef<MachineOperand> MOs) const {
0232 for (const MachineOperand &MO : MOs) {
0233 MI->addOperand(*MF, MO);
0234 }
0235 return *this;
0236 }
0237
0238 const MachineInstrBuilder &addMetadata(const MDNode *MD) const {
0239 MI->addOperand(*MF, MachineOperand::CreateMetadata(MD));
0240 assert((MI->isDebugValueLike() ? static_cast<bool>(MI->getDebugVariable())
0241 : true) &&
0242 "first MDNode argument of a DBG_VALUE not a variable");
0243 assert((MI->isDebugLabel() ? static_cast<bool>(MI->getDebugLabel())
0244 : true) &&
0245 "first MDNode argument of a DBG_LABEL not a label");
0246 return *this;
0247 }
0248
0249 const MachineInstrBuilder &addCFIIndex(unsigned CFIIndex) const {
0250 MI->addOperand(*MF, MachineOperand::CreateCFIIndex(CFIIndex));
0251 return *this;
0252 }
0253
0254 const MachineInstrBuilder &addIntrinsicID(Intrinsic::ID ID) const {
0255 MI->addOperand(*MF, MachineOperand::CreateIntrinsicID(ID));
0256 return *this;
0257 }
0258
0259 const MachineInstrBuilder &addPredicate(CmpInst::Predicate Pred) const {
0260 MI->addOperand(*MF, MachineOperand::CreatePredicate(Pred));
0261 return *this;
0262 }
0263
0264 const MachineInstrBuilder &addShuffleMask(ArrayRef<int> Val) const {
0265 MI->addOperand(*MF, MachineOperand::CreateShuffleMask(Val));
0266 return *this;
0267 }
0268
0269 const MachineInstrBuilder &addSym(MCSymbol *Sym,
0270 unsigned char TargetFlags = 0) const {
0271 MI->addOperand(*MF, MachineOperand::CreateMCSymbol(Sym, TargetFlags));
0272 return *this;
0273 }
0274
0275 const MachineInstrBuilder &setMIFlags(unsigned Flags) const {
0276 MI->setFlags(Flags);
0277 return *this;
0278 }
0279
0280 const MachineInstrBuilder &setMIFlag(MachineInstr::MIFlag Flag) const {
0281 MI->setFlag(Flag);
0282 return *this;
0283 }
0284
0285 const MachineInstrBuilder &setOperandDead(unsigned OpIdx) const {
0286 MI->getOperand(OpIdx).setIsDead();
0287 return *this;
0288 }
0289
0290
0291 const MachineInstrBuilder &addDisp(const MachineOperand &Disp, int64_t off,
0292 unsigned char TargetFlags = 0) const {
0293
0294
0295
0296
0297 if (0 == TargetFlags)
0298 TargetFlags = Disp.getTargetFlags();
0299
0300 switch (Disp.getType()) {
0301 default:
0302 llvm_unreachable("Unhandled operand type in addDisp()");
0303 case MachineOperand::MO_Immediate:
0304 return addImm(Disp.getImm() + off);
0305 case MachineOperand::MO_ConstantPoolIndex:
0306 return addConstantPoolIndex(Disp.getIndex(), Disp.getOffset() + off,
0307 TargetFlags);
0308 case MachineOperand::MO_GlobalAddress:
0309 return addGlobalAddress(Disp.getGlobal(), Disp.getOffset() + off,
0310 TargetFlags);
0311 case MachineOperand::MO_BlockAddress:
0312 return addBlockAddress(Disp.getBlockAddress(), Disp.getOffset() + off,
0313 TargetFlags);
0314 case MachineOperand::MO_JumpTableIndex:
0315 assert(off == 0 && "cannot create offset into jump tables");
0316 return addJumpTableIndex(Disp.getIndex(), TargetFlags);
0317 }
0318 }
0319
0320 const MachineInstrBuilder &setPCSections(MDNode *MD) const {
0321 if (MD)
0322 MI->setPCSections(*MF, MD);
0323 return *this;
0324 }
0325
0326 const MachineInstrBuilder &setMMRAMetadata(MDNode *MMRA) const {
0327 if (MMRA)
0328 MI->setMMRAMetadata(*MF, MMRA);
0329 return *this;
0330 }
0331
0332
0333 const MachineInstrBuilder &
0334 copyImplicitOps(const MachineInstr &OtherMI) const {
0335 MI->copyImplicitOps(*MF, OtherMI);
0336 return *this;
0337 }
0338
0339 bool constrainAllUses(const TargetInstrInfo &TII,
0340 const TargetRegisterInfo &TRI,
0341 const RegisterBankInfo &RBI) const {
0342 return constrainSelectedInstRegOperands(*MI, TII, TRI, RBI);
0343 }
0344 };
0345
0346
0347
0348 class MIMetadata {
0349 public:
0350 MIMetadata() = default;
0351 MIMetadata(DebugLoc DL, MDNode *PCSections = nullptr, MDNode *MMRA = nullptr)
0352 : DL(std::move(DL)), PCSections(PCSections), MMRA(MMRA) {}
0353 MIMetadata(const DILocation *DI, MDNode *PCSections = nullptr,
0354 MDNode *MMRA = nullptr)
0355 : DL(DI), PCSections(PCSections), MMRA(MMRA) {}
0356 explicit MIMetadata(const Instruction &From)
0357 : DL(From.getDebugLoc()),
0358 PCSections(From.getMetadata(LLVMContext::MD_pcsections)) {}
0359 explicit MIMetadata(const MachineInstr &From)
0360 : DL(From.getDebugLoc()), PCSections(From.getPCSections()) {}
0361
0362 const DebugLoc &getDL() const { return DL; }
0363 MDNode *getPCSections() const { return PCSections; }
0364 MDNode *getMMRAMetadata() const { return MMRA; }
0365
0366 private:
0367 DebugLoc DL;
0368 MDNode *PCSections = nullptr;
0369 MDNode *MMRA = nullptr;
0370 };
0371
0372
0373 inline MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD,
0374 const MCInstrDesc &MCID) {
0375 return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, MIMD.getDL()))
0376 .setPCSections(MIMD.getPCSections())
0377 .setMMRAMetadata(MIMD.getMMRAMetadata());
0378 }
0379
0380
0381
0382 inline MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD,
0383 const MCInstrDesc &MCID, Register DestReg) {
0384 return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, MIMD.getDL()))
0385 .setPCSections(MIMD.getPCSections())
0386 .setMMRAMetadata(MIMD.getMMRAMetadata())
0387 .addReg(DestReg, RegState::Define);
0388 }
0389
0390
0391
0392
0393 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
0394 MachineBasicBlock::iterator I,
0395 const MIMetadata &MIMD,
0396 const MCInstrDesc &MCID, Register DestReg) {
0397 MachineFunction &MF = *BB.getParent();
0398 MachineInstr *MI = MF.CreateMachineInstr(MCID, MIMD.getDL());
0399 BB.insert(I, MI);
0400 return MachineInstrBuilder(MF, MI)
0401 .setPCSections(MIMD.getPCSections())
0402 .setMMRAMetadata(MIMD.getMMRAMetadata())
0403 .addReg(DestReg, RegState::Define);
0404 }
0405
0406
0407
0408
0409
0410
0411
0412 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
0413 MachineBasicBlock::instr_iterator I,
0414 const MIMetadata &MIMD,
0415 const MCInstrDesc &MCID, Register DestReg) {
0416 MachineFunction &MF = *BB.getParent();
0417 MachineInstr *MI = MF.CreateMachineInstr(MCID, MIMD.getDL());
0418 BB.insert(I, MI);
0419 return MachineInstrBuilder(MF, MI)
0420 .setPCSections(MIMD.getPCSections())
0421 .setMMRAMetadata(MIMD.getMMRAMetadata())
0422 .addReg(DestReg, RegState::Define);
0423 }
0424
0425 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr &I,
0426 const MIMetadata &MIMD,
0427 const MCInstrDesc &MCID, Register DestReg) {
0428
0429
0430 if (I.isInsideBundle())
0431 return BuildMI(BB, MachineBasicBlock::instr_iterator(I), MIMD, MCID,
0432 DestReg);
0433 return BuildMI(BB, MachineBasicBlock::iterator(I), MIMD, MCID, DestReg);
0434 }
0435
0436 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I,
0437 const MIMetadata &MIMD,
0438 const MCInstrDesc &MCID, Register DestReg) {
0439 return BuildMI(BB, *I, MIMD, MCID, DestReg);
0440 }
0441
0442
0443
0444
0445 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
0446 MachineBasicBlock::iterator I,
0447 const MIMetadata &MIMD,
0448 const MCInstrDesc &MCID) {
0449 MachineFunction &MF = *BB.getParent();
0450 MachineInstr *MI = MF.CreateMachineInstr(MCID, MIMD.getDL());
0451 BB.insert(I, MI);
0452 return MachineInstrBuilder(MF, MI)
0453 .setPCSections(MIMD.getPCSections())
0454 .setMMRAMetadata(MIMD.getMMRAMetadata());
0455 }
0456
0457 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
0458 MachineBasicBlock::instr_iterator I,
0459 const MIMetadata &MIMD,
0460 const MCInstrDesc &MCID) {
0461 MachineFunction &MF = *BB.getParent();
0462 MachineInstr *MI = MF.CreateMachineInstr(MCID, MIMD.getDL());
0463 BB.insert(I, MI);
0464 return MachineInstrBuilder(MF, MI)
0465 .setPCSections(MIMD.getPCSections())
0466 .setMMRAMetadata(MIMD.getMMRAMetadata());
0467 }
0468
0469 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr &I,
0470 const MIMetadata &MIMD,
0471 const MCInstrDesc &MCID) {
0472
0473
0474 if (I.isInsideBundle())
0475 return BuildMI(BB, MachineBasicBlock::instr_iterator(I), MIMD, MCID);
0476 return BuildMI(BB, MachineBasicBlock::iterator(I), MIMD, MCID);
0477 }
0478
0479 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I,
0480 const MIMetadata &MIMD,
0481 const MCInstrDesc &MCID) {
0482 return BuildMI(BB, *I, MIMD, MCID);
0483 }
0484
0485
0486
0487 inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB,
0488 const MIMetadata &MIMD,
0489 const MCInstrDesc &MCID) {
0490 return BuildMI(*BB, BB->end(), MIMD, MCID);
0491 }
0492
0493
0494
0495
0496 inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB,
0497 const MIMetadata &MIMD,
0498 const MCInstrDesc &MCID, Register DestReg) {
0499 return BuildMI(*BB, BB->end(), MIMD, MCID, DestReg);
0500 }
0501
0502
0503
0504
0505
0506 MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL,
0507 const MCInstrDesc &MCID, bool IsIndirect,
0508 Register Reg, const MDNode *Variable,
0509 const MDNode *Expr);
0510
0511
0512
0513 MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL,
0514 const MCInstrDesc &MCID, bool IsIndirect,
0515 ArrayRef<MachineOperand> MOs,
0516 const MDNode *Variable, const MDNode *Expr);
0517
0518
0519
0520
0521 MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
0522 MachineBasicBlock::iterator I, const DebugLoc &DL,
0523 const MCInstrDesc &MCID, bool IsIndirect,
0524 Register Reg, const MDNode *Variable,
0525 const MDNode *Expr);
0526
0527
0528
0529 MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
0530 MachineBasicBlock::iterator I, const DebugLoc &DL,
0531 const MCInstrDesc &MCID, bool IsIndirect,
0532 ArrayRef<MachineOperand> MOs,
0533 const MDNode *Variable, const MDNode *Expr);
0534
0535
0536 MachineInstr *buildDbgValueForSpill(MachineBasicBlock &BB,
0537 MachineBasicBlock::iterator I,
0538 const MachineInstr &Orig, int FrameIndex,
0539 Register SpillReg);
0540 MachineInstr *buildDbgValueForSpill(
0541 MachineBasicBlock &BB, MachineBasicBlock::iterator I,
0542 const MachineInstr &Orig, int FrameIndex,
0543 const SmallVectorImpl<const MachineOperand *> &SpilledOperands);
0544
0545
0546
0547 void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex, Register Reg);
0548
0549 inline unsigned getDefRegState(bool B) {
0550 return B ? RegState::Define : 0;
0551 }
0552 inline unsigned getImplRegState(bool B) {
0553 return B ? RegState::Implicit : 0;
0554 }
0555 inline unsigned getKillRegState(bool B) {
0556 return B ? RegState::Kill : 0;
0557 }
0558 inline unsigned getDeadRegState(bool B) {
0559 return B ? RegState::Dead : 0;
0560 }
0561 inline unsigned getUndefRegState(bool B) {
0562 return B ? RegState::Undef : 0;
0563 }
0564 inline unsigned getInternalReadRegState(bool B) {
0565 return B ? RegState::InternalRead : 0;
0566 }
0567 inline unsigned getDebugRegState(bool B) {
0568 return B ? RegState::Debug : 0;
0569 }
0570 inline unsigned getRenamableRegState(bool B) {
0571 return B ? RegState::Renamable : 0;
0572 }
0573
0574
0575 inline unsigned getRegState(const MachineOperand &RegOp) {
0576 assert(RegOp.isReg() && "Not a register operand");
0577 return getDefRegState(RegOp.isDef()) | getImplRegState(RegOp.isImplicit()) |
0578 getKillRegState(RegOp.isKill()) | getDeadRegState(RegOp.isDead()) |
0579 getUndefRegState(RegOp.isUndef()) |
0580 getInternalReadRegState(RegOp.isInternalRead()) |
0581 getDebugRegState(RegOp.isDebug()) |
0582 getRenamableRegState(RegOp.getReg().isPhysical() &&
0583 RegOp.isRenamable());
0584 }
0585
0586
0587
0588
0589
0590
0591 class MIBundleBuilder {
0592 MachineBasicBlock &MBB;
0593 MachineBasicBlock::instr_iterator Begin;
0594 MachineBasicBlock::instr_iterator End;
0595
0596 public:
0597
0598
0599 MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator Pos)
0600 : MBB(BB), Begin(Pos.getInstrIterator()), End(Begin) {}
0601
0602
0603 MIBundleBuilder(MachineBasicBlock &BB, MachineBasicBlock::iterator B,
0604 MachineBasicBlock::iterator E)
0605 : MBB(BB), Begin(B.getInstrIterator()), End(E.getInstrIterator()) {
0606 assert(B != E && "No instructions to bundle");
0607 ++B;
0608 while (B != E) {
0609 MachineInstr &MI = *B;
0610 ++B;
0611 MI.bundleWithPred();
0612 }
0613 }
0614
0615
0616
0617 explicit MIBundleBuilder(MachineInstr *MI)
0618 : MBB(*MI->getParent()), Begin(MI),
0619 End(getBundleEnd(MI->getIterator())) {}
0620
0621
0622 MachineBasicBlock &getMBB() const { return MBB; }
0623
0624
0625
0626 bool empty() const { return Begin == End; }
0627
0628
0629 MachineBasicBlock::instr_iterator begin() const { return Begin; }
0630
0631
0632 MachineBasicBlock::instr_iterator end() const { return End; }
0633
0634
0635
0636 MIBundleBuilder &insert(MachineBasicBlock::instr_iterator I,
0637 MachineInstr *MI) {
0638 MBB.insert(I, MI);
0639 if (I == Begin) {
0640 if (!empty())
0641 MI->bundleWithSucc();
0642 Begin = MI->getIterator();
0643 return *this;
0644 }
0645 if (I == End) {
0646 MI->bundleWithPred();
0647 return *this;
0648 }
0649
0650
0651 MI->setFlag(MachineInstr::BundledPred);
0652 MI->setFlag(MachineInstr::BundledSucc);
0653 return *this;
0654 }
0655
0656
0657
0658 MIBundleBuilder &prepend(MachineInstr *MI) {
0659 return insert(begin(), MI);
0660 }
0661
0662
0663
0664 MIBundleBuilder &append(MachineInstr *MI) {
0665 return insert(end(), MI);
0666 }
0667 };
0668
0669 }
0670
0671 #endif