diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-29 23:19:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-29 23:19:00 +0000 |
commit | 27ccb70df68684cb4b9d4dafacb88272c8700c45 (patch) | |
tree | 318c454cacef9a4b6b1fd8e21273ffda6b1dffce /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | bbd68ada1a23830c34fb9a8ca4aa104ab8b460a7 (diff) | |
download | bcm5719-llvm-27ccb70df68684cb4b9d4dafacb88272c8700c45.tar.gz bcm5719-llvm-27ccb70df68684cb4b9d4dafacb88272c8700c45.zip |
Implement autoinserting ctor
llvm-svn: 4426
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 91b5ce7728e..605fe16c9b1 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -3,6 +3,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Value.h" #include "llvm/Target/MachineInstrInfo.h" // FIXME: shouldn't need this! using std::cerr; @@ -33,6 +34,11 @@ MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned numOperands) { } +/// MachineInstr ctor - This constructor only does a _reserve_ of the operands, +/// not a resize for them. It is expected that if you use this that you call +/// add* methods below to fill up the operands, instead of the Set methods. +/// Eventually, the "resizing" ctors will be phased out. +/// MachineInstr::MachineInstr(MachineOpCode Opcode, unsigned numOperands, bool XX, bool YY) : opCode(Opcode), @@ -41,6 +47,20 @@ MachineInstr::MachineInstr(MachineOpCode Opcode, unsigned numOperands, operands.reserve(numOperands); } +/// 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::MachineInstr(MachineBasicBlock *MBB, MachineOpCode Opcode, + unsigned numOperands) + : opCode(Opcode), + numImplicitRefs(0) +{ + assert(MBB && "Cannot use inserting ctor with null basic block!"); + operands.reserve(numOperands); + MBB->push_back(this); // Add instruction to end of basic block! +} + + // OperandComplete - Return true if it's illegal to add a new operand bool MachineInstr::OperandsComplete() const { |