17 #define DEBUG_TYPE "armtti"
42 unsigned getScalarizationOverhead(
Type *Ty,
bool Insert,
bool Extract)
const;
51 TLI(TM->getTargetLowering()) {
55 virtual void initializePass() {
59 virtual void finalizePass() {
71 virtual void *getAdjustedAnalysisPointer(
const void *
ID) {
80 virtual unsigned getIntImmCost(
const APInt &Imm,
Type *Ty)
const;
88 unsigned getNumberOfRegisters(
bool Vector)
const {
95 if (
ST->isThumb1Only())
100 unsigned getRegisterBitWidth(
bool Vector)
const {
110 unsigned getMaximumUnrollFactor()
const {
112 if (
ST->isCortexA15() ||
ST->isSwift())
117 unsigned getShuffleCost(ShuffleKind
Kind,
Type *Tp,
118 int Index,
Type *SubTp)
const;
120 unsigned getCastInstrCost(
unsigned Opcode,
Type *Dst,
123 unsigned getCmpSelInstrCost(
unsigned Opcode,
Type *ValTy,
Type *CondTy)
const;
125 unsigned getVectorInstrCost(
unsigned Opcode,
Type *Val,
unsigned Index)
const;
127 unsigned getAddressComputationCost(
Type *Val,
bool IsComplex)
const;
129 unsigned getArithmeticInstrCost(
unsigned Opcode,
Type *Ty,
130 OperandValueKind Op1Info = OK_AnyValue,
131 OperandValueKind Op2Info = OK_AnyValue)
const;
133 unsigned getMemoryOpCost(
unsigned Opcode,
Type *Src,
unsigned Alignment,
141 "ARM Target Transform Info",
true,
true,
false)
146 return new ARMTTI(TM);
150 unsigned ARMTTI::getIntImmCost(
const APInt &Imm,
Type *Ty)
const {
154 if (Bits == 0 || Bits > 32)
159 if (!
ST->isThumb()) {
160 if ((SImmVal >= 0 && SImmVal < 65536) ||
164 return ST->hasV6T2Ops() ? 2 : 3;
165 }
else if (
ST->isThumb2()) {
166 if ((SImmVal >= 0 && SImmVal < 65536) ||
170 return ST->hasV6T2Ops() ? 2 : 3;
172 if (SImmVal >= 0 && SImmVal < 256)
182 unsigned ARMTTI::getCastInstrCost(
unsigned Opcode,
Type *Dst,
184 int ISD = TLI->InstructionOpcodeToISD(Opcode);
185 assert(ISD &&
"Invalid opcode");
197 std::pair<unsigned, MVT>
LT = TLI->getTypeLegalizationCost(Src);
200 return LT.first * NEONFltDblTbl[Idx].
Cost;
203 EVT SrcTy = TLI->getValueType(Src);
204 EVT DstTy = TLI->getValueType(Dst);
213 NEONVectorConversionTbl[] = {
292 return NEONVectorConversionTbl[Idx].
Cost;
297 NEONFloatConversionTbl[] = {
323 return NEONFloatConversionTbl[Idx].
Cost;
328 NEONIntegerConversionTbl[] = {
355 return NEONIntegerConversionTbl[Idx].
Cost;
360 ARMIntegerConversionTbl[] = {
375 return ARMIntegerConversionTbl[Idx].
Cost;
381 unsigned ARMTTI::getVectorInstrCost(
unsigned Opcode,
Type *ValTy,
382 unsigned Index)
const {
386 Opcode == Instruction::InsertElement &&
394 unsigned ARMTTI::getCmpSelInstrCost(
unsigned Opcode,
Type *ValTy,
395 Type *CondTy)
const {
397 int ISD = TLI->InstructionOpcodeToISD(Opcode);
402 NEONVectorSelectTbl[] = {
411 EVT SelCondTy = TLI->getValueType(CondTy);
412 EVT SelValTy = TLI->getValueType(ValTy);
418 return NEONVectorSelectTbl[Idx].
Cost;
421 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(ValTy);
428 unsigned ARMTTI::getAddressComputationCost(
Type *Ty,
bool IsComplex)
const {
433 unsigned NumVectorInstToHideOverhead = 10;
436 return NumVectorInstToHideOverhead;
443 unsigned ARMTTI::getShuffleCost(ShuffleKind
Kind,
Type *Tp,
int Index,
446 if (Kind != SK_Reverse)
463 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Tp);
469 return LT.first * NEONShuffleTbl[Idx].
Cost;
472 unsigned ARMTTI::getArithmeticInstrCost(
unsigned Opcode,
Type *Ty, OperandValueKind Op1Info,
473 OperandValueKind Op2Info)
const {
475 int ISDOpcode = TLI->InstructionOpcodeToISD(Opcode);
476 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty);
478 const unsigned FunctionCallDivCost = 20;
479 const unsigned ReciprocalDivCost = 10;
527 return LT.first * CostTbl[Idx].
Cost;
546 unsigned ARMTTI::getMemoryOpCost(
unsigned Opcode,
Type *Src,
unsigned Alignment,
548 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Src);
ImmutablePass * createARMTargetTransformInfoPass(const ARMBaseTargetMachine *TM)
Creates an ARM-specific Target Transformation Info pass.
static PassRegistry * getPassRegistry()
uint64_t getZExtValue() const
Get zero extended value.
unsigned getScalarSizeInBits()
Cost tables and simple lookup functions.
int CostTableLookup(const CostTblEntry< TypeTy > *Tbl, unsigned len, int ISD, CompareTy Ty)
Find in cost table, TypeTy must be comparable to CompareTy by ==.
bool isDoubleTy() const
isDoubleTy - Return true if this is 'double', a 64-bit IEEE fp type.
Type Conversion Cost Table.
bool isVector() const
isVector - Return true if this is a vector value type.
#define llvm_unreachable(msg)
ID
LLVM Calling Convention Representation.
Type * getVectorElementType() const
bool isInteger() const
isInteger - Return true if this is an integer, or a vector integer type.
static int getT2SOImmVal(unsigned Arg)
static bool isThumbImmShiftedVal(unsigned V)
void initializeARMTTIPass(PassRegistry &)
int64_t getSExtValue() const
Get sign extended value.
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def)
Class for arbitrary precision integers.
ZERO_EXTEND - Used for integer types, zeroing the new bits.
static int getSOImmVal(unsigned Arg)
unsigned getPrimitiveSizeInBits() const
bool isFloatingPoint() const
isFloatingPoint - Return true if this is a FP, or a vector FP type.
int ConvertCostTableLookup(const TypeConversionCostTblEntry< TypeTy > *Tbl, unsigned len, int ISD, CompareTy Dst, CompareTy Src)
TRUNCATE - Completely drop the high bits.