diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-07-10 23:26:12 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-07-10 23:26:12 +0000 |
commit | 12977990966fa3e7258a77bf80727f079cd83222 (patch) | |
tree | 0ec9c1df090ce84442292dc1f1eae69bfe931f7f /llvm/lib/CodeGen | |
parent | a51f8ebf1a1d2e882eb73628673940d57c1964c4 (diff) | |
download | bcm5719-llvm-12977990966fa3e7258a77bf80727f079cd83222.tar.gz bcm5719-llvm-12977990966fa3e7258a77bf80727f079cd83222.zip |
Use findCommutedOpIndices to find the operands to commute.
llvm-svn: 75312
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/TargetInstrInfoImpl.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp b/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp index b9a6040cd1c..97de901f431 100644 --- a/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp @@ -18,16 +18,26 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/PseudoSourceValue.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; // commuteInstruction - The default implementation of this method just exchanges -// operand 1 and 2. +// the two operands returned by findCommutedOpIndices. MachineInstr *TargetInstrInfoImpl::commuteInstruction(MachineInstr *MI, bool NewMI) const { const TargetInstrDesc &TID = MI->getDesc(); bool HasDef = TID.getNumDefs(); - unsigned Idx1 = HasDef ? 1 : 0; - unsigned Idx2 = HasDef ? 2 : 1; + if (HasDef && !MI->getOperand(0).isReg()) + // No idea how to commute this instruction. Target should implement its own. + return 0; + unsigned Idx1, Idx2; + if (!findCommutedOpIndices(MI, Idx1, Idx2)) { + std::string msg; + raw_string_ostream Msg(msg); + Msg << "Don't know how to commute: " << *MI; + llvm_report_error(Msg.str()); + } assert(MI->getOperand(Idx1).isReg() && MI->getOperand(Idx2).isReg() && "This only knows how to commute register operands so far"); |