* Wrap some comments to 80 cols
[oota-llvm.git] / include / llvm / CodeGen / MachineInstr.h
index 3950630aed1e4beaff79b954aeba918830712fcd..a9f1352b47b6079b2ef59e1c15ee04ae7bf7a39d 100644 (file)
@@ -16,7 +16,8 @@
 #ifndef LLVM_CODEGEN_MACHINEINSTR_H
 #define LLVM_CODEGEN_MACHINEINSTR_H
 
-#include "Support/iterator"
+#include "llvm/ADT/iterator"
+#include <string>
 #include <vector>
 #include <cassert>
 
@@ -135,6 +136,7 @@ private:
   MachineOperand(int ImmVal = 0, MachineOperandType OpTy = MO_VirtualRegister)
     : flags(0), opType(OpTy), regNum(-1) {
     zeroContents ();
+    contents.immedVal = ImmVal;
   }
 
   MachineOperand(int Reg, MachineOperandType OpTy, UseType UseTy)
@@ -170,6 +172,7 @@ public:
       contents.SymbolName = new std::string(M.getSymbolName());
   }
 
   ~MachineOperand() {
     if (isExternalSymbol())
       delete contents.SymbolName;
@@ -252,6 +255,10 @@ public:
     assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
     return contents.MBB;
   }
+  void setMachineBasicBlock(MachineBasicBlock *MBB) {
+    assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
+    contents.MBB = MBB;
+  }
   int getFrameIndex() const {
     assert(isFrameIndex() && "Wrong MachineOperand accessor");
     return contents.immedVal;
@@ -305,7 +312,13 @@ public:
     // code.' It's not clear where the duplication is.
     assert(hasAllocatedReg() && "This operand cannot have a register number!");
     regNum = Reg;
-  }    
+  }  
+
+  void setValueReg(Value *val) {
+    assert(getVRegValueOrNull() != 0 && "Original operand must of type Value*");
+    contents.value = val;
+  }
+  
   void setImmedValue(int immVal) {
     assert(isImmediate() && "Wrong MachineOperand mutator");
     contents.immedVal = immVal;
@@ -313,16 +326,15 @@ public:
 
   friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
 
-private:
-  /// markHi32, markLo32, etc. - These methods must be accessed via
-  /// corresponding methods in MachineInstr.  These methods are deprecated
-  /// and only used by the SPARC v9 back-end.
+  /// markHi32, markLo32, etc. - These methods are deprecated and only used by
+  /// the SPARC v9 back-end.
   ///
   void markHi32()      { flags |= HIFLAG32; }
   void markLo32()      { flags |= LOFLAG32; }
   void markHi64()      { flags |= HIFLAG64; }
   void markLo64()      { flags |= LOFLAG64; }
   
+private:
   /// setRegForValue - Replaces the Value with its corresponding physical
   /// register after register allocation is complete. This is deprecated
   /// and only used by the SPARC v9 back-end.
@@ -365,7 +377,9 @@ class MachineInstr {
   // OperandComplete - Return true if it's illegal to add a new operand
   bool OperandsComplete() const;
 
-  MachineInstr(const MachineInstr &);  // DO NOT IMPLEMENT
+  //Constructor used by clone() method
+  MachineInstr(const MachineInstr&);
+
   void operator=(const MachineInstr&); // DO NOT IMPLEMENT
 
   // Intrusive list support
@@ -453,10 +467,14 @@ public:
                          MachineOperand::MO_VirtualRegister, V);
   }
 
+  /// clone - Create a copy of 'this' instruction that is identical in
+  /// all ways except the the instruction has no parent, prev, or next.
+  MachineInstr* clone() const;
+
   //
   // Debugging support
   //
-  void print(std::ostream &OS, const TargetMachine &TM) const;
+  void print(std::ostream &OS, const TargetMachine *TM) const;
   void dump() const;
   friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr);
 
@@ -649,12 +667,6 @@ public:
   unsigned substituteValue(const Value* oldVal, Value* newVal,
                            bool defsOnly, bool notDefsAndUses,
                            bool& someArgsWereIgnored);
-
-  void setOperandHi32(unsigned i) { operands[i].markHi32(); }
-  void setOperandLo32(unsigned i) { operands[i].markLo32(); }
-  void setOperandHi64(unsigned i) { operands[i].markHi64(); }
-  void setOperandLo64(unsigned i) { operands[i].markLo64(); }
-  
   
   // SetRegForOperand -
   // SetRegForImplicitRef -