[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h

Evan Cheng evan.cheng at apple.com
Wed Nov 15 12:48:32 PST 2006



Changes in directory llvm/include/llvm/CodeGen:

MachineInstr.h updated: 1.196 -> 1.197
---
Log message:

Add copyKillDeadInfo to copy kill / dead info; other minor updates.

---
Diffs of the changes:  (+28 -8)

 MachineInstr.h |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 deletions(-)


Index: llvm/include/llvm/CodeGen/MachineInstr.h
diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.196 llvm/include/llvm/CodeGen/MachineInstr.h:1.197
--- llvm/include/llvm/CodeGen/MachineInstr.h:1.196	Mon Nov 13 17:30:45 2006
+++ llvm/include/llvm/CodeGen/MachineInstr.h	Wed Nov 15 14:48:17 2006
@@ -206,19 +206,19 @@
     return IsDead;
   }
   void setIsKill() {
-    assert(isRegister() && "Wrong MachineOperand accessor");
+    assert(isRegister() && !IsDef && "Wrong MachineOperand accessor");
     IsKill = true;
   }
   void setIsDead() {
-    assert(isRegister() && "Wrong MachineOperand accessor");
+    assert(isRegister() && IsDef && "Wrong MachineOperand accessor");
     IsDead = true;
   }
   void unsetIsKill() {
-    assert(isRegister() && "Wrong MachineOperand accessor");
+    assert(isRegister() && !IsDef && "Wrong MachineOperand accessor");
     IsKill = false;
   }
   void unsetIsDead() {
-    assert(isRegister() && "Wrong MachineOperand accessor");
+    assert(isRegister() && IsDef && "Wrong MachineOperand accessor");
     IsDead = false;
   }
 
@@ -261,7 +261,7 @@
   }
   
   /// isIdenticalTo - Return true if this operand is identical to the specified
-  /// operand.
+  /// operand. Note: This method ignores isKill and isDead properties.
   bool isIdenticalTo(const MachineOperand &Other) const;
   
   /// ChangeToImmediate - Replace this operand with a new immediate operand of
@@ -295,13 +295,13 @@
 ///
 class MachineInstr {
   short Opcode;                         // the opcode
+  short NumImplicitOps;                 // Number of implicit operands (which
+                                        // are determined at construction time).
+
   std::vector<MachineOperand> Operands; // the operands
   MachineInstr* prev, *next;            // links for our intrusive list
   MachineBasicBlock* parent;            // pointer to the owning basic block
 
-  unsigned NumImplicitOps;              // Number of implicit operands (which
-                                        // are determined at construction time).
-
   // OperandComplete - Return true if it's illegal to add a new operand
   bool OperandsComplete() const;
 
@@ -376,6 +376,26 @@
     delete removeFromParent();
   }
 
+  /// copyKillDeadInfo - Copies kill / dead operand properties from MI.
+  ///
+  void copyKillDeadInfo(const MachineInstr *MI) {
+    for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+      const MachineOperand &MO = MI->getOperand(i);
+      if (MO.isReg() && (MO.isKill() || MO.isDead())) {
+        for (unsigned j = 0, ee = getNumOperands(); j != ee; ++j) {
+          MachineOperand &MOp = getOperand(j);
+          if (MOp.isIdenticalTo(MO)) {
+            if (MO.isKill())
+              MOp.setIsKill();
+            else
+              MOp.setIsDead();
+            break;
+          }
+        }
+      }
+    }
+  }
+
   //
   // Debugging support
   //






More information about the llvm-commits mailing list