mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-05 14:34:55 +00:00
- Exposed SetCondInst::getInverseCondition & ::getSwappedCondition better
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3562 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3d92ac255e
commit
ea8b7b8bb5
@ -87,18 +87,17 @@ const Value *BinaryOperator::getNotArgument(const BinaryOperator *Bop) {
|
|||||||
// order dependant (SetLT f.e.) the opcode is changed.
|
// order dependant (SetLT f.e.) the opcode is changed.
|
||||||
//
|
//
|
||||||
bool BinaryOperator::swapOperands() {
|
bool BinaryOperator::swapOperands() {
|
||||||
|
if (SetCondInst *SCI = dyn_cast<SetCondInst>(this)) {
|
||||||
|
iType = SCI->getSwappedCondition();
|
||||||
|
std::swap(Operands[0], Operands[1]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (getOpcode()) {
|
switch (getOpcode()) {
|
||||||
// Instructions that don't need opcode modification
|
// Instructions that don't need opcode modification
|
||||||
case Add: case Mul:
|
case Add: case Mul:
|
||||||
case And: case Xor:
|
case And: case Xor:
|
||||||
case Or:
|
case Or:
|
||||||
case SetEQ: case SetNE:
|
|
||||||
break;
|
|
||||||
// Instructions that need opcode modification
|
|
||||||
case SetGT: iType = SetLT; break;
|
|
||||||
case SetLT: iType = SetGT; break;
|
|
||||||
case SetGE: iType = SetLE; break;
|
|
||||||
case SetLE: iType = SetGE; break;
|
|
||||||
// Error on the side of caution
|
// Error on the side of caution
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
@ -126,8 +125,8 @@ SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2,
|
|||||||
// getInverseCondition - Return the inverse of the current condition opcode.
|
// getInverseCondition - Return the inverse of the current condition opcode.
|
||||||
// For example seteq -> setne, setgt -> setle, setlt -> setge, etc...
|
// For example seteq -> setne, setgt -> setle, setlt -> setge, etc...
|
||||||
//
|
//
|
||||||
Instruction::BinaryOps SetCondInst::getInverseCondition() const {
|
Instruction::BinaryOps SetCondInst::getInverseCondition(BinaryOps Opcode) {
|
||||||
switch (getOpcode()) {
|
switch (Opcode) {
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unknown setcc opcode!");
|
assert(0 && "Unknown setcc opcode!");
|
||||||
case SetEQ: return SetNE;
|
case SetEQ: return SetNE;
|
||||||
@ -138,3 +137,18 @@ Instruction::BinaryOps SetCondInst::getInverseCondition() const {
|
|||||||
case SetLE: return SetGT;
|
case SetLE: return SetGT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getSwappedCondition - Return the condition opcode that would be the result
|
||||||
|
// of exchanging the two operands of the setcc instruction without changing
|
||||||
|
// the result produced. Thus, seteq->seteq, setle->setge, setlt->setgt, etc.
|
||||||
|
//
|
||||||
|
Instruction::BinaryOps SetCondInst::getSwappedCondition(BinaryOps Opcode) {
|
||||||
|
switch (Opcode) {
|
||||||
|
default: assert(0 && "Unknown setcc instruction!");
|
||||||
|
case SetEQ: case SetNE: return Opcode;
|
||||||
|
case SetGT: return SetLT;
|
||||||
|
case SetLT: return SetGT;
|
||||||
|
case SetGE: return SetLE;
|
||||||
|
case SetLE: return SetGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user