Index: include/llvm/CodeGen/MachineInstrBuilder.h =================================================================== --- include/llvm/CodeGen/MachineInstrBuilder.h +++ include/llvm/CodeGen/MachineInstrBuilder.h @@ -282,30 +282,31 @@ }; /// Builder interface. Specify how to create the initial instruction itself. -inline MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, - const MCInstrDesc &MCID) { - return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, DL)); +template +Builder BuildMI(MachineFunction &MF, const DebugLoc &DL, + const MCInstrDesc &MCID) { + return Builder(MF, MF.CreateMachineInstr(MCID, DL)); } /// This version of the builder sets up the first operand as a /// destination virtual register. -inline MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, - const MCInstrDesc &MCID, unsigned DestReg) { - return MachineInstrBuilder(MF, MF.CreateMachineInstr(MCID, DL)) - .addReg(DestReg, RegState::Define); +template +Builder BuildMI(MachineFunction &MF, const DebugLoc &DL, + const MCInstrDesc &MCID, unsigned DestReg) { + return Builder(MF, MF.CreateMachineInstr(MCID, DL)) + .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. -inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, - MachineBasicBlock::iterator I, - const DebugLoc &DL, const MCInstrDesc &MCID, - unsigned DestReg) { +template +Builder BuildMI(MachineBasicBlock &BB, MachineBasicBlock::iterator I, + const DebugLoc &DL, const MCInstrDesc &MCID, unsigned DestReg) { MachineFunction &MF = *BB.getParent(); MachineInstr *MI = MF.CreateMachineInstr(MCID, DL); BB.insert(I, MI); - return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define); + return Builder(MF, MI).addReg(DestReg, RegState::Define); } /// This version of the builder inserts the newly-built instruction before @@ -314,107 +315,108 @@ /// /// 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, - unsigned DestReg) { +template +Builder BuildMI(MachineBasicBlock &BB, MachineBasicBlock::instr_iterator I, + const DebugLoc &DL, const MCInstrDesc &MCID, unsigned DestReg) { MachineFunction &MF = *BB.getParent(); MachineInstr *MI = MF.CreateMachineInstr(MCID, DL); BB.insert(I, MI); - return MachineInstrBuilder(MF, MI).addReg(DestReg, RegState::Define); + return Builder(MF, MI).addReg(DestReg, RegState::Define); } -inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr &I, - const DebugLoc &DL, const MCInstrDesc &MCID, - unsigned DestReg) { +template +Builder BuildMI(MachineBasicBlock &BB, MachineInstr &I, const DebugLoc &DL, + const MCInstrDesc &MCID, unsigned 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); + return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID, + DestReg); + return BuildMI(BB, MachineBasicBlock::iterator(I), 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); +template +Builder 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 /// given position in the given MachineBasicBlock, and does NOT take a /// destination register. -inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, - MachineBasicBlock::iterator I, - const DebugLoc &DL, - const MCInstrDesc &MCID) { +template +Builder BuildMI(MachineBasicBlock &BB, MachineBasicBlock::iterator I, + const DebugLoc &DL, const MCInstrDesc &MCID) { MachineFunction &MF = *BB.getParent(); MachineInstr *MI = MF.CreateMachineInstr(MCID, DL); BB.insert(I, MI); - return MachineInstrBuilder(MF, MI); + return Builder(MF, MI); } -inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, - MachineBasicBlock::instr_iterator I, - const DebugLoc &DL, - const MCInstrDesc &MCID) { +template +Builder BuildMI(MachineBasicBlock &BB, MachineBasicBlock::instr_iterator I, + const DebugLoc &DL, const MCInstrDesc &MCID) { MachineFunction &MF = *BB.getParent(); MachineInstr *MI = MF.CreateMachineInstr(MCID, DL); BB.insert(I, MI); - return MachineInstrBuilder(MF, MI); + return Builder(MF, MI); } -inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr &I, - const DebugLoc &DL, - const MCInstrDesc &MCID) { +template +Builder BuildMI(MachineBasicBlock &BB, MachineInstr &I, const DebugLoc &DL, + const MCInstrDesc &MCID) { // 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); - return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID); + return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID); + return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID); } -inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I, - const DebugLoc &DL, - const MCInstrDesc &MCID) { - return BuildMI(BB, *I, DL, MCID); +template +Builder BuildMI(MachineBasicBlock &BB, MachineInstr *I, const DebugLoc &DL, + const MCInstrDesc &MCID) { + return BuildMI(BB, *I, DL, MCID); } /// This version of the builder inserts the newly-built instruction at the end /// of the given MachineBasicBlock, and does NOT take a destination register. -inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, const DebugLoc &DL, - const MCInstrDesc &MCID) { - return BuildMI(*BB, BB->end(), DL, MCID); +template +Builder BuildMI(MachineBasicBlock *BB, const DebugLoc &DL, + const MCInstrDesc &MCID) { + return BuildMI(*BB, BB->end(), DL, MCID); } /// This version of the builder inserts the newly-built instruction at the /// end of the given MachineBasicBlock, and sets up the first operand as a /// destination virtual register. -inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, const DebugLoc &DL, - const MCInstrDesc &MCID, unsigned DestReg) { - return BuildMI(*BB, BB->end(), DL, MCID, DestReg); +template +Builder BuildMI(MachineBasicBlock *BB, const DebugLoc &DL, + const MCInstrDesc &MCID, unsigned DestReg) { + return BuildMI(*BB, BB->end(), DL, MCID, DestReg); } /// This version of the builder builds a DBG_VALUE intrinsic /// for either a value in a register or a register-indirect+offset /// address. The convention is that a DBG_VALUE is indirect iff the /// second operand is an immediate. -inline MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, - const MCInstrDesc &MCID, bool IsIndirect, - unsigned Reg, unsigned Offset, - const MDNode *Variable, const MDNode *Expr) { +template +Builder BuildMI(MachineFunction &MF, const DebugLoc &DL, + const MCInstrDesc &MCID, bool IsIndirect, unsigned Reg, + unsigned Offset, const MDNode *Variable, const MDNode *Expr) { assert(isa(Variable) && "not a variable"); assert(cast(Expr)->isValid() && "not an expression"); assert(cast(Variable)->isValidLocationForIntrinsic(DL) && "Expected inlined-at fields to agree"); if (IsIndirect) - return BuildMI(MF, DL, MCID) + return BuildMI(MF, DL, MCID) .addReg(Reg, RegState::Debug) .addImm(Offset) .addMetadata(Variable) .addMetadata(Expr); else { assert(Offset == 0 && "A direct address cannot have an offset."); - return BuildMI(MF, DL, MCID) + return BuildMI(MF, DL, MCID) .addReg(Reg, RegState::Debug) .addReg(0U, RegState::Debug) .addMetadata(Variable) @@ -425,23 +427,20 @@ /// This version of the builder builds a DBG_VALUE intrinsic /// for either a value in a register or a register-indirect+offset /// address and inserts it at position I. -inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, - MachineBasicBlock::iterator I, - const DebugLoc &DL, const MCInstrDesc &MCID, - bool IsIndirect, unsigned Reg, - unsigned Offset, const MDNode *Variable, - const MDNode *Expr) { +template +Builder BuildMI(MachineBasicBlock &BB, MachineBasicBlock::iterator I, + const DebugLoc &DL, const MCInstrDesc &MCID, bool IsIndirect, + unsigned Reg, unsigned Offset, const MDNode *Variable, + const MDNode *Expr) { assert(isa(Variable) && "not a variable"); assert(cast(Expr)->isValid() && "not an expression"); MachineFunction &MF = *BB.getParent(); MachineInstr *MI = - BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr); + BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr); BB.insert(I, MI); - return MachineInstrBuilder(MF, MI); + return Builder(MF, MI); } -// FIXME: Remove inline from BuildMI when it becomes a template - inline unsigned getDefRegState(bool B) { return B ? RegState::Define : 0; }