LLVM  5.0.0
TargetTransformInfo.cpp
Go to the documentation of this file.
1 //===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
12 #include "llvm/IR/CallSite.h"
13 #include "llvm/IR/DataLayout.h"
14 #include "llvm/IR/Instruction.h"
15 #include "llvm/IR/Instructions.h"
16 #include "llvm/IR/IntrinsicInst.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/IR/Operator.h"
21 #include <utility>
22 
23 using namespace llvm;
24 
25 #define DEBUG_TYPE "tti"
26 
28  "use-wide-memcpy-loop-lowering", cl::init(false),
29  cl::desc("Enables the new wide memcpy loop lowering in Transforms/Utils."),
30  cl::Hidden);
31 
32 namespace {
33 /// \brief No-op implementation of the TTI interface using the utility base
34 /// classes.
35 ///
36 /// This is used when no target specific information is available.
37 struct NoTTIImpl : TargetTransformInfoImplCRTPBase<NoTTIImpl> {
38  explicit NoTTIImpl(const DataLayout &DL)
39  : TargetTransformInfoImplCRTPBase<NoTTIImpl>(DL) {}
40 };
41 }
42 
44  : TTIImpl(new Model<NoTTIImpl>(NoTTIImpl(DL))) {}
45 
47 
49  : TTIImpl(std::move(Arg.TTIImpl)) {}
50 
52  TTIImpl = std::move(RHS.TTIImpl);
53  return *this;
54 }
55 
57  Type *OpTy) const {
58  int Cost = TTIImpl->getOperationCost(Opcode, Ty, OpTy);
59  assert(Cost >= 0 && "TTI should not produce negative costs!");
60  return Cost;
61 }
62 
63 int TargetTransformInfo::getCallCost(FunctionType *FTy, int NumArgs) const {
64  int Cost = TTIImpl->getCallCost(FTy, NumArgs);
65  assert(Cost >= 0 && "TTI should not produce negative costs!");
66  return Cost;
67 }
68 
70  ArrayRef<const Value *> Arguments) const {
71  int Cost = TTIImpl->getCallCost(F, Arguments);
72  assert(Cost >= 0 && "TTI should not produce negative costs!");
73  return Cost;
74 }
75 
77  return TTIImpl->getInliningThresholdMultiplier();
78 }
79 
80 int TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr,
81  ArrayRef<const Value *> Operands) const {
82  return TTIImpl->getGEPCost(PointeeType, Ptr, Operands);
83 }
84 
86  const Value *Src) const {
87  return TTIImpl->getExtCost(I, Src);
88 }
89 
91  Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments) const {
92  int Cost = TTIImpl->getIntrinsicCost(IID, RetTy, Arguments);
93  assert(Cost >= 0 && "TTI should not produce negative costs!");
94  return Cost;
95 }
96 
97 unsigned
99  unsigned &JTSize) const {
100  return TTIImpl->getEstimatedNumberOfCaseClusters(SI, JTSize);
101 }
102 
104  ArrayRef<const Value *> Operands) const {
105  int Cost = TTIImpl->getUserCost(U, Operands);
106  assert(Cost >= 0 && "TTI should not produce negative costs!");
107  return Cost;
108 }
109 
111  return TTIImpl->hasBranchDivergence();
112 }
113 
115  return TTIImpl->isSourceOfDivergence(V);
116 }
117 
119  return TTIImpl->isAlwaysUniform(V);
120 }
121 
123  return TTIImpl->getFlatAddressSpace();
124 }
125 
127  return TTIImpl->isLoweredToCall(F);
128 }
129 
131  Loop *L, ScalarEvolution &SE, UnrollingPreferences &UP) const {
132  return TTIImpl->getUnrollingPreferences(L, SE, UP);
133 }
134 
136  return TTIImpl->isLegalAddImmediate(Imm);
137 }
138 
140  return TTIImpl->isLegalICmpImmediate(Imm);
141 }
142 
144  int64_t BaseOffset,
145  bool HasBaseReg,
146  int64_t Scale,
147  unsigned AddrSpace) const {
148  return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
149  Scale, AddrSpace);
150 }
151 
153  return TTIImpl->isLSRCostLess(C1, C2);
154 }
155 
157  return TTIImpl->isLegalMaskedStore(DataType);
158 }
159 
161  return TTIImpl->isLegalMaskedLoad(DataType);
162 }
163 
165  return TTIImpl->isLegalMaskedGather(DataType);
166 }
167 
169  return TTIImpl->isLegalMaskedGather(DataType);
170 }
171 
173  return TTIImpl->prefersVectorizedAddressing();
174 }
175 
177  int64_t BaseOffset,
178  bool HasBaseReg,
179  int64_t Scale,
180  unsigned AddrSpace) const {
181  int Cost = TTIImpl->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
182  Scale, AddrSpace);
183  assert(Cost >= 0 && "TTI should not produce negative costs!");
184  return Cost;
185 }
186 
188  int64_t Offset) const {
189  return TTIImpl->isFoldableMemAccessOffset(I, Offset);
190 }
191 
193  return TTIImpl->isTruncateFree(Ty1, Ty2);
194 }
195 
197  return TTIImpl->isProfitableToHoist(I);
198 }
199 
201  return TTIImpl->isTypeLegal(Ty);
202 }
203 
205  return TTIImpl->getJumpBufAlignment();
206 }
207 
209  return TTIImpl->getJumpBufSize();
210 }
211 
213  return TTIImpl->shouldBuildLookupTables();
214 }
216  return TTIImpl->shouldBuildLookupTablesForConstant(C);
217 }
218 
219 unsigned TargetTransformInfo::
220 getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const {
221  return TTIImpl->getScalarizationOverhead(Ty, Insert, Extract);
222 }
223 
224 unsigned TargetTransformInfo::
226  unsigned VF) const {
227  return TTIImpl->getOperandsScalarizationOverhead(Args, VF);
228 }
229 
231  return TTIImpl->supportsEfficientVectorElementLoadStore();
232 }
233 
234 bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
235  return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
236 }
237 
238 bool TargetTransformInfo::expandMemCmp(Instruction *I, unsigned &MaxLoadSize) const {
239  return TTIImpl->expandMemCmp(I, MaxLoadSize);
240 }
241 
243  return TTIImpl->enableInterleavedAccessVectorization();
244 }
245 
247  return TTIImpl->isFPVectorizationPotentiallyUnsafe();
248 }
249 
251  unsigned BitWidth,
252  unsigned AddressSpace,
253  unsigned Alignment,
254  bool *Fast) const {
255  return TTIImpl->allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
256  Alignment, Fast);
257 }
258 
260 TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
261  return TTIImpl->getPopcntSupport(IntTyWidthInBit);
262 }
263 
265  return TTIImpl->haveFastSqrt(Ty);
266 }
267 
269  int Cost = TTIImpl->getFPOpCost(Ty);
270  assert(Cost >= 0 && "TTI should not produce negative costs!");
271  return Cost;
272 }
273 
274 int TargetTransformInfo::getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
275  const APInt &Imm,
276  Type *Ty) const {
277  int Cost = TTIImpl->getIntImmCodeSizeCost(Opcode, Idx, Imm, Ty);
278  assert(Cost >= 0 && "TTI should not produce negative costs!");
279  return Cost;
280 }
281 
282 int TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
283  int Cost = TTIImpl->getIntImmCost(Imm, Ty);
284  assert(Cost >= 0 && "TTI should not produce negative costs!");
285  return Cost;
286 }
287 
288 int TargetTransformInfo::getIntImmCost(unsigned Opcode, unsigned Idx,
289  const APInt &Imm, Type *Ty) const {
290  int Cost = TTIImpl->getIntImmCost(Opcode, Idx, Imm, Ty);
291  assert(Cost >= 0 && "TTI should not produce negative costs!");
292  return Cost;
293 }
294 
296  const APInt &Imm, Type *Ty) const {
297  int Cost = TTIImpl->getIntImmCost(IID, Idx, Imm, Ty);
298  assert(Cost >= 0 && "TTI should not produce negative costs!");
299  return Cost;
300 }
301 
302 unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
303  return TTIImpl->getNumberOfRegisters(Vector);
304 }
305 
306 unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
307  return TTIImpl->getRegisterBitWidth(Vector);
308 }
309 
311  return TTIImpl->getMinVectorRegisterBitWidth();
312 }
313 
315  const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const {
316  return TTIImpl->shouldConsiderAddressTypePromotion(
317  I, AllowPromotionWithoutCommonHeader);
318 }
319 
321  return TTIImpl->getCacheLineSize();
322 }
323 
325  return TTIImpl->getPrefetchDistance();
326 }
327 
329  return TTIImpl->getMinPrefetchStride();
330 }
331 
333  return TTIImpl->getMaxPrefetchIterationsAhead();
334 }
335 
336 unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
337  return TTIImpl->getMaxInterleaveFactor(VF);
338 }
339 
341  unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
342  OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
343  OperandValueProperties Opd2PropInfo,
345  int Cost = TTIImpl->getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
346  Opd1PropInfo, Opd2PropInfo, Args);
347  assert(Cost >= 0 && "TTI should not produce negative costs!");
348  return Cost;
349 }
350 
352  Type *SubTp) const {
353  int Cost = TTIImpl->getShuffleCost(Kind, Ty, Index, SubTp);
354  assert(Cost >= 0 && "TTI should not produce negative costs!");
355  return Cost;
356 }
357 
358 int TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
359  Type *Src, const Instruction *I) const {
360  assert ((I == nullptr || I->getOpcode() == Opcode) &&
361  "Opcode should reflect passed instruction.");
362  int Cost = TTIImpl->getCastInstrCost(Opcode, Dst, Src, I);
363  assert(Cost >= 0 && "TTI should not produce negative costs!");
364  return Cost;
365 }
366 
368  VectorType *VecTy,
369  unsigned Index) const {
370  int Cost = TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
371  assert(Cost >= 0 && "TTI should not produce negative costs!");
372  return Cost;
373 }
374 
375 int TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
376  int Cost = TTIImpl->getCFInstrCost(Opcode);
377  assert(Cost >= 0 && "TTI should not produce negative costs!");
378  return Cost;
379 }
380 
381 int TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
382  Type *CondTy, const Instruction *I) const {
383  assert ((I == nullptr || I->getOpcode() == Opcode) &&
384  "Opcode should reflect passed instruction.");
385  int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
386  assert(Cost >= 0 && "TTI should not produce negative costs!");
387  return Cost;
388 }
389 
391  unsigned Index) const {
392  int Cost = TTIImpl->getVectorInstrCost(Opcode, Val, Index);
393  assert(Cost >= 0 && "TTI should not produce negative costs!");
394  return Cost;
395 }
396 
397 int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
398  unsigned Alignment,
399  unsigned AddressSpace,
400  const Instruction *I) const {
401  assert ((I == nullptr || I->getOpcode() == Opcode) &&
402  "Opcode should reflect passed instruction.");
403  int Cost = TTIImpl->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
404  assert(Cost >= 0 && "TTI should not produce negative costs!");
405  return Cost;
406 }
407 
409  unsigned Alignment,
410  unsigned AddressSpace) const {
411  int Cost =
412  TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
413  assert(Cost >= 0 && "TTI should not produce negative costs!");
414  return Cost;
415 }
416 
418  Value *Ptr, bool VariableMask,
419  unsigned Alignment) const {
420  int Cost = TTIImpl->getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
421  Alignment);
422  assert(Cost >= 0 && "TTI should not produce negative costs!");
423  return Cost;
424 }
425 
427  unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
428  unsigned Alignment, unsigned AddressSpace) const {
429  int Cost = TTIImpl->getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
430  Alignment, AddressSpace);
431  assert(Cost >= 0 && "TTI should not produce negative costs!");
432  return Cost;
433 }
434 
437  unsigned ScalarizationCostPassed) const {
438  int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys, FMF,
439  ScalarizationCostPassed);
440  assert(Cost >= 0 && "TTI should not produce negative costs!");
441  return Cost;
442 }
443 
445  ArrayRef<Value *> Args, FastMathFlags FMF, unsigned VF) const {
446  int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Args, FMF, VF);
447  assert(Cost >= 0 && "TTI should not produce negative costs!");
448  return Cost;
449 }
450 
452  ArrayRef<Type *> Tys) const {
453  int Cost = TTIImpl->getCallInstrCost(F, RetTy, Tys);
454  assert(Cost >= 0 && "TTI should not produce negative costs!");
455  return Cost;
456 }
457 
459  return TTIImpl->getNumberOfParts(Tp);
460 }
461 
463  ScalarEvolution *SE,
464  const SCEV *Ptr) const {
465  int Cost = TTIImpl->getAddressComputationCost(Tp, SE, Ptr);
466  assert(Cost >= 0 && "TTI should not produce negative costs!");
467  return Cost;
468 }
469 
471  bool IsPairwiseForm) const {
472  int Cost = TTIImpl->getReductionCost(Opcode, Ty, IsPairwiseForm);
473  assert(Cost >= 0 && "TTI should not produce negative costs!");
474  return Cost;
475 }
476 
477 unsigned
479  return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
480 }
481 
483  MemIntrinsicInfo &Info) const {
484  return TTIImpl->getTgtMemIntrinsic(Inst, Info);
485 }
486 
488  return TTIImpl->getAtomicMemIntrinsicMaxElementSize();
489 }
490 
492  IntrinsicInst *Inst, Type *ExpectedType) const {
493  return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
494 }
495 
497  Value *Length,
498  unsigned SrcAlign,
499  unsigned DestAlign) const {
500  return TTIImpl->getMemcpyLoopLoweringType(Context, Length, SrcAlign,
501  DestAlign);
502 }
503 
506  unsigned RemainingBytes, unsigned SrcAlign, unsigned DestAlign) const {
507  TTIImpl->getMemcpyLoopResidualLoweringType(OpsOut, Context, RemainingBytes,
508  SrcAlign, DestAlign);
509 }
510 
513 }
514 
516  const Function *Callee) const {
517  return TTIImpl->areInlineCompatible(Caller, Callee);
518 }
519 
521  return TTIImpl->getLoadStoreVecRegBitWidth(AS);
522 }
523 
525  return TTIImpl->isLegalToVectorizeLoad(LI);
526 }
527 
529  return TTIImpl->isLegalToVectorizeStore(SI);
530 }
531 
533  unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
534  return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
535  AddrSpace);
536 }
537 
539  unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
540  return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
541  AddrSpace);
542 }
543 
545  unsigned LoadSize,
546  unsigned ChainSizeInBytes,
547  VectorType *VecTy) const {
548  return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
549 }
550 
552  unsigned StoreSize,
553  unsigned ChainSizeInBytes,
554  VectorType *VecTy) const {
555  return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
556 }
557 
559  Type *Ty, ReductionFlags Flags) const {
560  return TTIImpl->useReductionIntrinsic(Opcode, Ty, Flags);
561 }
562 
564  return TTIImpl->shouldExpandReduction(II);
565 }
566 
568 
569 TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
570 
572  std::function<Result(const Function &)> TTICallback)
573  : TTICallback(std::move(TTICallback)) {}
574 
577  return TTICallback(F);
578 }
579 
580 AnalysisKey TargetIRAnalysis::Key;
581 
582 TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
583  return Result(F.getParent()->getDataLayout());
584 }
585 
586 // Register the basic pass.
588  "Target Transform Information", false, true)
590 
591 void TargetTransformInfoWrapperPass::anchor() {}
592 
594  : ImmutablePass(ID) {
597 }
598 
600  TargetIRAnalysis TIRA)
601  : ImmutablePass(ID), TIRA(std::move(TIRA)) {
604 }
605 
607  FunctionAnalysisManager DummyFAM;
608  TTI = TIRA.run(F, DummyFAM);
609  return *TTI;
610 }
611 
614  return new TargetTransformInfoWrapperPass(std::move(TIRA));
615 }
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy=nullptr, const Instruction *I=nullptr) const
MachineLoop * L
bool shouldBuildLookupTablesForConstant(Constant *C) const
Return true if switches should be turned into lookup tables containing this constant value for the ta...
bool enableInterleavedAccessVectorization() const
Enable matching of interleaved access groups.
PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const
Return hardware support for population count.
int getExtCost(const Instruction *I, const Value *Src) const
Estimate the cost of a EXT operation when lowered.
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
bool isFPVectorizationPotentiallyUnsafe() const
Indicate that it is potentially unsafe to automatically vectorize floating-point operations because t...
int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr, bool VariableMask, unsigned Alignment) const
bool isLegalMaskedStore(Type *DataType) const
Return true if the target supports masked load/store AVX2 and AVX-512 targets allow masks for consecu...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVMContext & Context
TargetTransformInfo & operator=(TargetTransformInfo &&RHS)
bool isSourceOfDivergence(const Value *V) const
Returns whether V is a source of divergence.
bool isLegalToVectorizeLoad(LoadInst *LI) const
bool isAlwaysUniform(const Value *V) const
unsigned getStoreVectorFactor(unsigned VF, unsigned StoreSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const
unsigned getAtomicMemIntrinsicMaxElementSize() const
bool isLegalToVectorizeStore(StoreInst *SI) const
bool hasBranchDivergence() const
Return true if branch divergence exists.
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace) const
The main scalar evolution driver.
DataLayout DL
TargetTransformInfoWrapperPass()
We must provide a default constructor for the pass but it should never be used.
unsigned getJumpBufSize() const
Returns the target's jmp_buf size in bytes.
ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
unsigned getMaxInterleaveFactor(unsigned VF) const
bool allowsMisalignedMemoryAccesses(LLVMContext &Context, unsigned BitWidth, unsigned AddressSpace=0, unsigned Alignment=1, bool *Fast=nullptr) const
Determine if the target supports unaligned memory accesses.
Analysis pass providing the TargetTransformInfo.
bool shouldExpandReduction(const IntrinsicInst *II) const
int getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands) const
Estimate the cost of a GEP operation when lowered.
unsigned getNumberOfParts(Type *Tp) const
An instruction for reading from memory.
Definition: Instructions.h:164
int getIntImmCodeSizeCost(unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty) const
Return the expected cost for the given integer when optimising for size.
bool isLegalAddImmediate(int64_t Imm) const
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
unsigned getMaxPrefetchIterationsAhead() const
This file provides helpers for the implementation of a TargetTransformInfo-conforming class...
CRTP base class for use as a mix-in that aids implementing a TargetTransformInfo-compatible class...
bool prefersVectorizedAddressing() const
Return true if target doesn't mind addresses in vectors.
bool isLegalMaskedGather(Type *DataType) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
bool supportsEfficientVectorElementLoadStore() const
If target has efficient vector element load/store instructions, it can return true here so that inser...
bool isLSRCostLess(TargetTransformInfo::LSRCost &C1, TargetTransformInfo::LSRCost &C2) const
Return true if LSR cost of C1 is lower than C1.
unsigned getInliningThresholdMultiplier() const
bool isLegalMaskedScatter(Type *DataType) const
Return true if the target supports masked gather/scatter AVX-512 fully supports gather and scatter fo...
Class to represent function types.
Definition: DerivedTypes.h:103
#define F(x, y, z)
Definition: MD5.cpp:55
unsigned getLoadVectorFactor(unsigned VF, unsigned LoadSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
bool isTypeLegal(Type *Ty) const
Return true if this type is legal.
PopcntSupportKind
Flags indicating the kind of support for population count.
unsigned getRegisterBitWidth(bool Vector) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
An instruction for storing to memory.
Definition: Instructions.h:306
void initializeTargetTransformInfoWrapperPassPass(PassRegistry &)
int getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, ArrayRef< Type * > ParamTys) const
Estimate the cost of an intrinsic when lowered.
bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace=0) const
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:401
int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, ArrayRef< Value * > Args, FastMathFlags FMF, unsigned VF=1) const
Wrapper pass for TargetTransformInfo.
Flags describing the kind of vector reduction.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
This is an important base class in LLVM.
Definition: Constant.h:42
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
int getCallInstrCost(Function *F, Type *RetTy, ArrayRef< Type * > Tys) const
TargetIRAnalysis()
Default construct a target IR analysis.
bool useReductionIntrinsic(unsigned Opcode, Type *Ty, ReductionFlags Flags) const
int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm) const
Calculate the cost of performing a vector reduction.
Type * getMemcpyLoopLoweringType(LLVMContext &Context, Value *Length, unsigned SrcAlign, unsigned DestAlign) const
bool enableAggressiveInterleaving(bool LoopHasReductions) const
Don't restrict interleaved unrolling to small loops.
int getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy=nullptr) const
Estimate the cost of a specific operation when lowered.
int getFPOpCost(Type *Ty) const
Return the expected cost of supporting the floating point operation of the specified type...
int getShuffleCost(ShuffleKind Kind, Type *Tp, int Index=0, Type *SubTp=nullptr) const
bool isFoldableMemAccessOffset(Instruction *I, int64_t Offset) const
Return true if target supports the load / store instruction with the given Offset on the form reg + O...
int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace=0) const
Return the cost of the scaling factor used in the addressing mode represented by AM for this target...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:34
OperandValueProperties
Additional properties of an operand's values.
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType) const
ImmutablePass class - This class is used to provide information that does not need to be run...
Definition: Pass.h:266
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI, unsigned &JTSize) const
unsigned getMinPrefetchStride() const
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
void getMemcpyLoopResidualLoweringType(SmallVectorImpl< Type * > &OpsOut, LLVMContext &Context, unsigned RemainingBytes, unsigned SrcAlign, unsigned DestAlign) const
Module.h This file contains the declarations for the Module class.
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, const Instruction *I=nullptr) const
AddressSpace
Definition: NVPTXBaseInfo.h:22
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr) const
static cl::opt< bool > UseWideMemcpyLoopLowering("use-wide-memcpy-loop-lowering", cl::init(false), cl::desc("Enables the new wide memcpy loop lowering in Transforms/Utils."), cl::Hidden)
bool haveFastSqrt(Type *Ty) const
Return true if the hardware has a fast square-root instruction.
Class to represent vector types.
Definition: DerivedTypes.h:393
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const
Class for arbitrary precision integers.
Definition: APInt.h:69
int getIntImmCost(const APInt &Imm, Type *Ty) const
Return the expected cost of materializing for the given integer immediate of the specified type...
unsigned getJumpBufAlignment() const
Returns the target's jmp_buf alignment in bytes.
TargetTransformInfo(T Impl)
Construct a TTI object using a type implementing the Concept API below.
Result run(const Function &F, FunctionAnalysisManager &)
bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const
static std::vector< std::string > Flags
Definition: FlagsTest.cpp:8
bool isLegalICmpImmediate(int64_t Imm) const
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:361
bool shouldBuildLookupTables() const
Return true if switches should be turned into lookup tables for the target.
bool isLegalMaskedLoad(Type *DataType) const
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:360
int getCallCost(FunctionType *FTy, int NumArgs=-1) const
Estimate the cost of a function call when lowered.
#define C
Definition: LargeTest.cpp:25
unsigned getPrefetchDistance() const
Parameters that control the generic loop unrolling transformation.
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace) const
unsigned getMinVectorRegisterBitWidth() const
#define I(x, y, z)
Definition: MD5.cpp:58
bool expandMemCmp(Instruction *I, unsigned &MaxLoadSize) const
Enable inline expansion of memcmp.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:43
bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const
unsigned getOperandsScalarizationOverhead(ArrayRef< const Value * > Args, unsigned VF) const
int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index=-1) const
const unsigned Kind
Multiway switch.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isLoweredToCall(const Function *F) const
Test whether calls to a function lower to actual program function calls.
TargetTransformInfo Result
unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:545
LLVM Value Representation.
Definition: Value.h:73
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:121
bool isTruncateFree(Type *Ty1, Type *Ty2) const
Return true if it's free to truncate a value of type Ty1 to type Ty2.
unsigned getNumberOfRegisters(bool Vector) const
print Print MemDeps of function
int getCFInstrCost(unsigned Opcode) const
Convenience struct for specifying and reasoning about fast-math flags.
Definition: Operator.h:160
OperandValueKind
Additional information about an operand's possible values.
A container for analyses that lazily runs them and caches their results.
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index=-1) const
unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const
This pass exposes codegen information to IR-level passes.
TargetTransformInfo & getTTI(const Function &F)
int * Ptr
int getUserCost(const User *U, ArrayRef< const Value * > Operands) const
Estimate the cost of a given IR user when lowered.
unsigned getFlatAddressSpace() const
Returns the address space ID for a target's 'flat' address space.
unsigned getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys) const
Information about a load/store intrinsic defined by the target.
int getAddressComputationCost(Type *Ty, ScalarEvolution *SE=nullptr, const SCEV *Ptr=nullptr) const
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:70
bool isProfitableToHoist(Instruction *I) const
Return true if it is profitable to hoist instruction in the then/else to before if.
int getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind Opd1Info=OK_AnyValue, OperandValueKind Opd2Info=OK_AnyValue, OperandValueProperties Opd1PropInfo=OP_None, OperandValueProperties Opd2PropInfo=OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >()) const
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:44
ShuffleKind
The various kinds of shuffle patterns for vector queries.
void getUnrollingPreferences(Loop *L, ScalarEvolution &, UnrollingPreferences &UP) const
Get target-customized preferences for the generic loop unrolling transformation.