aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-12-06 08:27:42 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-12-06 08:27:42 +0000
commit576d123e130a8291669dd2384a3735cc4933fd00 (patch)
treef7e03697f2c5159b7ebb825edfb83156db72e610 /lib/CodeGen/MachineInstr.cpp
parent93a498566a5ed50d1513511e2f827c0866676e65 (diff)
Move copyKillDeadInfo out-of-line. Add findRegisterUseOperand().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r--lib/CodeGen/MachineInstr.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index e0444fa038..04bd265228 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -169,6 +169,37 @@ bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
}
}
+/// 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;
}