[llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp X86InstrInfo.h
Chris Lattner
sabre at nondot.org
Fri Oct 20 22:52:54 PDT 2006
Changes in directory llvm/lib/Target/X86:
X86InstrInfo.cpp updated: 1.68 -> 1.69
X86InstrInfo.h updated: 1.57 -> 1.58
---
Log message:
Implement support for branch condition reversal.
---
Diffs of the changes: (+33 -2)
X86InstrInfo.cpp | 30 ++++++++++++++++++++++++++++--
X86InstrInfo.h | 5 +++++
2 files changed, 33 insertions(+), 2 deletions(-)
Index: llvm/lib/Target/X86/X86InstrInfo.cpp
diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.68 llvm/lib/Target/X86/X86InstrInfo.cpp:1.69
--- llvm/lib/Target/X86/X86InstrInfo.cpp:1.68 Sat Oct 21 00:42:09 2006
+++ llvm/lib/Target/X86/X86InstrInfo.cpp Sat Oct 21 00:52:40 2006
@@ -290,6 +290,31 @@
}
}
+/// GetOppositeBranchCondition - Return the inverse of the specified condition,
+/// e.g. turning COND_E to COND_NE.
+X86::CondCode X86::GetOppositeBranchCondition(X86::CondCode CC) {
+ switch (CC) {
+ default: assert(0 && "Illegal condition code!");
+ case X86::COND_E: return X86::COND_NE;
+ case X86::COND_NE: return X86::COND_E;
+ case X86::COND_L: return X86::COND_GE;
+ case X86::COND_LE: return X86::COND_G;
+ case X86::COND_G: return X86::COND_LE;
+ case X86::COND_GE: return X86::COND_L;
+ case X86::COND_B: return X86::COND_AE;
+ case X86::COND_BE: return X86::COND_A;
+ case X86::COND_A: return X86::COND_BE;
+ case X86::COND_AE: return X86::COND_B;
+ case X86::COND_S: return X86::COND_NS;
+ case X86::COND_NS: return X86::COND_S;
+ case X86::COND_P: return X86::COND_NP;
+ case X86::COND_NP: return X86::COND_P;
+ case X86::COND_O: return X86::COND_NO;
+ case X86::COND_NO: return X86::COND_O;
+ }
+}
+
+
bool X86InstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
MachineBasicBlock *&TBB,
MachineBasicBlock *&FBB,
@@ -397,8 +422,9 @@
bool X86InstrInfo::
ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
- // TODO: IMPLEMENT.
- return true;
+ assert(Cond.size() == 1 && "Invalid X86 branch condition!");
+ Cond[0].setImm(GetOppositeBranchCondition((X86::CondCode)Cond[0].getImm()));
+ return false;
}
const TargetRegisterClass *X86InstrInfo::getPointerRegClass() const {
Index: llvm/lib/Target/X86/X86InstrInfo.h
diff -u llvm/lib/Target/X86/X86InstrInfo.h:1.57 llvm/lib/Target/X86/X86InstrInfo.h:1.58
--- llvm/lib/Target/X86/X86InstrInfo.h:1.57 Fri Oct 20 12:42:20 2006
+++ llvm/lib/Target/X86/X86InstrInfo.h Sat Oct 21 00:52:40 2006
@@ -46,6 +46,11 @@
// Turn condition code into conditional branch opcode.
unsigned GetCondBranchFromCond(CondCode CC);
+
+ /// GetOppositeBranchCondition - Return the inverse of the specified cond,
+ /// e.g. turning COND_E to COND_NE.
+ CondCode GetOppositeBranchCondition(X86::CondCode CC);
+
}
/// X86II - This namespace holds all of the target specific flags that
More information about the llvm-commits
mailing list