aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/VirtRegMap.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-11-01 23:06:55 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-11-01 23:06:55 +0000
commit360c2dd25a0dc7eaed3d57af47a47ac7d12a6886 (patch)
tree2412ed9222d0a01a29a99e544854b56be432e840 /lib/CodeGen/VirtRegMap.cpp
parente0805a2d36ac1c27b6e1bb2eb3ccddfd14b2f908 (diff)
Two-address instructions no longer have to be A := A op C. Now any pair of dest / src operands can be tied together.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r--lib/CodeGen/VirtRegMap.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index 850c16904e..911c5c6b79 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -98,7 +98,8 @@ void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI,
}
ModRef MRInfo;
- if (OpNo < 2 && TII.isTwoAddrInstr(OldMI->getOpcode())) {
+ if (TII.getOperandConstraint(OldMI->getOpcode(), OpNo,
+ TargetInstrInfo::TIED_TO)) {
// Folded a two-address operand.
MRInfo = isModRef;
} else if (OldMI->getOperand(OpNo).isDef()) {
@@ -560,9 +561,11 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
// aren't allowed to modify the reused register. If none of these cases
// apply, reuse it.
bool CanReuse = true;
- if (i == 1 && MI.getOperand(0).isReg() &&
- MI.getOperand(0).getReg() == VirtReg &&
- TII->isTwoAddrInstr(MI.getOpcode())) {
+ int ti = TII->getOperandConstraint(MI.getOpcode(), i,
+ TargetInstrInfo::TIED_TO);
+ if (ti != -1 &&
+ MI.getOperand(ti).isReg() &&
+ MI.getOperand(ti).getReg() == VirtReg) {
// Okay, we have a two address operand. We can reuse this physreg as
// long as we are allowed to clobber the value.
CanReuse = Spills.canClobberPhysReg(StackSlot);
@@ -818,8 +821,9 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
// If this def is part of a two-address operand, make sure to execute
// the store from the correct physical register.
unsigned PhysReg;
- if (i == 0 && TII->isTwoAddrInstr(MI.getOpcode()))
- PhysReg = MI.getOperand(1).getReg();
+ int TiedOp = TII->getTiedToSrcOperand(MI.getOpcode(), i);
+ if (TiedOp != -1)
+ PhysReg = MI.getOperand(TiedOp).getReg();
else
PhysReg = VRM.getPhys(VirtReg);