[llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 29 17:20:02 PST 2002


Changes in directory llvm/lib/CodeGen:

MachineInstr.cpp updated: 1.58 -> 1.59

---
Log message:

Implement autoinserting ctor


---
Diffs of the changes:

Index: llvm/lib/CodeGen/MachineInstr.cpp
diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.58 llvm/lib/CodeGen/MachineInstr.cpp:1.59
--- llvm/lib/CodeGen/MachineInstr.cpp:1.58	Tue Oct 29 13:40:17 2002
+++ llvm/lib/CodeGen/MachineInstr.cpp	Tue Oct 29 17:19:00 2002
@@ -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 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),
@@ -40,6 +46,20 @@
 {
   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





More information about the llvm-commits mailing list