aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/MachineInstr.h16
-rw-r--r--include/llvm/CodeGen/MachineInstrBuilder.h50
2 files changed, 29 insertions, 37 deletions
diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h
index 7ad33f5..1aa8b40 100644
--- a/include/llvm/CodeGen/MachineInstr.h
+++ b/include/llvm/CodeGen/MachineInstr.h
@@ -27,7 +27,6 @@ namespace llvm {
class Value;
class Function;
class MachineBasicBlock;
-class TargetInstrInfo;
class TargetInstrDescriptor;
class TargetMachine;
class GlobalValue;
@@ -296,7 +295,7 @@ public:
///
class MachineInstr {
short Opcode; // the opcode
- short NumImplicitOps; // Number of implicit operands (which
+ unsigned short NumImplicitOps; // Number of implicit operands (which
// are determined at construction time).
std::vector<MachineOperand> Operands; // the operands
@@ -314,19 +313,20 @@ class MachineInstr {
friend struct ilist_traits<MachineInstr>;
public:
- /// MachineInstr ctor - This constructor reserves space for numOperand
- /// operands.
- MachineInstr(short Opcode, unsigned numOperands);
+ /// MachineInstr ctor - This constructor creates a dummy MachineInstr with
+ /// opcode 0 and no operands.
+ MachineInstr();
/// MachineInstr ctor - This constructor create a MachineInstr and add the
- /// implicit operands. It reserves space for numOperand operands.
- MachineInstr(const TargetInstrInfo &TII, short Opcode, unsigned numOperands);
+ /// implicit operands. It reserves space for number of operands specified by
+ /// TargetInstrDescriptor.
+ MachineInstr(const TargetInstrDescriptor &TID);
/// MachineInstr ctor - Work exactly the same as the ctor above, except that
/// the MachineInstr is created and added to the end of the specified basic
/// block.
///
- MachineInstr(MachineBasicBlock *MBB, short Opcode, unsigned numOps);
+ MachineInstr(MachineBasicBlock *MBB, const TargetInstrDescriptor &TID);
~MachineInstr();
diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h
index 1fd9348..8bacdee 100644
--- a/include/llvm/CodeGen/MachineInstrBuilder.h
+++ b/include/llvm/CodeGen/MachineInstrBuilder.h
@@ -19,10 +19,11 @@
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/Target/TargetMachine.h"
namespace llvm {
+class TargetInstrDescriptor;
+
class MachineInstrBuilder {
MachineInstr *MI;
public:
@@ -83,36 +84,29 @@ public:
};
/// BuildMI - Builder interface. Specify how to create the initial instruction
-/// itself. NumOperands is the number of operands to the machine instruction to
-/// allow for memory efficient representation of machine instructions.
+/// itself.
///
-inline MachineInstrBuilder BuildMI(const TargetInstrInfo &TII, int Opcode,
- unsigned NumOperands) {
- return MachineInstrBuilder(new MachineInstr(TII, Opcode, NumOperands));
+inline MachineInstrBuilder BuildMI(const TargetInstrDescriptor &TID) {
+ return MachineInstrBuilder(new MachineInstr(TID));
}
/// BuildMI - This version of the builder sets up the first operand as a
-/// destination virtual register. NumOperands is the number of additional add*
-/// calls that are expected, not including the destination register.
+/// destination virtual register.
///
-inline MachineInstrBuilder BuildMI(const TargetInstrInfo &TII, int Opcode,
- unsigned NumOperands, unsigned DestReg) {
- return MachineInstrBuilder(new MachineInstr(TII, Opcode, NumOperands+1))
- .addReg(DestReg, true);
+ inline MachineInstrBuilder BuildMI(const TargetInstrDescriptor &TID,
+ unsigned DestReg) {
+ return MachineInstrBuilder(new MachineInstr(TID)).addReg(DestReg, true);
}
/// BuildMI - 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.
-/// NumOperands is the number of additional add* calls that are expected,
-/// not including the destination register.
///
inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
MachineBasicBlock::iterator I,
- int Opcode, unsigned NumOperands,
+ const TargetInstrDescriptor &TID,
unsigned DestReg) {
- MachineInstr *MI = new MachineInstr(*BB.getParent()->getTarget().
- getInstrInfo(), Opcode, NumOperands+1);
+ MachineInstr *MI = new MachineInstr(TID);
BB.insert(I, MI);
return MachineInstrBuilder(MI).addReg(DestReg, true);
}
@@ -123,9 +117,8 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
///
inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
MachineBasicBlock::iterator I,
- int Opcode, unsigned NumOperands) {
- MachineInstr *MI = new MachineInstr(*BB.getParent()->getTarget().
- getInstrInfo(), Opcode, NumOperands);
+ const TargetInstrDescriptor &TID) {
+ MachineInstr *MI = new MachineInstr(TID);
BB.insert(I, MI);
return MachineInstrBuilder(MI);
}
@@ -134,20 +127,19 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
/// instruction at the end of the given MachineBasicBlock, and does NOT take a
/// destination register.
///
-inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, int Opcode,
- unsigned NumOperands) {
- return BuildMI(*BB, BB->end(), Opcode, NumOperands);
+inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB,
+ const TargetInstrDescriptor &TID) {
+ return BuildMI(*BB, BB->end(), TID);
}
/// BuildMI - 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. NumOperands is the number of
-/// additional add* calls that are expected, not including the destination
-/// register.
+/// operand as a destination virtual register.
///
-inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, int Opcode,
- unsigned NumOperands, unsigned DestReg) {
- return BuildMI(*BB, BB->end(), Opcode, NumOperands, DestReg);
+inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB,
+ const TargetInstrDescriptor &TID,
+ unsigned DestReg) {
+ return BuildMI(*BB, BB->end(), TID, DestReg);
}
} // End llvm namespace