21 #define DEBUG_TYPE "aarch64tti"
36 return (64 - LZ + 15) / 16;
50 ImmVal = Imm.
sext((BitSize + 63) & ~0x3fU);
55 for (
unsigned ShiftVal = 0; ShiftVal < BitSize; ShiftVal += 64) {
61 return std::max(1U, Cost);
74 unsigned ImmIdx = ~0U;
78 case Instruction::GetElementPtr:
86 case Instruction::Add:
87 case Instruction::Sub:
88 case Instruction::Mul:
89 case Instruction::UDiv:
90 case Instruction::SDiv:
91 case Instruction::URem:
92 case Instruction::SRem:
96 case Instruction::ICmp:
100 case Instruction::Shl:
101 case Instruction::LShr:
102 case Instruction::AShr:
106 case Instruction::Trunc:
107 case Instruction::ZExt:
108 case Instruction::SExt:
109 case Instruction::IntToPtr:
110 case Instruction::PtrToInt:
111 case Instruction::BitCast:
121 unsigned NumConstants = (BitSize + 63) / 64;
143 case Intrinsic::sadd_with_overflow:
144 case Intrinsic::uadd_with_overflow:
145 case Intrinsic::ssub_with_overflow:
146 case Intrinsic::usub_with_overflow:
147 case Intrinsic::smul_with_overflow:
148 case Intrinsic::umul_with_overflow:
150 unsigned NumConstants = (BitSize + 63) / 64;
157 case Intrinsic::experimental_stackmap:
161 case Intrinsic::experimental_patchpoint_void:
162 case Intrinsic::experimental_patchpoint_i64:
172 assert(
isPowerOf2_32(TyWidth) &&
"Ty width must be power of 2");
173 if (TyWidth == 32 || TyWidth == 64)
182 assert(ISD &&
"Invalid opcode");
253 int Idx = ConvertCostTableLookup<MVT>(
257 return ConversionTbl[Idx].Cost;
264 assert(Val->
isVectorTy() &&
"This must be a vector type");
271 if (!LT.second.isVector())
275 unsigned Width = LT.second.getVectorNumElements();
276 Index = Index % Width;
322 Opd1PropInfo, Opd2PropInfo);
339 unsigned NumVectorInstToHideOverhead = 10;
342 return NumVectorInstToHideOverhead;
356 const unsigned AmortizationCost = 20;
358 VectorSelectTbl[] = {
374 return VectorSelectTbl[Idx].
Cost;
392 unsigned AmortizationCost = 6;
394 return LT.first * 2 * AmortizationCost;
402 unsigned NumVectorizableInstsToAmortize = NumVecElts * 2;
404 return NumVectorizableInstsToAmortize * NumVecElts * 2;
413 assert(Factor >= 2 &&
"Invalid interleave factor");
414 assert(isa<VectorType>(VecTy) &&
"Expect a vector type");
416 if (Factor <= TLI->getMaxSupportedInterleaveFactor()) {
422 if (NumElts % Factor == 0 && (SubVecSize == 64 || SubVecSize == 128))
427 Alignment, AddressSpace);
432 for (
auto *
I : Tys) {
433 if (!
I->isVectorTy())
435 if (
I->getScalarSizeInBits() *
I->getVectorNumElements() == 128)
464 Type *ExpectedType) {
468 case Intrinsic::aarch64_neon_st2:
469 case Intrinsic::aarch64_neon_st3:
470 case Intrinsic::aarch64_neon_st4: {
478 for (
unsigned i = 0, e = NumElts; i != e; ++i) {
484 for (
unsigned i = 0, e = NumElts; i != e; ++i) {
490 case Intrinsic::aarch64_neon_ld2:
491 case Intrinsic::aarch64_neon_ld3:
492 case Intrinsic::aarch64_neon_ld4:
493 if (Inst->
getType() == ExpectedType)
504 case Intrinsic::aarch64_neon_ld2:
505 case Intrinsic::aarch64_neon_ld3:
506 case Intrinsic::aarch64_neon_ld4:
513 case Intrinsic::aarch64_neon_st2:
514 case Intrinsic::aarch64_neon_st3:
515 case Intrinsic::aarch64_neon_st4:
527 case Intrinsic::aarch64_neon_ld2:
528 case Intrinsic::aarch64_neon_st2:
531 case Intrinsic::aarch64_neon_ld3:
532 case Intrinsic::aarch64_neon_st3:
535 case Intrinsic::aarch64_neon_ld4:
536 case Intrinsic::aarch64_neon_st4:
APInt LLVM_ATTRIBUTE_UNUSED_RESULT ashr(unsigned shiftAmt) const
Arithmetic right-shift function.
unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace)
Cost tables and simple lookup functions.
Intrinsic::ID getIntrinsicID() const
getIntrinsicID - Return the intrinsic ID of this intrinsic.
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
Type Conversion Cost Table.
unsigned getMaxInterleaveFactor(unsigned VF)
std::size_t countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy)
unsigned getAddressComputationCost(Type *Ty, bool IsComplex)
unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src)
unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src)
unsigned short MatchingId
StructType - Class to represent struct types.
unsigned getNumArgOperands() const
getNumArgOperands - Return the number of call arguments.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static bool isLogicalImmediate(uint64_t imm, unsigned regSize)
isLogicalImmediate - Return true if the immediate is valid for a logical immediate instruction of the...
Type * getVectorElementType() const
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace)
int InstructionOpcodeToISD(unsigned Opcode) const
Get the ISD node that corresponds to the Instruction class opcode.
unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace)
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
Simple integer binary arithmetic operators.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info)
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy)
LLVM_CONSTEXPR size_t array_lengthof(T(&)[N])
Find the length of an array.
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType)
The instances of the Type class are immutable: once they are created, they are never changed...
bool isVectorTy() const
isVectorTy - True if this is an instance of VectorType.
Type * getElementType(unsigned N) const
int64_t getSExtValue() const
Get sign extended value.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const
Sign extend to a new width.
unsigned getBitWidth() const
Return the number of bits in the APInt.
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
EVT - Extended Value Type.
static UndefValue * get(Type *T)
get() - Static factory methods - Return an 'undef' object of the specified type.
unsigned getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys)
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
unsigned getVectorNumElements() const
Type * getType() const
All values are typed, get the type of this value.
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None)
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
Class for arbitrary precision integers.
Select(COND, TRUEVAL, FALSEVAL).
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
const Type * getScalarType() const LLVM_READONLY
getScalarType - If this is a vector type, return the element type, otherwise return 'this'...
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
Bitwise operators - logical and, logical or, logical xor.
unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP)
bool isSimple() const
isSimple - Test if the given EVT is simple (as opposed to being extended).
int ConvertCostTableLookup(const TypeConversionCostTblEntry< TypeTy > *Tbl, unsigned len, int ISD, CompareTy Dst, CompareTy Src)
Find in type conversion cost table, TypeTy must be comparable to CompareTy by ==. ...
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
unsigned getIntImmCost(int64_t Val)
Calculate the cost of materializing a 64-bit value.
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None)
bool isPowerOf2_32(uint32_t Value)
isPowerOf2_32 - This function returns true if the argument is a power of two > 0. ...
void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP)
unsigned getNumElements() const
Random access to the elements.
unsigned getLoopDepth() const
getLoopDepth - Return the nesting level of this loop.
Information about a load/store intrinsic defined by the target.
std::pair< unsigned, MVT > getTypeLegalizationCost(const DataLayout &DL, Type *Ty) const
Estimate the cost of type-legalization and the legalized type.
MVT getSimpleVT() const
getSimpleVT - Return the SimpleValueType held in the specified simple EVT.
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.