diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-03-19 20:30:06 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-03-19 20:30:06 +0000 |
commit | 1361cbbb0ba022b3496d30e00aa06990826a4ee3 (patch) | |
tree | e7bf397ee275e6e7ff4cd418b8e6e52640707d9b /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 05799db963def5a5ad882fd3388c58a5e1648159 (diff) | |
download | bcm5719-llvm-1361cbbb0ba022b3496d30e00aa06990826a4ee3.tar.gz bcm5719-llvm-1361cbbb0ba022b3496d30e00aa06990826a4ee3.zip |
Added MachineInstr::isRegTiedToDefOperand to check for two-addressness.
llvm-svn: 67335
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 7bb616468c1..cc85b80a178 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -689,7 +689,7 @@ int MachineInstr::findFirstPredOperandIdx() const { return -1; } -/// isRegReDefinedByTwoAddr - Given the index of a register def operand, +/// isRegReDefinedByTwoAddr - Given the index of a register operand, /// check if the register def is a re-definition due to two addr elimination. bool MachineInstr::isRegReDefinedByTwoAddr(unsigned DefIdx) const{ assert(getOperand(DefIdx).isDef() && "DefIdx is not a def!"); @@ -703,6 +703,24 @@ bool MachineInstr::isRegReDefinedByTwoAddr(unsigned DefIdx) const{ return false; } +/// isRegTiedToDefOperand - Return true if the operand of the specified index +/// is a register use and it is tied to an def operand. It also returns the def +/// operand index by reference. +bool MachineInstr::isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx){ + const TargetInstrDesc &TID = getDesc(); + if (UseOpIdx >= TID.getNumOperands()) + return false; + const MachineOperand &MO = getOperand(UseOpIdx); + if (!MO.isReg() || !MO.isUse()) + return false; + int DefIdx = TID.getOperandConstraint(UseOpIdx, TOI::TIED_TO); + if (DefIdx == -1) + return false; + if (DefOpIdx) + *DefOpIdx = (unsigned)DefIdx; + return true; +} + /// copyKillDeadInfo - Copies kill / dead operand properties from MI. /// void MachineInstr::copyKillDeadInfo(const MachineInstr *MI) { |