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

Chris Lattner lattner at cs.uiuc.edu
Mon Oct 28 14:49:04 PST 2002


Changes in directory llvm/lib/CodeGen:

MachineInstr.cpp updated: 1.51 -> 1.52

---
Log message:

* Make MachineOperand ctors private, so MachineOperand can only be created 
  by MachineInstr.
* Add a bunch of new methods to allow incremental addition of operands to the
  machine instr instance.



---
Diffs of the changes:

Index: llvm/lib/CodeGen/MachineInstr.cpp
diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.51 llvm/lib/CodeGen/MachineInstr.cpp:1.52
--- llvm/lib/CodeGen/MachineInstr.cpp:1.51	Mon Oct 28 13:46:59 2002
+++ llvm/lib/CodeGen/MachineInstr.cpp	Mon Oct 28 14:48:39 2002
@@ -11,41 +11,42 @@
 // Constructor for instructions with fixed #operands (nearly all)
 MachineInstr::MachineInstr(MachineOpCode _opCode,
 			   OpCodeMask    _opCodeMask)
-  : opCode(_opCode),
-    opCodeMask(_opCodeMask),
-    operands(TargetInstrDescriptors[_opCode].numOperands)
-{
+  : opCode(_opCode), opCodeMask(_opCodeMask),
+    operands(TargetInstrDescriptors[_opCode].numOperands, MachineOperand()) {
   assert(TargetInstrDescriptors[_opCode].numOperands >= 0);
 }
 
 // Constructor for instructions with variable #operands
-MachineInstr::MachineInstr(MachineOpCode _opCode,
-			   unsigned	 numOperands,
-			   OpCodeMask    _opCodeMask)
-  : opCode(_opCode),
-    opCodeMask(_opCodeMask),
-    operands(numOperands)
-{
+MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned  numOperands,
+			   OpCodeMask    OpCodeMask)
+  : opCode(OpCode), opCodeMask(OpCodeMask),
+    operands(numOperands, MachineOperand()) {
 }
 
+// OperandComplete - Return true if it's illegal to add a new operand
+bool MachineInstr::OperandsComplete() const {
+  int NumOperands = TargetInstrDescriptors[opCode].numOperands;
+  if (NumOperands >= 0 && operands.size() >= (unsigned)NumOperands)
+    return true;  // Broken!
+  return false;
+}
+
+
 // 
 // Support for replacing opcode and operands of a MachineInstr in place.
 // This only resets the size of the operand vector and initializes it.
 // The new operands must be set explicitly later.
 // 
-void
-MachineInstr::replace(MachineOpCode _opCode,
-                      unsigned	    numOperands,
-                      OpCodeMask    _opCodeMask)
-{
-  opCode = _opCode;
-  opCodeMask = _opCodeMask;
+void MachineInstr::replace(MachineOpCode Opcode, unsigned numOperands,
+                           OpCodeMask Mask) {
+  opCode = Opcode;
+  opCodeMask = Mask;
   operands.clear();
-  operands.resize(numOperands);
+  operands.resize(numOperands, MachineOperand());
 }
 
 void
-MachineInstr::SetMachineOperandVal(unsigned int i,
+MachineInstr::SetMachineOperandVal(unsigned i,
                                    MachineOperand::MachineOperandType opType,
                                    Value* V,
                                    bool isdef,





More information about the llvm-commits mailing list