Added findRegisterDefOperand().
authorEvan Cheng <evan.cheng@apple.com>
Sat, 17 Feb 2007 11:10:18 +0000 (11:10 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Sat, 17 Feb 2007 11:10:18 +0000 (11:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34380 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstr.h
lib/CodeGen/MachineInstr.cpp

index ad2ccdf8ca14adc40ef72e4018707d69b78b6862..9cefe7bf20ce50d1aa54c54c8ec34d6f8a024f62 100644 (file)
@@ -393,6 +393,10 @@ public:
   /// the specific register or NULL if it is not found.
   MachineOperand *findRegisterUseOperand(unsigned Reg);
   
+  /// findRegisterDefOperand() - Returns the MachineOperand that is a def of
+  /// the specific register or NULL if it is not found.
+  MachineOperand *findRegisterDefOperand(unsigned Reg);
+  
   /// copyKillDeadInfo - Copies kill / dead operand properties from MI.
   ///
   void copyKillDeadInfo(const MachineInstr *MI);
index a39313310c2166d9e89df5b655d6e58f1adca60c..01a3e3ee381a172d59f442dde4b6bdff3dc16b82 100644 (file)
@@ -180,6 +180,17 @@ MachineOperand *MachineInstr::findRegisterUseOperand(unsigned Reg) {
   return NULL;
 }
   
+/// findRegisterDefOperand() - Returns the MachineOperand that is a def of
+/// the specific register or NULL if it is not found.
+MachineOperand *MachineInstr::findRegisterDefOperand(unsigned Reg) {
+  for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
+    MachineOperand &MO = getOperand(i);
+    if (MO.isReg() && MO.isDef() && MO.getReg() == Reg)
+      return &MO;
+  }
+  return NULL;
+}
+  
 /// copyKillDeadInfo - Copies kill / dead operand properties from MI.
 ///
 void MachineInstr::copyKillDeadInfo(const MachineInstr *MI) {