Register scavenger is now capable of scavenging. It spills a register whose use of...
[oota-llvm.git] / include / llvm / CodeGen / MachineInstr.h
index e19a3ebfbe8e69d3434437952d10b1f408948b83..3351aa802103dc20df72f78377fadcf85d4d6605 100644 (file)
@@ -76,6 +76,10 @@ private:
   int offset;
 
   MachineOperand() {}
+
+  void print(std::ostream &os) const;
+  void print(std::ostream *os) const { if (os) print(*os); }
+
 public:
   MachineOperand(const MachineOperand &M) {
     *this = M;
@@ -276,17 +280,20 @@ public:
   /// ChangeToRegister - Replace this operand with a new register operand of
   /// the specified value.  If an operand is known to be an register already,
   /// the setReg method should be used.
-  void ChangeToRegister(unsigned Reg, bool isDef) {
+  void ChangeToRegister(unsigned Reg, bool isDef, bool isImp = false,
+                        bool isKill = false, bool isDead = false) {
     opType = MO_Register;
     contents.RegNo = Reg;
     IsDef = isDef;
-    IsImp = false;
-    IsKill = false;
-    IsDead = false;
+    IsImp = isImp;
+    IsKill = isKill;
+    IsDead = isDead;
   }
 
-  friend OStream& operator<<(OStream& os, const MachineOperand& mop);
-  friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
+  friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop) {
+    mop.print(os);
+    return os;
+  }
 
   friend class MachineInstr;
 };
@@ -384,8 +391,13 @@ public:
   }
 
   /// findRegisterUseOperand() - Returns the MachineOperand that is a use of
+  /// the specific register or NULL if it is not found. It further tightening
+  /// the search criteria to a use that kills the register if isKill is true.
+  MachineOperand *findRegisterUseOperand(unsigned Reg, bool isKill = false);
+  
+  /// findRegisterDefOperand() - Returns the MachineOperand that is a def of
   /// the specific register or NULL if it is not found.
-  MachineOperand *findRegisterUseOperand(unsigned Reg);
+  MachineOperand *findRegisterDefOperand(unsigned Reg);
   
   /// copyKillDeadInfo - Copies kill / dead operand properties from MI.
   ///
@@ -394,13 +406,17 @@ public:
   //
   // Debugging support
   //
-  void print(OStream &OS, const TargetMachine *TM) const {
-    if (OS.stream()) print(*OS.stream(), TM);
+  void print(std::ostream *OS, const TargetMachine *TM) const {
+    if (OS) print(*OS, TM);
   }
   void print(std::ostream &OS, const TargetMachine *TM) const;
+  void print(std::ostream &OS) const;
+  void print(std::ostream *OS) const { if (OS) print(*OS); }
   void dump() const;
-  friend OStream& operator<<(OStream& os, const MachineInstr& minstr);
-  friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr);
+  friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr){
+    minstr.print(os);
+    return os;
+  }
 
   //===--------------------------------------------------------------------===//
   // Accessors to add operands when building up machine instructions.