aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-29 04:55:28 +0000
committerChris Lattner <sabre@nondot.org>2004-02-29 04:55:28 +0000
commitc3c106ca59e44032041414c72ce584451f1d885f (patch)
tree6d087230458e2d05bd178621e451e16947b1eab2 /include
parent8777d241cf61066fc886eaeaaad9fd5c09ab1719 (diff)
downloadexternal_llvm-c3c106ca59e44032041414c72ce584451f1d885f.zip
external_llvm-c3c106ca59e44032041414c72ce584451f1d885f.tar.gz
external_llvm-c3c106ca59e44032041414c72ce584451f1d885f.tar.bz2
Add BuildMI variants that take a MBB::iterator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11975 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index b4b491e..9f06678 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -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