diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2008-02-15 18:21:33 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2008-02-15 18:21:33 +0000 |
| commit | 9215129f4ef432d82800953cc54c0f7d2414ff33 (patch) | |
| tree | 79a8246900f1cb4b8fde6c6ac65a633b4e83f0da /llvm/lib/CodeGen | |
| parent | bd258284e0171fee68abb67904bb6d118e45ef8b (diff) | |
| download | bcm5719-llvm-9215129f4ef432d82800953cc54c0f7d2414ff33.tar.gz bcm5719-llvm-9215129f4ef432d82800953cc54c0f7d2414ff33.zip | |
Added CommuteChangesDestination(). This returns true if commuting the specified
machine instr will change its definition register.
llvm-svn: 47166
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/TargetInstrInfoImpl.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp b/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp index 4f6c1237e9f..ceec82b3078 100644 --- a/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp @@ -39,8 +39,28 @@ MachineInstr *TargetInstrInfoImpl::commuteInstruction(MachineInstr *MI) const { return MI; } +/// CommuteChangesDestination - Return true if commuting the specified +/// instruction will also changes the destination operand. Also return the +/// current operand index of the would be new destination register by +/// reference. This can happen when the commutable instruction is also a +/// two-address instruction. +bool TargetInstrInfoImpl::CommuteChangesDestination(MachineInstr *MI, + unsigned &OpIdx) const{ + assert(MI->getOperand(1).isRegister() && MI->getOperand(2).isRegister() && + "This only knows how to commute register operands so far"); + if (MI->getOperand(0).getReg() == MI->getOperand(1).getReg()) { + // Must be two address instruction! + assert(MI->getDesc().getOperandConstraint(0, TOI::TIED_TO) && + "Expecting a two-address instruction!"); + OpIdx = 2; + return true; + } + return false; +} + + bool TargetInstrInfoImpl::PredicateInstruction(MachineInstr *MI, - const std::vector<MachineOperand> &Pred) const { + const std::vector<MachineOperand> &Pred) const { bool MadeChange = false; const TargetInstrDesc &TID = MI->getDesc(); if (!TID.isPredicable()) |

