22 #ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
23 #define LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
31 #include "llvm/Support/DataTypes.h"
39 class ScalarEvolution;
211 unsigned &JTSize)
const;
425 bool HasBaseReg, int64_t Scale,
426 unsigned AddrSpace = 0)
const;
453 bool HasBaseReg, int64_t Scale,
454 unsigned AddrSpace = 0)
const;
519 unsigned Alignment = 1,
520 bool *
Fast =
nullptr)
const;
597 const Instruction &
I,
bool &AllowPromotionWithoutCommonHeader)
const;
636 Type *SubTp =
nullptr)
const;
647 unsigned Index = -1)
const;
679 bool VariableMask,
unsigned Alignment)
const;
713 unsigned VF = 1)
const;
720 unsigned ScalarizationCostPassed = UINT_MAX)
const;
737 const SCEV *
Ptr =
nullptr)
const;
761 Type *ExpectedType)
const;
765 unsigned SrcAlign,
unsigned DestAlign)
const;
775 unsigned RemainingBytes,
777 unsigned DestAlign)
const;
803 unsigned AddrSpace)
const;
808 unsigned AddrSpace)
const;
813 unsigned ChainSizeInBytes,
819 unsigned ChainSizeInBytes,
847 template <
typename T>
class Model;
849 std::unique_ptr<Concept> TTIImpl;
870 unsigned &JTSize) = 0;
883 int64_t BaseOffset,
bool HasBaseReg,
885 unsigned AddrSpace) = 0;
894 int64_t BaseOffset,
bool HasBaseReg,
895 int64_t Scale,
unsigned AddrSpace) = 0;
932 const Instruction &I,
bool &AllowPromotionWithoutCommonHeader) = 0;
959 unsigned AddressSpace) = 0;
961 Value *Ptr,
bool VariableMask,
962 unsigned Alignment) = 0;
967 unsigned AddressSpace) = 0;
969 bool IsPairwiseForm) = 0;
972 unsigned ScalarizationCostPassed) = 0;
979 const SCEV *Ptr) = 0;
985 Type *ExpectedType) = 0;
988 unsigned DestAlign)
const = 0;
991 unsigned RemainingBytes,
unsigned SrcAlign,
unsigned DestAlign)
const = 0;
999 unsigned AddrSpace)
const = 0;
1002 unsigned AddrSpace)
const = 0;
1004 unsigned ChainSizeInBytes,
1007 unsigned ChainSizeInBytes,
1014 template <
typename T>
1019 Model(
T Impl) : Impl(std::move(Impl)) {}
1020 ~
Model()
override {}
1022 const DataLayout &getDataLayout()
const override {
1023 return Impl.getDataLayout();
1027 return Impl.getOperationCost(Opcode, Ty, OpTy);
1030 ArrayRef<const Value *> Operands)
override {
1031 return Impl.getGEPCost(PointeeType, Ptr, Operands);
1033 int getExtCost(
const Instruction *
I,
const Value *Src)
override {
1034 return Impl.getExtCost(I, Src);
1036 int getCallCost(FunctionType *FTy,
int NumArgs)
override {
1037 return Impl.getCallCost(FTy, NumArgs);
1039 int getCallCost(
const Function *
F,
int NumArgs)
override {
1040 return Impl.getCallCost(F, NumArgs);
1043 ArrayRef<const Value *> Arguments)
override {
1044 return Impl.getCallCost(F, Arguments);
1047 return Impl.getInliningThresholdMultiplier();
1050 ArrayRef<Type *> ParamTys)
override {
1051 return Impl.getIntrinsicCost(IID, RetTy, ParamTys);
1054 ArrayRef<const Value *> Arguments)
override {
1055 return Impl.getIntrinsicCost(IID, RetTy, Arguments);
1057 int getUserCost(
const User *U, ArrayRef<const Value *> Operands)
override {
1058 return Impl.getUserCost(U, Operands);
1062 return Impl.isSourceOfDivergence(V);
1066 return Impl.isAlwaysUniform(V);
1070 return Impl.getFlatAddressSpace();
1074 return Impl.isLoweredToCall(F);
1077 UnrollingPreferences &UP)
override {
1078 return Impl.getUnrollingPreferences(L, SE, UP);
1081 return Impl.isLegalAddImmediate(Imm);
1084 return Impl.isLegalICmpImmediate(Imm);
1087 bool HasBaseReg, int64_t Scale,
1088 unsigned AddrSpace)
override {
1089 return Impl.isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
1093 TargetTransformInfo::LSRCost &C2)
override {
1094 return Impl.isLSRCostLess(C1, C2);
1097 return Impl.isLegalMaskedStore(DataType);
1100 return Impl.isLegalMaskedLoad(DataType);
1103 return Impl.isLegalMaskedScatter(DataType);
1106 return Impl.isLegalMaskedGather(DataType);
1109 return Impl.prefersVectorizedAddressing();
1112 bool HasBaseReg, int64_t Scale,
1113 unsigned AddrSpace)
override {
1114 return Impl.getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
1118 return Impl.isFoldableMemAccessOffset(I, Offset);
1121 return Impl.isTruncateFree(Ty1, Ty2);
1124 return Impl.isProfitableToHoist(I);
1128 unsigned getJumpBufSize()
override {
return Impl.getJumpBufSize(); }
1130 return Impl.shouldBuildLookupTables();
1133 return Impl.shouldBuildLookupTablesForConstant(C);
1136 bool Extract)
override {
1137 return Impl.getScalarizationOverhead(Ty, Insert, Extract);
1140 unsigned VF)
override {
1141 return Impl.getOperandsScalarizationOverhead(Args, VF);
1145 return Impl.supportsEfficientVectorElementLoadStore();
1149 return Impl.enableAggressiveInterleaving(LoopHasReductions);
1151 bool expandMemCmp(Instruction *I,
unsigned &MaxLoadSize)
override {
1152 return Impl.expandMemCmp(I, MaxLoadSize);
1155 return Impl.enableInterleavedAccessVectorization();
1158 return Impl.isFPVectorizationPotentiallyUnsafe();
1162 unsigned Alignment,
bool *
Fast)
override {
1163 return Impl.allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
1167 return Impl.getPopcntSupport(IntTyWidthInBit);
1174 Type *Ty)
override {
1175 return Impl.getIntImmCodeSizeCost(Opc, Idx, Imm, Ty);
1178 return Impl.getIntImmCost(Imm, Ty);
1180 int getIntImmCost(
unsigned Opc,
unsigned Idx,
const APInt &Imm,
1181 Type *Ty)
override {
1182 return Impl.getIntImmCost(Opc, Idx, Imm, Ty);
1185 Type *Ty)
override {
1186 return Impl.getIntImmCost(IID, Idx, Imm, Ty);
1189 return Impl.getNumberOfRegisters(Vector);
1192 return Impl.getRegisterBitWidth(Vector);
1195 return Impl.getMinVectorRegisterBitWidth();
1198 const Instruction &I,
bool &AllowPromotionWithoutCommonHeader)
override {
1199 return Impl.shouldConsiderAddressTypePromotion(
1200 I, AllowPromotionWithoutCommonHeader);
1203 return Impl.getCacheLineSize();
1207 return Impl.getMinPrefetchStride();
1210 return Impl.getMaxPrefetchIterationsAhead();
1213 return Impl.getMaxInterleaveFactor(VF);
1216 unsigned &JTSize)
override {
1217 return Impl.getEstimatedNumberOfCaseClusters(SI, JTSize);
1224 ArrayRef<const Value *> Args)
override {
1225 return Impl.getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
1226 Opd1PropInfo, Opd2PropInfo, Args);
1229 Type *SubTp)
override {
1230 return Impl.getShuffleCost(Kind, Tp, Index, SubTp);
1233 const Instruction *I)
override {
1234 return Impl.getCastInstrCost(Opcode, Dst, Src, I);
1237 unsigned Index)
override {
1238 return Impl.getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
1241 return Impl.getCFInstrCost(Opcode);
1244 const Instruction *I)
override {
1245 return Impl.getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
1248 return Impl.getVectorInstrCost(Opcode, Val, Index);
1251 unsigned AddressSpace,
const Instruction *I)
override {
1252 return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
1255 unsigned AddressSpace)
override {
1256 return Impl.getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
1259 Value *Ptr,
bool VariableMask,
1260 unsigned Alignment)
override {
1261 return Impl.getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
1265 ArrayRef<unsigned> Indices,
unsigned Alignment,
1266 unsigned AddressSpace)
override {
1267 return Impl.getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
1268 Alignment, AddressSpace);
1271 bool IsPairwiseForm)
override {
1272 return Impl.getReductionCost(Opcode, Ty, IsPairwiseForm);
1275 FastMathFlags FMF,
unsigned ScalarizationCostPassed)
override {
1276 return Impl.getIntrinsicInstrCost(ID, RetTy, Tys, FMF,
1277 ScalarizationCostPassed);
1280 ArrayRef<Value *> Args, FastMathFlags FMF,
unsigned VF)
override {
1281 return Impl.getIntrinsicInstrCost(ID, RetTy, Args, FMF, VF);
1284 ArrayRef<Type *> Tys)
override {
1285 return Impl.getCallInstrCost(F, RetTy, Tys);
1288 return Impl.getNumberOfParts(Tp);
1291 const SCEV *Ptr)
override {
1292 return Impl.getAddressComputationCost(Ty, SE, Ptr);
1295 return Impl.getCostOfKeepingLiveOverCall(Tys);
1298 MemIntrinsicInfo &Info)
override {
1299 return Impl.getTgtMemIntrinsic(Inst, Info);
1302 return Impl.getAtomicMemIntrinsicMaxElementSize();
1305 Type *ExpectedType)
override {
1306 return Impl.getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
1310 unsigned DestAlign)
const override {
1311 return Impl.getMemcpyLoopLoweringType(Context, Length, SrcAlign, DestAlign);
1314 LLVMContext &Context,
1315 unsigned RemainingBytes,
1317 unsigned DestAlign)
const override {
1318 Impl.getMemcpyLoopResidualLoweringType(OpsOut, Context, RemainingBytes,
1319 SrcAlign, DestAlign);
1322 const Function *Callee)
const override {
1323 return Impl.areInlineCompatible(Caller, Callee);
1326 return Impl.getLoadStoreVecRegBitWidth(AddrSpace);
1329 return Impl.isLegalToVectorizeLoad(LI);
1332 return Impl.isLegalToVectorizeStore(SI);
1336 unsigned AddrSpace)
const override {
1337 return Impl.isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
1342 unsigned AddrSpace)
const override {
1343 return Impl.isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
1347 unsigned ChainSizeInBytes,
1348 VectorType *VecTy)
const override {
1349 return Impl.getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
1352 unsigned ChainSizeInBytes,
1353 VectorType *VecTy)
const override {
1354 return Impl.getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
1357 ReductionFlags
Flags)
const override {
1358 return Impl.useReductionIntrinsic(Opcode, Ty, Flags);
1361 return Impl.shouldExpandReduction(II);
1365 template <
typename T>
1367 : TTIImpl(new
Model<
T>(Impl)) {}
1398 : TTICallback(Arg.TTICallback) {}
1400 : TTICallback(std::move(Arg.TTICallback)) {}
1402 TTICallback = RHS.TTICallback;
1406 TTICallback = std::move(RHS.TTICallback);
1426 std::function<Result(const Function &)> TTICallback;
1440 virtual void anchor();
A parsed version of the target data layout string in and methods for querying it. ...
TargetIRAnalysis & operator=(const TargetIRAnalysis &RHS)
value_op_iterator value_op_begin()
The main scalar evolution driver.
ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
Analysis pass providing the TargetTransformInfo.
value_op_iterator value_op_end()
An instruction for reading from memory.
TargetIRAnalysis & operator=(TargetIRAnalysis &&RHS)
unsigned short MatchingId
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
Function Alias Analysis false
A set of analyses that are preserved following a run of a transformation pass.
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.
This is an important base class in LLVM.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
A CRTP mix-in that provides informational APIs needed for analysis passes.
TargetIRAnalysis()
Default construct a target IR analysis.
TargetIRAnalysis(const TargetIRAnalysis &Arg)
ImmutablePass class - This class is used to provide information that does not need to be run...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Class to represent vector types.
Class for arbitrary precision integers.
Result run(const Function &F, FunctionAnalysisManager &)
static std::vector< std::string > Flags
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
TargetIRAnalysis(TargetIRAnalysis &&Arg)
Fast - This calling convention attempts to make calls as fast as possible (e.g.
API to communicate dependencies between analyses during invalidation.
TargetTransformInfo Result
LLVM Value Representation.
print Print MemDeps of function
Value * PtrVal
This is the pointer that the intrinsic is loading from or storing to.
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...
A wrapper class for inspecting calls to intrinsic functions.