Add BuildMI variants that take a MBB::iterator
authorChris Lattner <sabre@nondot.org>
Sun, 29 Feb 2004 04:55:28 +0000 (04:55 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 29 Feb 2004 04:55:28 +0000 (04:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11975 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstrBuilder.h

index b4b491e3f0d0d82fecb1b508433077936962d282..9f0667867a88c20b4905187fddba184a489b726b 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef LLVM_CODEGEN_MACHINEINSTRBUILDER_H
 #define LLVM_CODEGEN_MACHINEINSTRBUILDER_H
 
-#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
 
 namespace llvm {
 
@@ -150,12 +150,33 @@ inline MachineInstrBuilder BuildMI(
 }
 
 
+/// BuildMI - Insert the instruction before a specified location in the basic
+/// block.
+inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
+                                   MachineBasicBlock::iterator I,
+                                   int Opcode, unsigned NumOperands,
+                                   unsigned DestReg) {
+  MachineInstr *MI = new MachineInstr(Opcode, NumOperands+1, true, true);
+  BB.insert(I, MI);
+  return MachineInstrBuilder(MI).addReg(DestReg, MachineOperand::Def);
+}
+
+/// BMI - A special BuildMI variant that takes an iterator to insert the
+/// instruction at as well as a basic block.
+inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
+                                   MachineBasicBlock::iterator I,
+                                   int Opcode, unsigned NumOperands) {
+  MachineInstr *MI = new MachineInstr(Opcode, NumOperands, true, true);
+  BB.insert(I, MI);
+  return MachineInstrBuilder(MI);
+}
+
 /// BuildMI - This version of the builder inserts the built MachineInstr into
 /// the specified MachineBasicBlock.
 ///
 inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, int Opcode,
                                    unsigned NumOperands) {
-  return MachineInstrBuilder(new MachineInstr(BB, Opcode, NumOperands));
+  return BuildMI(*BB, BB->end(), Opcode, NumOperands);
 }
 
 /// BuildMI - This version of the builder inserts the built MachineInstr into
@@ -165,9 +186,7 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, int Opcode,
 ///
 inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, int Opcode,
                                    unsigned NumOperands, unsigned DestReg) {
-  return MachineInstrBuilder(
-    new MachineInstr(BB, Opcode, NumOperands+1))
-      .addReg(DestReg, MachineOperand::Def);
+  return BuildMI(*BB, BB->end(), Opcode, NumOperands, DestReg);
 }
 
 } // End llvm namespace