Add TargetLowering::isLegalICmpImmediate. It tells LSR what immediate can be folded into target icmp instructions.

llvm-svn: 86858
This commit is contained in:
Evan Cheng 2009-11-11 19:05:52 +00:00
parent d576d66d91
commit 3d3c24a82c
3 changed files with 26 additions and 0 deletions

View File

@ -1514,6 +1514,14 @@ public:
return false; return false;
} }
/// isLegalICmpImmediate - Return true if the specified immediate is legal
/// icmp immediate, that is the target has icmp instructions which can compare
/// a register against the immediate without having to materialize the
/// immediate into a register.
virtual bool isLegalICmpImmediate(uint64_t Imm) const {
return true;
}
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Div utility functions // Div utility functions
// //

View File

@ -3706,6 +3706,18 @@ bool ARMTargetLowering::isLegalAddressingMode(const AddrMode &AM,
return true; return true;
} }
/// isLegalICmpImmediate - Return true if the specified immediate is legal
/// icmp immediate, that is the target has icmp instructions which can compare
/// a register against the immediate without having to materialize the
/// immediate into a register.
bool ARMTargetLowering::isLegalICmpImmediate(uint64_t Imm) const {
if (!Subtarget->isThumb())
return ARM_AM::getSOImmVal(Imm) != -1;
if (Subtarget->isThumb2())
return ARM_AM::getT2SOImmVal(Imm) != -1;
return Imm < 256;
}
static bool getARMIndexedAddressParts(SDNode *Ptr, EVT VT, static bool getARMIndexedAddressParts(SDNode *Ptr, EVT VT,
bool isSEXTLoad, SDValue &Base, bool isSEXTLoad, SDValue &Base,
SDValue &Offset, bool &isInc, SDValue &Offset, bool &isInc,

View File

@ -180,6 +180,12 @@ namespace llvm {
virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const; virtual bool isLegalAddressingMode(const AddrMode &AM, const Type *Ty)const;
bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const; bool isLegalT2ScaledAddressingMode(const AddrMode &AM, EVT VT) const;
/// isLegalICmpImmediate - Return true if the specified immediate is legal
/// icmp immediate, that is the target has icmp instructions which can compare
/// a register against the immediate without having to materialize the
/// immediate into a register.
virtual bool isLegalICmpImmediate(uint64_t Imm) const;
/// getPreIndexedAddressParts - returns true by value, base pointer and /// getPreIndexedAddressParts - returns true by value, base pointer and
/// offset pointer and addressing mode by reference if the node's address /// offset pointer and addressing mode by reference if the node's address
/// can be legally represented as pre-indexed load / store address. /// can be legally represented as pre-indexed load / store address.