[llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp
Evan Cheng
evan.cheng at apple.com
Wed Dec 6 00:27:57 PST 2006
Changes in directory llvm/lib/CodeGen:
MachineInstr.cpp updated: 1.136 -> 1.137
---
Log message:
Move copyKillDeadInfo out-of-line. Add findRegisterUseOperand().
---
Diffs of the changes: (+31 -0)
MachineInstr.cpp | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+)
Index: llvm/lib/CodeGen/MachineInstr.cpp
diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.136 llvm/lib/CodeGen/MachineInstr.cpp:1.137
--- llvm/lib/CodeGen/MachineInstr.cpp:1.136 Thu Nov 30 01:08:44 2006
+++ llvm/lib/CodeGen/MachineInstr.cpp Wed Dec 6 02:27:42 2006
@@ -169,6 +169,37 @@
}
}
+/// findRegisterUseOperand() - Returns the MachineOperand that is a use of
+/// the specific register or NULL if it is not found.
+MachineOperand *MachineInstr::findRegisterUseOperand(unsigned Reg) {
+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
+ MachineOperand &MO = getOperand(i);
+ if (MO.isReg() && MO.isUse() && MO.getReg() == Reg)
+ return &MO;
+ }
+ return NULL;
+}
+
+/// copyKillDeadInfo - Copies kill / dead operand properties from MI.
+///
+void MachineInstr::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()))
+ continue;
+ for (unsigned j = 0, ee = getNumOperands(); j != ee; ++j) {
+ MachineOperand &MOp = getOperand(j);
+ if (!MOp.isIdenticalTo(MO))
+ continue;
+ if (MO.isKill())
+ MOp.setIsKill();
+ else
+ MOp.setIsDead();
+ break;
+ }
+ }
+}
+
void MachineInstr::dump() const {
llvm_cerr << " " << *this;
}
More information about the llvm-commits
mailing list