summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-07-10 07:35:43 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-07-10 07:35:43 +0000
commitef0732d25a9882c947984ae3f2afbef5463ba00f (patch)
treefb57684794d4837a901af952c17b790c9ab2cc69 /lib/CodeGen/MachineInstr.cpp
parent5dcc41f5b3daf6ef7097f169767291ff9cd0dd0b (diff)
downloadllvm-ef0732d25a9882c947984ae3f2afbef5463ba00f.tar.gz
llvm-ef0732d25a9882c947984ae3f2afbef5463ba00f.tar.bz2
llvm-ef0732d25a9882c947984ae3f2afbef5463ba00f.tar.xz
- Change the horrible N^2 isRegReDefinedByTwoAddr. Now callers must supply the operand index of def machineoperand and at most one full scan of non-implicit operands is needed.
- Change local register allocator to use the new isRegReDefinedByTwoAddr instead of reinventing the wheel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53394 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r--lib/CodeGen/MachineInstr.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index e9a8c63abd..6f616b4202 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -623,20 +623,15 @@ int MachineInstr::findFirstPredOperandIdx() const {
return -1;
}
-/// isRegReDefinedByTwoAddr - Returns true if the Reg re-definition is due
-/// to two addr elimination.
-bool MachineInstr::isRegReDefinedByTwoAddr(unsigned Reg) const {
+/// isRegReDefinedByTwoAddr - Given the defined register and the operand index,
+/// check if the register def is a re-definition due to two addr elimination.
+bool MachineInstr::isRegReDefinedByTwoAddr(unsigned Reg, unsigned DefIdx) const{
const TargetInstrDesc &TID = getDesc();
- for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
- const MachineOperand &MO1 = getOperand(i);
- if (MO1.isRegister() && MO1.isDef() && MO1.getReg() == Reg) {
- for (unsigned j = i+1; j < e; ++j) {
- const MachineOperand &MO2 = getOperand(j);
- if (MO2.isRegister() && MO2.isUse() && MO2.getReg() == Reg &&
- TID.getOperandConstraint(j, TOI::TIED_TO) == (int)i)
- return true;
- }
- }
+ for (unsigned i = 0, e = TID.getNumOperands(); i != e; ++i) {
+ const MachineOperand &MO = getOperand(i);
+ if (MO.isRegister() && MO.isUse() && MO.getReg() == Reg &&
+ TID.getOperandConstraint(i, TOI::TIED_TO) == (int)DefIdx)
+ return true;
}
return false;
}