return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define);
}
+/// This version of the builder inserts the newly-built instruction before
+/// the given position in the given MachineBasicBlock, and sets up the first
+/// operand as a destination virtual register.
+///
+/// If \c I is inside a bundle, then the newly inserted \a MachineInstr is
+/// added to the same bundle.
inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
MachineBasicBlock::instr_iterator I,
const DebugLoc &DL, const MCInstrDesc &MCID,
return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define);
}
-inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I,
+inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr &I,
const DebugLoc &DL, const MCInstrDesc &MCID,
unsigned DestReg) {
- if (I->isInsideBundle()) {
- MachineBasicBlock::instr_iterator MII(I);
- return BuildMI(BB, MII, DL, MCID, DestReg);
- }
+ // Calling the overload for instr_iterator is always correct. However, the
+ // definition is not available in headers, so inline the check.
+ if (I.isInsideBundle())
+ return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID, DestReg);
+ return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID, DestReg);
+}
- MachineBasicBlock::iterator MII = I;
- return BuildMI(BB, MII, DL, MCID, DestReg);
+inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I,
+ const DebugLoc &DL, const MCInstrDesc &MCID,
+ unsigned DestReg) {
+ return BuildMI(BB, *I, DL, MCID, DestReg);
}
/// This version of the builder inserts the newly-built instruction before the