21 #ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFO_H 22 #define LLVM_ANALYSIS_TARGETTRANSFORMINFO_H 73 unsigned short MatchingId = 0;
76 bool WriteMem =
false;
92 const SCEV *ExitCount =
nullptr;
96 bool IsNestingLegal =
false;
98 bool CounterInReg =
false;
100 bool PerformEntryTest =
false;
169 case TCK_RecipThroughput:
170 return getInstructionThroughput(I);
173 return getInstructionLatency(I);
176 return getUserCost(I);
219 int getOperationCost(
unsigned Opcode,
Type *Ty,
Type *OpTy =
nullptr)
const;
226 int getGEPCost(
Type *PointeeType,
const Value *Ptr,
246 const User *U =
nullptr)
const;
252 int getCallCost(
const Function *
F,
int NumArgs = -1,
253 const User *U =
nullptr)
const;
259 const User *U =
nullptr)
const;
267 unsigned getInliningThresholdMultiplier()
const;
279 int getInlinerVectorBonusPercent()
const;
286 const User *U =
nullptr)
const;
293 const User *U =
nullptr)
const;
302 unsigned getEstimatedNumberOfCaseClusters(
const SwitchInst &
SI,
343 bool hasBranchDivergence()
const;
351 bool isSourceOfDivergence(
const Value *V)
const;
356 bool isAlwaysUniform(
const Value *V)
const;
374 unsigned getFlatAddressSpace()
const;
402 bool isLoweredToCall(
const Function *
F)
const;
547 bool isLegalAddImmediate(int64_t Imm)
const;
553 bool isLegalICmpImmediate(int64_t Imm)
const;
561 bool isLegalAddressingMode(
Type *Ty,
GlobalValue *BaseGV, int64_t BaseOffset,
562 bool HasBaseReg, int64_t Scale,
563 unsigned AddrSpace = 0,
573 bool canMacroFuseCmp()
const;
583 bool shouldFavorPostInc()
const;
587 bool shouldFavorBackedgeIndex(
const Loop *L)
const;
592 bool isLegalMaskedLoad(
Type *DataType,
MaybeAlign Alignment)
const;
595 bool isLegalNTStore(
Type *DataType,
Align Alignment)
const;
597 bool isLegalNTLoad(
Type *DataType,
Align Alignment)
const;
600 bool isLegalMaskedScatter(
Type *DataType,
MaybeAlign Alignment)
const;
602 bool isLegalMaskedGather(
Type *DataType,
MaybeAlign Alignment)
const;
605 bool isLegalMaskedCompressStore(
Type *DataType)
const;
607 bool isLegalMaskedExpandLoad(
Type *DataType)
const;
614 bool hasDivRemOp(
Type *DataType,
bool IsSigned)
const;
621 bool hasVolatileVariant(
Instruction *
I,
unsigned AddrSpace)
const;
624 bool prefersVectorizedAddressing()
const;
633 bool HasBaseReg, int64_t Scale,
634 unsigned AddrSpace = 0)
const;
640 bool LSRWithInstrQueries()
const;
645 bool isTruncateFree(
Type *Ty1,
Type *Ty2)
const;
654 bool isTypeLegal(
Type *Ty)
const;
658 bool shouldBuildLookupTables()
const;
662 bool shouldBuildLookupTablesForConstant(
Constant *
C)
const;
666 bool useColdCCForColdCall(
Function &F)
const;
668 unsigned getScalarizationOverhead(
Type *Ty,
bool Insert,
bool Extract)
const;
676 bool supportsEfficientVectorElementLoadStore()
const;
679 bool enableAggressiveInterleaving(
bool LoopHasReductions)
const;
685 operator bool()
const {
return MaxNumLoads > 0; }
688 unsigned MaxNumLoads = 0;
701 unsigned NumLoadsPerBlock = 1;
706 bool AllowOverlappingLoads =
false;
709 bool IsZeroCmp)
const;
712 bool enableInterleavedAccessVectorization()
const;
717 bool enableMaskedInterleavedAccessVectorization()
const;
726 bool isFPVectorizationPotentiallyUnsafe()
const;
731 unsigned Alignment = 1,
732 bool *
Fast =
nullptr)
const;
738 bool haveFastSqrt(
Type *Ty)
const;
744 bool isFCmpOrdCheaperThanFCmpZero(
Type *Ty)
const;
748 int getFPOpCost(
Type *Ty)
const;
752 int getIntImmCost(
const APInt &Imm,
Type *Ty)
const;
757 int getIntImmCostInst(
unsigned Opc,
unsigned Idx,
const APInt &Imm,
769 int getIntImmCodeSizeCost(
unsigned Opc,
unsigned Idx,
const APInt &Imm,
797 OK_NonUniformConstantValue
804 unsigned getNumberOfRegisters(
unsigned ClassID)
const;
816 unsigned getRegisterClassForType(
bool Vector,
Type *Ty =
nullptr)
const;
819 const char* getRegisterClassName(
unsigned ClassID)
const;
822 unsigned getRegisterBitWidth(
bool Vector)
const;
825 unsigned getMinVectorRegisterBitWidth()
const;
833 bool shouldMaximizeVectorBandwidth(
bool OptSize)
const;
838 unsigned getMinimumVF(
unsigned ElemWidth)
const;
843 bool shouldConsiderAddressTypePromotion(
844 const Instruction &I,
bool &AllowPromotionWithoutCommonHeader)
const;
847 unsigned getCacheLineSize()
const;
868 unsigned getPrefetchDistance()
const;
874 unsigned getMinPrefetchStride()
const;
879 unsigned getMaxPrefetchIterationsAhead()
const;
884 unsigned getMaxInterleaveFactor(
unsigned VF)
const;
906 int getArithmeticInstrCost(
920 Type *SubTp =
nullptr)
const;
925 int getCastInstrCost(
unsigned Opcode,
Type *Dst,
Type *Src,
930 int getExtractWithExtendCost(
unsigned Opcode,
Type *Dst,
VectorType *VecTy,
931 unsigned Index = -1)
const;
935 int getCFInstrCost(
unsigned Opcode)
const;
940 int getCmpSelInstrCost(
unsigned Opcode,
Type *ValTy,
945 int getVectorInstrCost(
unsigned Opcode,
Type *Val,
unsigned Index = -1)
const;
948 int getMemoryOpCost(
unsigned Opcode,
Type *Src,
MaybeAlign Alignment,
953 int getMaskedMemoryOpCost(
unsigned Opcode,
Type *Src,
unsigned Alignment,
954 unsigned AddressSpace)
const;
963 int getGatherScatterOpCost(
unsigned Opcode,
Type *DataTy,
Value *Ptr,
964 bool VariableMask,
unsigned Alignment)
const;
976 int getInterleavedMemoryOpCost(
unsigned Opcode,
Type *VecTy,
unsigned Factor,
978 unsigned AddressSpace,
979 bool UseMaskForCond =
false,
980 bool UseMaskForGaps =
false)
const;
995 int getArithmeticReductionCost(
unsigned Opcode,
Type *Ty,
996 bool IsPairwiseForm)
const;
997 int getMinMaxReductionCost(
Type *Ty,
Type *CondTy,
bool IsPairwiseForm,
998 bool IsUnsigned)
const;
1005 unsigned VF = 1)
const;
1012 unsigned ScalarizationCostPassed = UINT_MAX)
const;
1019 unsigned getNumberOfParts(
Type *Tp)
const;
1029 const SCEV *Ptr =
nullptr)
const;
1046 unsigned getAtomicMemIntrinsicMaxElementSize()
const;
1053 Type *ExpectedType)
const;
1057 unsigned SrcAlign,
unsigned DestAlign)
const;
1067 unsigned RemainingBytes,
1069 unsigned DestAlign)
const;
1101 unsigned getLoadStoreVecRegBitWidth(
unsigned AddrSpace)
const;
1104 bool isLegalToVectorizeLoad(
LoadInst *LI)
const;
1107 bool isLegalToVectorizeStore(
StoreInst *
SI)
const;
1110 bool isLegalToVectorizeLoadChain(
unsigned ChainSizeInBytes,
1112 unsigned AddrSpace)
const;
1115 bool isLegalToVectorizeStoreChain(
unsigned ChainSizeInBytes,
1117 unsigned AddrSpace)
const;
1121 unsigned getLoadVectorFactor(
unsigned VF,
unsigned LoadSize,
1122 unsigned ChainSizeInBytes,
1127 unsigned getStoreVectorFactor(
unsigned VF,
unsigned StoreSize,
1128 unsigned ChainSizeInBytes,
1141 bool useReductionIntrinsic(
unsigned Opcode,
Type *Ty,
1150 unsigned getGISelRematGlobalCost()
const;
1157 int getInstructionLatency(
const Instruction *I)
const;
1161 int getInstructionThroughput(
const Instruction *I)
const;
1169 template <
typename T>
class Model;
1171 std::unique_ptr<Concept> TTIImpl;
1177 virtual const DataLayout &getDataLayout()
const = 0;
1178 virtual int getOperationCost(
unsigned Opcode,
Type *Ty,
Type *OpTy) = 0;
1179 virtual int getGEPCost(
Type *PointeeType,
const Value *Ptr,
1182 virtual int getCallCost(
FunctionType *FTy,
int NumArgs,
const User *U) = 0;
1183 virtual int getCallCost(
const Function *
F,
int NumArgs,
const User *U) = 0;
1184 virtual int getCallCost(
const Function *F,
1186 virtual unsigned getInliningThresholdMultiplier() = 0;
1187 virtual int getInlinerVectorBonusPercent() = 0;
1193 virtual int getMemcpyCost(
const Instruction *I) = 0;
1194 virtual unsigned getEstimatedNumberOfCaseClusters(
const SwitchInst &
SI,
1200 virtual bool hasBranchDivergence() = 0;
1201 virtual bool isSourceOfDivergence(
const Value *V) = 0;
1202 virtual bool isAlwaysUniform(
const Value *V) = 0;
1203 virtual unsigned getFlatAddressSpace() = 0;
1206 virtual bool rewriteIntrinsicWithAddressSpace(
1208 virtual bool isLoweredToCall(
const Function *F) = 0;
1215 virtual bool preferPredicateOverEpilogue(
Loop *L,
LoopInfo *LI,
1221 virtual bool isLegalAddImmediate(int64_t Imm) = 0;
1222 virtual bool isLegalICmpImmediate(int64_t Imm) = 0;
1224 int64_t BaseOffset,
bool HasBaseReg,
1230 virtual bool canMacroFuseCmp() = 0;
1234 virtual bool shouldFavorPostInc()
const = 0;
1235 virtual bool shouldFavorBackedgeIndex(
const Loop *L)
const = 0;
1237 virtual bool isLegalMaskedLoad(
Type *DataType,
MaybeAlign Alignment) = 0;
1238 virtual bool isLegalNTStore(
Type *DataType,
Align Alignment) = 0;
1239 virtual bool isLegalNTLoad(
Type *DataType,
Align Alignment) = 0;
1240 virtual bool isLegalMaskedScatter(
Type *DataType,
MaybeAlign Alignment) = 0;
1241 virtual bool isLegalMaskedGather(
Type *DataType,
MaybeAlign Alignment) = 0;
1242 virtual bool isLegalMaskedCompressStore(
Type *DataType) = 0;
1243 virtual bool isLegalMaskedExpandLoad(
Type *DataType) = 0;
1244 virtual bool hasDivRemOp(
Type *DataType,
bool IsSigned) = 0;
1245 virtual bool hasVolatileVariant(
Instruction *I,
unsigned AddrSpace) = 0;
1246 virtual bool prefersVectorizedAddressing() = 0;
1248 int64_t BaseOffset,
bool HasBaseReg,
1249 int64_t Scale,
unsigned AddrSpace) = 0;
1250 virtual bool LSRWithInstrQueries() = 0;
1251 virtual bool isTruncateFree(
Type *Ty1,
Type *Ty2) = 0;
1252 virtual bool isProfitableToHoist(
Instruction *I) = 0;
1253 virtual bool useAA() = 0;
1254 virtual bool isTypeLegal(
Type *Ty) = 0;
1255 virtual bool shouldBuildLookupTables() = 0;
1256 virtual bool shouldBuildLookupTablesForConstant(
Constant *
C) = 0;
1257 virtual bool useColdCCForColdCall(
Function &F) = 0;
1259 getScalarizationOverhead(
Type *Ty,
bool Insert,
bool Extract) = 0;
1262 virtual bool supportsEfficientVectorElementLoadStore() = 0;
1263 virtual bool enableAggressiveInterleaving(
bool LoopHasReductions) = 0;
1265 enableMemCmpExpansion(
bool OptSize,
bool IsZeroCmp)
const = 0;
1266 virtual bool enableInterleavedAccessVectorization() = 0;
1267 virtual bool enableMaskedInterleavedAccessVectorization() = 0;
1268 virtual bool isFPVectorizationPotentiallyUnsafe() = 0;
1275 virtual bool haveFastSqrt(
Type *Ty) = 0;
1276 virtual bool isFCmpOrdCheaperThanFCmpZero(
Type *Ty) = 0;
1277 virtual int getFPOpCost(
Type *Ty) = 0;
1278 virtual int getIntImmCodeSizeCost(
unsigned Opc,
unsigned Idx,
const APInt &Imm,
1280 virtual int getIntImmCost(
const APInt &Imm,
Type *Ty) = 0;
1281 virtual int getIntImmCostInst(
unsigned Opc,
unsigned Idx,
const APInt &Imm,
1283 virtual int getIntImmCostIntrin(
Intrinsic::ID IID,
unsigned Idx,
1285 virtual unsigned getNumberOfRegisters(
unsigned ClassID)
const = 0;
1286 virtual unsigned getRegisterClassForType(
bool Vector,
Type *Ty =
nullptr)
const = 0;
1287 virtual const char* getRegisterClassName(
unsigned ClassID)
const = 0;
1288 virtual unsigned getRegisterBitWidth(
bool Vector)
const = 0;
1289 virtual unsigned getMinVectorRegisterBitWidth() = 0;
1290 virtual bool shouldMaximizeVectorBandwidth(
bool OptSize)
const = 0;
1291 virtual unsigned getMinimumVF(
unsigned ElemWidth)
const = 0;
1292 virtual bool shouldConsiderAddressTypePromotion(
1293 const Instruction &I,
bool &AllowPromotionWithoutCommonHeader) = 0;
1294 virtual unsigned getCacheLineSize()
const = 0;
1301 virtual unsigned getPrefetchDistance()
const = 0;
1307 virtual unsigned getMinPrefetchStride()
const = 0;
1312 virtual unsigned getMaxPrefetchIterationsAhead()
const = 0;
1314 virtual unsigned getMaxInterleaveFactor(
unsigned VF) = 0;
1315 virtual unsigned getArithmeticInstrCost(
1322 virtual int getCastInstrCost(
unsigned Opcode,
Type *Dst,
Type *Src,
1324 virtual int getExtractWithExtendCost(
unsigned Opcode,
Type *Dst,
1326 virtual int getCFInstrCost(
unsigned Opcode) = 0;
1327 virtual int getCmpSelInstrCost(
unsigned Opcode,
Type *ValTy,
1329 virtual int getVectorInstrCost(
unsigned Opcode,
Type *Val,
1330 unsigned Index) = 0;
1331 virtual int getMemoryOpCost(
unsigned Opcode,
Type *Src,
MaybeAlign Alignment,
1333 virtual int getMaskedMemoryOpCost(
unsigned Opcode,
Type *Src,
1335 unsigned AddressSpace) = 0;
1336 virtual int getGatherScatterOpCost(
unsigned Opcode,
Type *DataTy,
1337 Value *Ptr,
bool VariableMask,
1338 unsigned Alignment) = 0;
1339 virtual int getInterleavedMemoryOpCost(
unsigned Opcode,
Type *VecTy,
1343 unsigned AddressSpace,
1344 bool UseMaskForCond =
false,
1345 bool UseMaskForGaps =
false) = 0;
1346 virtual int getArithmeticReductionCost(
unsigned Opcode,
Type *Ty,
1347 bool IsPairwiseForm) = 0;
1348 virtual int getMinMaxReductionCost(
Type *Ty,
Type *CondTy,
1349 bool IsPairwiseForm,
bool IsUnsigned) = 0;
1352 unsigned ScalarizationCostPassed) = 0;
1357 virtual unsigned getNumberOfParts(
Type *Tp) = 0;
1359 const SCEV *Ptr) = 0;
1363 virtual unsigned getAtomicMemIntrinsicMaxElementSize()
const = 0;
1365 Type *ExpectedType) = 0;
1368 unsigned DestAlign)
const = 0;
1369 virtual void getMemcpyLoopResidualLoweringType(
1371 unsigned RemainingBytes,
unsigned SrcAlign,
unsigned DestAlign)
const = 0;
1379 virtual unsigned getLoadStoreVecRegBitWidth(
unsigned AddrSpace)
const = 0;
1380 virtual bool isLegalToVectorizeLoad(
LoadInst *LI)
const = 0;
1381 virtual bool isLegalToVectorizeStore(
StoreInst *SI)
const = 0;
1382 virtual bool isLegalToVectorizeLoadChain(
unsigned ChainSizeInBytes,
1384 unsigned AddrSpace)
const = 0;
1385 virtual bool isLegalToVectorizeStoreChain(
unsigned ChainSizeInBytes,
1387 unsigned AddrSpace)
const = 0;
1388 virtual unsigned getLoadVectorFactor(
unsigned VF,
unsigned LoadSize,
1389 unsigned ChainSizeInBytes,
1391 virtual unsigned getStoreVectorFactor(
unsigned VF,
unsigned StoreSize,
1392 unsigned ChainSizeInBytes,
1394 virtual bool useReductionIntrinsic(
unsigned Opcode,
Type *Ty,
1396 virtual bool shouldExpandReduction(
const IntrinsicInst *II)
const = 0;
1397 virtual unsigned getGISelRematGlobalCost()
const = 0;
1398 virtual int getInstructionLatency(
const Instruction *I) = 0;
1401 template <
typename T>
1406 Model(
T Impl) : Impl(std::move(Impl)) {}
1407 ~
Model()
override {}
1409 const DataLayout &getDataLayout()
const override {
1410 return Impl.getDataLayout();
1413 int getOperationCost(
unsigned Opcode,
Type *Ty,
Type *OpTy)
override {
1414 return Impl.getOperationCost(Opcode, Ty, OpTy);
1416 int getGEPCost(
Type *PointeeType,
const Value *Ptr,
1418 return Impl.getGEPCost(PointeeType, Ptr, Operands);
1421 return Impl.getExtCost(I, Src);
1424 return Impl.getCallCost(FTy, NumArgs, U);
1426 int getCallCost(
const Function *
F,
int NumArgs,
const User *U)
override {
1427 return Impl.getCallCost(F, NumArgs, U);
1431 return Impl.getCallCost(F, Arguments, U);
1433 unsigned getInliningThresholdMultiplier()
override {
1434 return Impl.getInliningThresholdMultiplier();
1436 int getInlinerVectorBonusPercent()
override {
1437 return Impl.getInlinerVectorBonusPercent();
1441 return Impl.getIntrinsicCost(IID, RetTy, ParamTys, U);
1445 const User *U =
nullptr)
override {
1446 return Impl.getIntrinsicCost(IID, RetTy, Arguments, U);
1448 int getMemcpyCost(
const Instruction *I)
override {
1449 return Impl.getMemcpyCost(I);
1452 return Impl.getUserCost(U, Operands);
1454 bool hasBranchDivergence()
override {
return Impl.hasBranchDivergence(); }
1455 bool isSourceOfDivergence(
const Value *V)
override {
1456 return Impl.isSourceOfDivergence(V);
1459 bool isAlwaysUniform(
const Value *V)
override {
1460 return Impl.isAlwaysUniform(V);
1463 unsigned getFlatAddressSpace()
override {
1464 return Impl.getFlatAddressSpace();
1469 return Impl.collectFlatAddressOperands(OpIndexes, IID);
1472 bool rewriteIntrinsicWithAddressSpace(
1474 return Impl.rewriteIntrinsicWithAddressSpace(II, OldV, NewV);
1477 bool isLoweredToCall(
const Function *F)
override {
1478 return Impl.isLoweredToCall(F);
1482 return Impl.getUnrollingPreferences(L, SE, UP);
1488 return Impl.isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
1494 return Impl.preferPredicateOverEpilogue(L, LI, SE, AC, TLI, DT, LAI);
1496 bool isLegalAddImmediate(int64_t Imm)
override {
1497 return Impl.isLegalAddImmediate(Imm);
1499 bool isLegalICmpImmediate(int64_t Imm)
override {
1500 return Impl.isLegalICmpImmediate(Imm);
1502 bool isLegalAddressingMode(
Type *Ty,
GlobalValue *BaseGV, int64_t BaseOffset,
1503 bool HasBaseReg, int64_t Scale,
1506 return Impl.isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
1507 Scale, AddrSpace, I);
1511 return Impl.isLSRCostLess(C1, C2);
1513 bool canMacroFuseCmp()
override {
1514 return Impl.canMacroFuseCmp();
1520 return Impl.canSaveCmp(L, BI, SE, LI, DT, AC, LibInfo);
1522 bool shouldFavorPostInc()
const override {
1523 return Impl.shouldFavorPostInc();
1525 bool shouldFavorBackedgeIndex(
const Loop *L)
const override {
1526 return Impl.shouldFavorBackedgeIndex(L);
1529 return Impl.isLegalMaskedStore(DataType, Alignment);
1531 bool isLegalMaskedLoad(
Type *DataType,
MaybeAlign Alignment)
override {
1532 return Impl.isLegalMaskedLoad(DataType, Alignment);
1534 bool isLegalNTStore(
Type *DataType,
Align Alignment)
override {
1535 return Impl.isLegalNTStore(DataType, Alignment);
1537 bool isLegalNTLoad(
Type *DataType,
Align Alignment)
override {
1538 return Impl.isLegalNTLoad(DataType, Alignment);
1540 bool isLegalMaskedScatter(
Type *DataType,
MaybeAlign Alignment)
override {
1541 return Impl.isLegalMaskedScatter(DataType, Alignment);
1543 bool isLegalMaskedGather(
Type *DataType,
MaybeAlign Alignment)
override {
1544 return Impl.isLegalMaskedGather(DataType, Alignment);
1546 bool isLegalMaskedCompressStore(
Type *DataType)
override {
1547 return Impl.isLegalMaskedCompressStore(DataType);
1549 bool isLegalMaskedExpandLoad(
Type *DataType)
override {
1550 return Impl.isLegalMaskedExpandLoad(DataType);
1552 bool hasDivRemOp(
Type *DataType,
bool IsSigned)
override {
1553 return Impl.hasDivRemOp(DataType, IsSigned);
1555 bool hasVolatileVariant(
Instruction *I,
unsigned AddrSpace)
override {
1556 return Impl.hasVolatileVariant(I, AddrSpace);
1558 bool prefersVectorizedAddressing()
override {
1559 return Impl.prefersVectorizedAddressing();
1562 bool HasBaseReg, int64_t Scale,
1563 unsigned AddrSpace)
override {
1564 return Impl.getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
1567 bool LSRWithInstrQueries()
override {
1568 return Impl.LSRWithInstrQueries();
1570 bool isTruncateFree(
Type *Ty1,
Type *Ty2)
override {
1571 return Impl.isTruncateFree(Ty1, Ty2);
1573 bool isProfitableToHoist(
Instruction *I)
override {
1574 return Impl.isProfitableToHoist(I);
1576 bool useAA()
override {
return Impl.useAA(); }
1577 bool isTypeLegal(
Type *Ty)
override {
return Impl.isTypeLegal(Ty); }
1578 bool shouldBuildLookupTables()
override {
1579 return Impl.shouldBuildLookupTables();
1581 bool shouldBuildLookupTablesForConstant(
Constant *
C)
override {
1582 return Impl.shouldBuildLookupTablesForConstant(C);
1584 bool useColdCCForColdCall(
Function &F)
override {
1585 return Impl.useColdCCForColdCall(F);
1588 unsigned getScalarizationOverhead(
Type *Ty,
bool Insert,
1589 bool Extract)
override {
1590 return Impl.getScalarizationOverhead(Ty, Insert, Extract);
1593 unsigned VF)
override {
1594 return Impl.getOperandsScalarizationOverhead(Args, VF);
1597 bool supportsEfficientVectorElementLoadStore()
override {
1598 return Impl.supportsEfficientVectorElementLoadStore();
1601 bool enableAggressiveInterleaving(
bool LoopHasReductions)
override {
1602 return Impl.enableAggressiveInterleaving(LoopHasReductions);
1605 bool IsZeroCmp)
const override {
1606 return Impl.enableMemCmpExpansion(OptSize, IsZeroCmp);
1608 bool enableInterleavedAccessVectorization()
override {
1609 return Impl.enableInterleavedAccessVectorization();
1611 bool enableMaskedInterleavedAccessVectorization()
override {
1612 return Impl.enableMaskedInterleavedAccessVectorization();
1614 bool isFPVectorizationPotentiallyUnsafe()
override {
1615 return Impl.isFPVectorizationPotentiallyUnsafe();
1619 unsigned Alignment,
bool *
Fast)
override {
1620 return Impl.allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
1624 return Impl.getPopcntSupport(IntTyWidthInBit);
1626 bool haveFastSqrt(
Type *Ty)
override {
return Impl.haveFastSqrt(Ty); }
1628 bool isFCmpOrdCheaperThanFCmpZero(
Type *Ty)
override {
1629 return Impl.isFCmpOrdCheaperThanFCmpZero(Ty);
1632 int getFPOpCost(
Type *Ty)
override {
return Impl.getFPOpCost(Ty); }
1634 int getIntImmCodeSizeCost(
unsigned Opc,
unsigned Idx,
const APInt &Imm,
1635 Type *Ty)
override {
1636 return Impl.getIntImmCodeSizeCost(Opc, Idx, Imm, Ty);
1638 int getIntImmCost(
const APInt &Imm,
Type *Ty)
override {
1639 return Impl.getIntImmCost(Imm, Ty);
1641 int getIntImmCostInst(
unsigned Opc,
unsigned Idx,
const APInt &Imm,
1642 Type *Ty)
override {
1643 return Impl.getIntImmCostInst(Opc, Idx, Imm, Ty);
1646 Type *Ty)
override {
1647 return Impl.getIntImmCostIntrin(IID, Idx, Imm, Ty);
1649 unsigned getNumberOfRegisters(
unsigned ClassID)
const override {
1650 return Impl.getNumberOfRegisters(ClassID);
1652 unsigned getRegisterClassForType(
bool Vector,
Type *Ty =
nullptr)
const override {
1653 return Impl.getRegisterClassForType(Vector, Ty);
1655 const char* getRegisterClassName(
unsigned ClassID)
const override {
1656 return Impl.getRegisterClassName(ClassID);
1658 unsigned getRegisterBitWidth(
bool Vector)
const override {
1659 return Impl.getRegisterBitWidth(Vector);
1661 unsigned getMinVectorRegisterBitWidth()
override {
1662 return Impl.getMinVectorRegisterBitWidth();
1664 bool shouldMaximizeVectorBandwidth(
bool OptSize)
const override {
1665 return Impl.shouldMaximizeVectorBandwidth(OptSize);
1667 unsigned getMinimumVF(
unsigned ElemWidth)
const override {
1668 return Impl.getMinimumVF(ElemWidth);
1670 bool shouldConsiderAddressTypePromotion(
1671 const Instruction &I,
bool &AllowPromotionWithoutCommonHeader)
override {
1672 return Impl.shouldConsiderAddressTypePromotion(
1673 I, AllowPromotionWithoutCommonHeader);
1675 unsigned getCacheLineSize()
const override {
1676 return Impl.getCacheLineSize();
1679 return Impl.getCacheSize(Level);
1682 return Impl.getCacheAssociativity(Level);
1687 unsigned getPrefetchDistance()
const override {
1688 return Impl.getPrefetchDistance();
1694 unsigned getMinPrefetchStride()
const override {
1695 return Impl.getMinPrefetchStride();
1701 unsigned getMaxPrefetchIterationsAhead()
const override {
1702 return Impl.getMaxPrefetchIterationsAhead();
1705 unsigned getMaxInterleaveFactor(
unsigned VF)
override {
1706 return Impl.getMaxInterleaveFactor(VF);
1708 unsigned getEstimatedNumberOfCaseClusters(
const SwitchInst &
SI,
1712 return Impl.getEstimatedNumberOfCaseClusters(SI, JTSize, PSI, BFI);
1714 unsigned getArithmeticInstrCost(
unsigned Opcode,
Type *Ty,
1721 return Impl.getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
1722 Opd1PropInfo, Opd2PropInfo, Args, CxtI);
1725 Type *SubTp)
override {
1726 return Impl.getShuffleCost(Kind, Tp, Index, SubTp);
1728 int getCastInstrCost(
unsigned Opcode,
Type *Dst,
Type *Src,
1730 return Impl.getCastInstrCost(Opcode, Dst, Src, I);
1732 int getExtractWithExtendCost(
unsigned Opcode,
Type *Dst,
VectorType *VecTy,
1733 unsigned Index)
override {
1734 return Impl.getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
1736 int getCFInstrCost(
unsigned Opcode)
override {
1737 return Impl.getCFInstrCost(Opcode);
1739 int getCmpSelInstrCost(
unsigned Opcode,
Type *ValTy,
Type *CondTy,
1741 return Impl.getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
1743 int getVectorInstrCost(
unsigned Opcode,
Type *Val,
unsigned Index)
override {
1744 return Impl.getVectorInstrCost(Opcode, Val, Index);
1746 int getMemoryOpCost(
unsigned Opcode,
Type *Src,
MaybeAlign Alignment,
1747 unsigned AddressSpace,
const Instruction *I)
override {
1748 return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
1750 int getMaskedMemoryOpCost(
unsigned Opcode,
Type *Src,
unsigned Alignment,
1751 unsigned AddressSpace)
override {
1752 return Impl.getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
1754 int getGatherScatterOpCost(
unsigned Opcode,
Type *DataTy,
1755 Value *Ptr,
bool VariableMask,
1756 unsigned Alignment)
override {
1757 return Impl.getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
1760 int getInterleavedMemoryOpCost(
unsigned Opcode,
Type *VecTy,
unsigned Factor,
1762 unsigned AddressSpace,
bool UseMaskForCond,
1763 bool UseMaskForGaps)
override {
1764 return Impl.getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
1765 Alignment, AddressSpace,
1766 UseMaskForCond, UseMaskForGaps);
1768 int getArithmeticReductionCost(
unsigned Opcode,
Type *Ty,
1769 bool IsPairwiseForm)
override {
1770 return Impl.getArithmeticReductionCost(Opcode, Ty, IsPairwiseForm);
1772 int getMinMaxReductionCost(
Type *Ty,
Type *CondTy,
1773 bool IsPairwiseForm,
bool IsUnsigned)
override {
1774 return Impl.getMinMaxReductionCost(Ty, CondTy, IsPairwiseForm, IsUnsigned);
1777 FastMathFlags FMF,
unsigned ScalarizationCostPassed)
override {
1778 return Impl.getIntrinsicInstrCost(ID, RetTy, Tys, FMF,
1779 ScalarizationCostPassed);
1783 return Impl.getIntrinsicInstrCost(ID, RetTy, Args, FMF, VF);
1787 return Impl.getCallInstrCost(F, RetTy, Tys);
1789 unsigned getNumberOfParts(
Type *Tp)
override {
1790 return Impl.getNumberOfParts(Tp);
1793 const SCEV *Ptr)
override {
1794 return Impl.getAddressComputationCost(Ty, SE, Ptr);
1797 return Impl.getCostOfKeepingLiveOverCall(Tys);
1801 return Impl.getTgtMemIntrinsic(Inst, Info);
1803 unsigned getAtomicMemIntrinsicMaxElementSize()
const override {
1804 return Impl.getAtomicMemIntrinsicMaxElementSize();
1807 Type *ExpectedType)
override {
1808 return Impl.getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
1812 unsigned DestAlign)
const override {
1813 return Impl.getMemcpyLoopLoweringType(Context, Length, SrcAlign, DestAlign);
1817 unsigned RemainingBytes,
1819 unsigned DestAlign)
const override {
1820 Impl.getMemcpyLoopResidualLoweringType(OpsOut, Context, RemainingBytes,
1821 SrcAlign, DestAlign);
1825 return Impl.areInlineCompatible(Caller, Callee);
1830 return Impl.areFunctionArgsABICompatible(Caller, Callee, Args);
1833 return Impl.isIndexedLoadLegal(Mode, Ty, getDataLayout());
1836 return Impl.isIndexedStoreLegal(Mode, Ty, getDataLayout());
1838 unsigned getLoadStoreVecRegBitWidth(
unsigned AddrSpace)
const override {
1839 return Impl.getLoadStoreVecRegBitWidth(AddrSpace);
1841 bool isLegalToVectorizeLoad(
LoadInst *LI)
const override {
1842 return Impl.isLegalToVectorizeLoad(LI);
1844 bool isLegalToVectorizeStore(
StoreInst *SI)
const override {
1845 return Impl.isLegalToVectorizeStore(SI);
1847 bool isLegalToVectorizeLoadChain(
unsigned ChainSizeInBytes,
1849 unsigned AddrSpace)
const override {
1850 return Impl.isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
1853 bool isLegalToVectorizeStoreChain(
unsigned ChainSizeInBytes,
1855 unsigned AddrSpace)
const override {
1856 return Impl.isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
1859 unsigned getLoadVectorFactor(
unsigned VF,
unsigned LoadSize,
1860 unsigned ChainSizeInBytes,
1862 return Impl.getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
1864 unsigned getStoreVectorFactor(
unsigned VF,
unsigned StoreSize,
1865 unsigned ChainSizeInBytes,
1867 return Impl.getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
1869 bool useReductionIntrinsic(
unsigned Opcode,
Type *Ty,
1871 return Impl.useReductionIntrinsic(Opcode, Ty, Flags);
1873 bool shouldExpandReduction(
const IntrinsicInst *II)
const override {
1874 return Impl.shouldExpandReduction(II);
1877 unsigned getGISelRematGlobalCost()
const override {
1878 return Impl.getGISelRematGlobalCost();
1881 int getInstructionLatency(
const Instruction *I)
override {
1882 return Impl.getInstructionLatency(I);
1886 template <
typename T>
1888 : TTIImpl(new
Model<
T>(Impl)) {}
1919 : TTICallback(Arg.TTICallback) {}
1921 : TTICallback(
std::move(
Arg.TTICallback)) {}
1923 TTICallback = RHS.TTICallback;
1927 TTICallback = std::move(RHS.TTICallback);
1947 std::function<Result(const Function &)> TTICallback;
1950 static Result getDefaultTTI(
const Function &F);
1961 virtual void anchor();
A parsed version of the target data layout string in and methods for querying it. ...
Atomic ordering constants.
This class represents lattice values for constants.
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
TargetIRAnalysis & operator=(const TargetIRAnalysis &RHS)
Analysis providing profile information.
value_op_iterator value_op_begin()
The main scalar evolution driver.
ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
A cache of @llvm.assume calls within a function.
Analysis pass providing the TargetTransformInfo.
value_op_iterator value_op_end()
An instruction for reading from memory.
TargetIRAnalysis & operator=(TargetIRAnalysis &&RHS)
bool areInlineCompatible(const Function &Caller, const Function &Callee)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
mir Rename Register Operands
AtomicOrdering
Atomic ordering for LLVM's memory model.
Class to represent function types.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
An instruction for storing to memory.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Analysis containing CSE Info
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
static cl::opt< bool > ForceNestedLoop("force-nested-hardware-loop", cl::Hidden, cl::init(false), cl::desc("Force allowance of nested hardware loops"))
A CRTP mix-in that provides informational APIs needed for analysis passes.
AMDGPU Lower Kernel Arguments
static cl::opt< unsigned > LoopDecrement("hardware-loop-decrement", cl::Hidden, cl::init(1), cl::desc("Set the loop decrement value"))
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
TargetIRAnalysis(const TargetIRAnalysis &Arg)
Class to represent integer types.
static cl::opt< bool > ForceHardwareLoopPHI("force-hardware-loop-phi", cl::Hidden, cl::init(false), cl::desc("Force hardware loop counter to be updated through a phi"))
Attributes of a target dependent hardware loop.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
ImmutablePass class - This class is used to provide information that does not need to be run...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Provides information about what library functions are available for the current target.
Drive the analysis of memory accesses in the loop.
HardwareLoopInfo(Loop *L)
Class to represent vector types.
Class for arbitrary precision integers.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static unsigned getScalingFactorCost(const TargetTransformInfo &TTI, const LSRUse &LU, const Formula &F, const Loop &L)
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
TargetIRAnalysis(TargetIRAnalysis &&Arg)
API to communicate dependencies between analyses during invalidation.
TargetTransformInfo Result
LLVM Value Representation.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
print Print MemDeps of function
Convenience struct for specifying and reasoning about fast-math flags.
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
Information about a load/store intrinsic defined by the target.
A special type used by analysis passes to provide an address that identifies that particular analysis...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
A wrapper class for inspecting calls to intrinsic functions.