mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
[FastISel] Move optimizeCmpPredicate to FastISel base class. NFC.
Make the optimizeCmpPredicate function available to all targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217822 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
34ad085eec
commit
1ee1e8bdc2
@ -484,6 +484,8 @@ protected:
|
||||
/// \brief Create a machine mem operand from the given instruction.
|
||||
MachineMemOperand *createMachineMemOperandFor(const Instruction *I) const;
|
||||
|
||||
CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) const;
|
||||
|
||||
bool lowerCallTo(const CallInst *CI, const char *SymName, unsigned NumArgs);
|
||||
bool lowerCallTo(CallLoweringInfo &CLI);
|
||||
|
||||
|
@ -2142,3 +2142,43 @@ FastISel::createMachineMemOperandFor(const Instruction *I) const {
|
||||
return FuncInfo.MF->getMachineMemOperand(MachinePointerInfo(Ptr), Flags, Size,
|
||||
Alignment, AAInfo, Ranges);
|
||||
}
|
||||
|
||||
CmpInst::Predicate FastISel::optimizeCmpPredicate(const CmpInst *CI) const {
|
||||
// If both operands are the same, then try to optimize or fold the cmp.
|
||||
CmpInst::Predicate Predicate = CI->getPredicate();
|
||||
if (CI->getOperand(0) != CI->getOperand(1))
|
||||
return Predicate;
|
||||
|
||||
switch (Predicate) {
|
||||
default: llvm_unreachable("Invalid predicate!");
|
||||
case CmpInst::FCMP_FALSE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OEQ: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OGE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OLE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_ONE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_ORD: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_UNO: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UEQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UGT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_ULT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UNE: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_TRUE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
|
||||
case CmpInst::ICMP_EQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_NE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_ULT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SLE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
}
|
||||
|
||||
return Predicate;
|
||||
}
|
@ -164,46 +164,6 @@ private:
|
||||
|
||||
} // end anonymous namespace.
|
||||
|
||||
static CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) {
|
||||
// If both operands are the same, then try to optimize or fold the cmp.
|
||||
CmpInst::Predicate Predicate = CI->getPredicate();
|
||||
if (CI->getOperand(0) != CI->getOperand(1))
|
||||
return Predicate;
|
||||
|
||||
switch (Predicate) {
|
||||
default: llvm_unreachable("Invalid predicate!");
|
||||
case CmpInst::FCMP_FALSE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OEQ: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OGE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_OLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_OLE: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_ONE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::FCMP_ORD: Predicate = CmpInst::FCMP_ORD; break;
|
||||
case CmpInst::FCMP_UNO: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UEQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UGT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_ULT: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::FCMP_UNE: Predicate = CmpInst::FCMP_UNO; break;
|
||||
case CmpInst::FCMP_TRUE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
|
||||
case CmpInst::ICMP_EQ: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_NE: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_UGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_ULT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_ULE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SGT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SGE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
case CmpInst::ICMP_SLT: Predicate = CmpInst::FCMP_FALSE; break;
|
||||
case CmpInst::ICMP_SLE: Predicate = CmpInst::FCMP_TRUE; break;
|
||||
}
|
||||
|
||||
return Predicate;
|
||||
}
|
||||
|
||||
static std::pair<X86::CondCode, bool>
|
||||
getX86ConditionCode(CmpInst::Predicate Predicate) {
|
||||
X86::CondCode CC = X86::COND_INVALID;
|
||||
|
Loading…
Reference in New Issue
Block a user