]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Analysis/TargetTransformInfo.cpp
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304149, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Analysis / TargetTransformInfo.cpp
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
10 #include "llvm/Analysis/TargetTransformInfo.h"
11 #include "llvm/Analysis/TargetTransformInfoImpl.h"
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"
19 #include "llvm/Support/ErrorHandling.h"
20 #include <utility>
21
22 using namespace llvm;
23
24 #define DEBUG_TYPE "tti"
25
26 namespace {
27 /// \brief No-op implementation of the TTI interface using the utility base
28 /// classes.
29 ///
30 /// This is used when no target specific information is available.
31 struct NoTTIImpl : TargetTransformInfoImplCRTPBase<NoTTIImpl> {
32   explicit NoTTIImpl(const DataLayout &DL)
33       : TargetTransformInfoImplCRTPBase<NoTTIImpl>(DL) {}
34 };
35 }
36
37 TargetTransformInfo::TargetTransformInfo(const DataLayout &DL)
38     : TTIImpl(new Model<NoTTIImpl>(NoTTIImpl(DL))) {}
39
40 TargetTransformInfo::~TargetTransformInfo() {}
41
42 TargetTransformInfo::TargetTransformInfo(TargetTransformInfo &&Arg)
43     : TTIImpl(std::move(Arg.TTIImpl)) {}
44
45 TargetTransformInfo &TargetTransformInfo::operator=(TargetTransformInfo &&RHS) {
46   TTIImpl = std::move(RHS.TTIImpl);
47   return *this;
48 }
49
50 int TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
51                                           Type *OpTy) const {
52   int Cost = TTIImpl->getOperationCost(Opcode, Ty, OpTy);
53   assert(Cost >= 0 && "TTI should not produce negative costs!");
54   return Cost;
55 }
56
57 int TargetTransformInfo::getCallCost(FunctionType *FTy, int NumArgs) const {
58   int Cost = TTIImpl->getCallCost(FTy, NumArgs);
59   assert(Cost >= 0 && "TTI should not produce negative costs!");
60   return Cost;
61 }
62
63 int TargetTransformInfo::getCallCost(const Function *F,
64                                      ArrayRef<const Value *> Arguments) const {
65   int Cost = TTIImpl->getCallCost(F, Arguments);
66   assert(Cost >= 0 && "TTI should not produce negative costs!");
67   return Cost;
68 }
69
70 unsigned TargetTransformInfo::getInliningThresholdMultiplier() const {
71   return TTIImpl->getInliningThresholdMultiplier();
72 }
73
74 int TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr,
75                                     ArrayRef<const Value *> Operands) const {
76   return TTIImpl->getGEPCost(PointeeType, Ptr, Operands);
77 }
78
79 int TargetTransformInfo::getIntrinsicCost(
80     Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments) const {
81   int Cost = TTIImpl->getIntrinsicCost(IID, RetTy, Arguments);
82   assert(Cost >= 0 && "TTI should not produce negative costs!");
83   return Cost;
84 }
85
86 unsigned
87 TargetTransformInfo::getEstimatedNumberOfCaseClusters(const SwitchInst &SI,
88                                                       unsigned &JTSize) const {
89   return TTIImpl->getEstimatedNumberOfCaseClusters(SI, JTSize);
90 }
91
92 int TargetTransformInfo::getUserCost(const User *U) const {
93   int Cost = TTIImpl->getUserCost(U);
94   assert(Cost >= 0 && "TTI should not produce negative costs!");
95   return Cost;
96 }
97
98 bool TargetTransformInfo::hasBranchDivergence() const {
99   return TTIImpl->hasBranchDivergence();
100 }
101
102 bool TargetTransformInfo::isSourceOfDivergence(const Value *V) const {
103   return TTIImpl->isSourceOfDivergence(V);
104 }
105
106 unsigned TargetTransformInfo::getFlatAddressSpace() const {
107   return TTIImpl->getFlatAddressSpace();
108 }
109
110 bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
111   return TTIImpl->isLoweredToCall(F);
112 }
113
114 void TargetTransformInfo::getUnrollingPreferences(
115     Loop *L, UnrollingPreferences &UP) const {
116   return TTIImpl->getUnrollingPreferences(L, UP);
117 }
118
119 bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
120   return TTIImpl->isLegalAddImmediate(Imm);
121 }
122
123 bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const {
124   return TTIImpl->isLegalICmpImmediate(Imm);
125 }
126
127 bool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
128                                                 int64_t BaseOffset,
129                                                 bool HasBaseReg,
130                                                 int64_t Scale,
131                                                 unsigned AddrSpace) const {
132   return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
133                                         Scale, AddrSpace);
134 }
135
136 bool TargetTransformInfo::isLegalMaskedStore(Type *DataType) const {
137   return TTIImpl->isLegalMaskedStore(DataType);
138 }
139
140 bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType) const {
141   return TTIImpl->isLegalMaskedLoad(DataType);
142 }
143
144 bool TargetTransformInfo::isLegalMaskedGather(Type *DataType) const {
145   return TTIImpl->isLegalMaskedGather(DataType);
146 }
147
148 bool TargetTransformInfo::isLegalMaskedScatter(Type *DataType) const {
149   return TTIImpl->isLegalMaskedGather(DataType);
150 }
151
152 bool TargetTransformInfo::prefersVectorizedAddressing() const {
153   return TTIImpl->prefersVectorizedAddressing();
154 }
155
156 int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
157                                               int64_t BaseOffset,
158                                               bool HasBaseReg,
159                                               int64_t Scale,
160                                               unsigned AddrSpace) const {
161   int Cost = TTIImpl->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
162                                            Scale, AddrSpace);
163   assert(Cost >= 0 && "TTI should not produce negative costs!");
164   return Cost;
165 }
166
167 bool TargetTransformInfo::isFoldableMemAccessOffset(Instruction *I,
168                                                     int64_t Offset) const {
169   return TTIImpl->isFoldableMemAccessOffset(I, Offset);
170 }
171
172 bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
173   return TTIImpl->isTruncateFree(Ty1, Ty2);
174 }
175
176 bool TargetTransformInfo::isProfitableToHoist(Instruction *I) const {
177   return TTIImpl->isProfitableToHoist(I);
178 }
179
180 bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
181   return TTIImpl->isTypeLegal(Ty);
182 }
183
184 unsigned TargetTransformInfo::getJumpBufAlignment() const {
185   return TTIImpl->getJumpBufAlignment();
186 }
187
188 unsigned TargetTransformInfo::getJumpBufSize() const {
189   return TTIImpl->getJumpBufSize();
190 }
191
192 bool TargetTransformInfo::shouldBuildLookupTables() const {
193   return TTIImpl->shouldBuildLookupTables();
194 }
195 bool TargetTransformInfo::shouldBuildLookupTablesForConstant(Constant *C) const {
196   return TTIImpl->shouldBuildLookupTablesForConstant(C);
197 }
198
199 unsigned TargetTransformInfo::
200 getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const {
201   return TTIImpl->getScalarizationOverhead(Ty, Insert, Extract);
202 }
203
204 unsigned TargetTransformInfo::
205 getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
206                                  unsigned VF) const {
207   return TTIImpl->getOperandsScalarizationOverhead(Args, VF);
208 }
209
210 bool TargetTransformInfo::supportsEfficientVectorElementLoadStore() const {
211   return TTIImpl->supportsEfficientVectorElementLoadStore();
212 }
213
214 bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
215   return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
216 }
217
218 bool TargetTransformInfo::enableInterleavedAccessVectorization() const {
219   return TTIImpl->enableInterleavedAccessVectorization();
220 }
221
222 bool TargetTransformInfo::isFPVectorizationPotentiallyUnsafe() const {
223   return TTIImpl->isFPVectorizationPotentiallyUnsafe();
224 }
225
226 bool TargetTransformInfo::allowsMisalignedMemoryAccesses(LLVMContext &Context,
227                                                          unsigned BitWidth,
228                                                          unsigned AddressSpace,
229                                                          unsigned Alignment,
230                                                          bool *Fast) const {
231   return TTIImpl->allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
232                                                  Alignment, Fast);
233 }
234
235 TargetTransformInfo::PopcntSupportKind
236 TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
237   return TTIImpl->getPopcntSupport(IntTyWidthInBit);
238 }
239
240 bool TargetTransformInfo::haveFastSqrt(Type *Ty) const {
241   return TTIImpl->haveFastSqrt(Ty);
242 }
243
244 int TargetTransformInfo::getFPOpCost(Type *Ty) const {
245   int Cost = TTIImpl->getFPOpCost(Ty);
246   assert(Cost >= 0 && "TTI should not produce negative costs!");
247   return Cost;
248 }
249
250 int TargetTransformInfo::getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
251                                                const APInt &Imm,
252                                                Type *Ty) const {
253   int Cost = TTIImpl->getIntImmCodeSizeCost(Opcode, Idx, Imm, Ty);
254   assert(Cost >= 0 && "TTI should not produce negative costs!");
255   return Cost;
256 }
257
258 int TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
259   int Cost = TTIImpl->getIntImmCost(Imm, Ty);
260   assert(Cost >= 0 && "TTI should not produce negative costs!");
261   return Cost;
262 }
263
264 int TargetTransformInfo::getIntImmCost(unsigned Opcode, unsigned Idx,
265                                        const APInt &Imm, Type *Ty) const {
266   int Cost = TTIImpl->getIntImmCost(Opcode, Idx, Imm, Ty);
267   assert(Cost >= 0 && "TTI should not produce negative costs!");
268   return Cost;
269 }
270
271 int TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
272                                        const APInt &Imm, Type *Ty) const {
273   int Cost = TTIImpl->getIntImmCost(IID, Idx, Imm, Ty);
274   assert(Cost >= 0 && "TTI should not produce negative costs!");
275   return Cost;
276 }
277
278 unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
279   return TTIImpl->getNumberOfRegisters(Vector);
280 }
281
282 unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
283   return TTIImpl->getRegisterBitWidth(Vector);
284 }
285
286 unsigned TargetTransformInfo::getMinVectorRegisterBitWidth() const {
287   return TTIImpl->getMinVectorRegisterBitWidth();
288 }
289
290 bool TargetTransformInfo::shouldConsiderAddressTypePromotion(
291     const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const {
292   return TTIImpl->shouldConsiderAddressTypePromotion(
293       I, AllowPromotionWithoutCommonHeader);
294 }
295
296 unsigned TargetTransformInfo::getCacheLineSize() const {
297   return TTIImpl->getCacheLineSize();
298 }
299
300 unsigned TargetTransformInfo::getPrefetchDistance() const {
301   return TTIImpl->getPrefetchDistance();
302 }
303
304 unsigned TargetTransformInfo::getMinPrefetchStride() const {
305   return TTIImpl->getMinPrefetchStride();
306 }
307
308 unsigned TargetTransformInfo::getMaxPrefetchIterationsAhead() const {
309   return TTIImpl->getMaxPrefetchIterationsAhead();
310 }
311
312 unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
313   return TTIImpl->getMaxInterleaveFactor(VF);
314 }
315
316 int TargetTransformInfo::getArithmeticInstrCost(
317     unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
318     OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
319     OperandValueProperties Opd2PropInfo,
320     ArrayRef<const Value *> Args) const {
321   int Cost = TTIImpl->getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
322                                              Opd1PropInfo, Opd2PropInfo, Args);
323   assert(Cost >= 0 && "TTI should not produce negative costs!");
324   return Cost;
325 }
326
327 int TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Ty, int Index,
328                                         Type *SubTp) const {
329   int Cost = TTIImpl->getShuffleCost(Kind, Ty, Index, SubTp);
330   assert(Cost >= 0 && "TTI should not produce negative costs!");
331   return Cost;
332 }
333
334 int TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
335                                  Type *Src, const Instruction *I) const {
336   assert ((I == nullptr || I->getOpcode() == Opcode) &&
337           "Opcode should reflect passed instruction.");
338   int Cost = TTIImpl->getCastInstrCost(Opcode, Dst, Src, I);
339   assert(Cost >= 0 && "TTI should not produce negative costs!");
340   return Cost;
341 }
342
343 int TargetTransformInfo::getExtractWithExtendCost(unsigned Opcode, Type *Dst,
344                                                   VectorType *VecTy,
345                                                   unsigned Index) const {
346   int Cost = TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
347   assert(Cost >= 0 && "TTI should not produce negative costs!");
348   return Cost;
349 }
350
351 int TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
352   int Cost = TTIImpl->getCFInstrCost(Opcode);
353   assert(Cost >= 0 && "TTI should not produce negative costs!");
354   return Cost;
355 }
356
357 int TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
358                                  Type *CondTy, const Instruction *I) const {
359   assert ((I == nullptr || I->getOpcode() == Opcode) &&
360           "Opcode should reflect passed instruction.");
361   int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
362   assert(Cost >= 0 && "TTI should not produce negative costs!");
363   return Cost;
364 }
365
366 int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
367                                             unsigned Index) const {
368   int Cost = TTIImpl->getVectorInstrCost(Opcode, Val, Index);
369   assert(Cost >= 0 && "TTI should not produce negative costs!");
370   return Cost;
371 }
372
373 int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
374                                          unsigned Alignment,
375                                          unsigned AddressSpace,
376                                          const Instruction *I) const {
377   assert ((I == nullptr || I->getOpcode() == Opcode) &&
378           "Opcode should reflect passed instruction.");
379   int Cost = TTIImpl->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
380   assert(Cost >= 0 && "TTI should not produce negative costs!");
381   return Cost;
382 }
383
384 int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
385                                                unsigned Alignment,
386                                                unsigned AddressSpace) const {
387   int Cost =
388       TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
389   assert(Cost >= 0 && "TTI should not produce negative costs!");
390   return Cost;
391 }
392
393 int TargetTransformInfo::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
394                                                 Value *Ptr, bool VariableMask,
395                                                 unsigned Alignment) const {
396   int Cost = TTIImpl->getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
397                                              Alignment);
398   assert(Cost >= 0 && "TTI should not produce negative costs!");
399   return Cost;
400 }
401
402 int TargetTransformInfo::getInterleavedMemoryOpCost(
403     unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
404     unsigned Alignment, unsigned AddressSpace) const {
405   int Cost = TTIImpl->getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
406                                                  Alignment, AddressSpace);
407   assert(Cost >= 0 && "TTI should not produce negative costs!");
408   return Cost;
409 }
410
411 int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
412                                     ArrayRef<Type *> Tys, FastMathFlags FMF,
413                                     unsigned ScalarizationCostPassed) const {
414   int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys, FMF,
415                                             ScalarizationCostPassed);
416   assert(Cost >= 0 && "TTI should not produce negative costs!");
417   return Cost;
418 }
419
420 int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
421            ArrayRef<Value *> Args, FastMathFlags FMF, unsigned VF) const {
422   int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Args, FMF, VF);
423   assert(Cost >= 0 && "TTI should not produce negative costs!");
424   return Cost;
425 }
426
427 int TargetTransformInfo::getCallInstrCost(Function *F, Type *RetTy,
428                                           ArrayRef<Type *> Tys) const {
429   int Cost = TTIImpl->getCallInstrCost(F, RetTy, Tys);
430   assert(Cost >= 0 && "TTI should not produce negative costs!");
431   return Cost;
432 }
433
434 unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
435   return TTIImpl->getNumberOfParts(Tp);
436 }
437
438 int TargetTransformInfo::getAddressComputationCost(Type *Tp,
439                                                    ScalarEvolution *SE,
440                                                    const SCEV *Ptr) const {
441   int Cost = TTIImpl->getAddressComputationCost(Tp, SE, Ptr);
442   assert(Cost >= 0 && "TTI should not produce negative costs!");
443   return Cost;
444 }
445
446 int TargetTransformInfo::getReductionCost(unsigned Opcode, Type *Ty,
447                                           bool IsPairwiseForm) const {
448   int Cost = TTIImpl->getReductionCost(Opcode, Ty, IsPairwiseForm);
449   assert(Cost >= 0 && "TTI should not produce negative costs!");
450   return Cost;
451 }
452
453 unsigned
454 TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const {
455   return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
456 }
457
458 bool TargetTransformInfo::getTgtMemIntrinsic(IntrinsicInst *Inst,
459                                              MemIntrinsicInfo &Info) const {
460   return TTIImpl->getTgtMemIntrinsic(Inst, Info);
461 }
462
463 Value *TargetTransformInfo::getOrCreateResultFromMemIntrinsic(
464     IntrinsicInst *Inst, Type *ExpectedType) const {
465   return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
466 }
467
468 bool TargetTransformInfo::areInlineCompatible(const Function *Caller,
469                                               const Function *Callee) const {
470   return TTIImpl->areInlineCompatible(Caller, Callee);
471 }
472
473 unsigned TargetTransformInfo::getLoadStoreVecRegBitWidth(unsigned AS) const {
474   return TTIImpl->getLoadStoreVecRegBitWidth(AS);
475 }
476
477 bool TargetTransformInfo::isLegalToVectorizeLoad(LoadInst *LI) const {
478   return TTIImpl->isLegalToVectorizeLoad(LI);
479 }
480
481 bool TargetTransformInfo::isLegalToVectorizeStore(StoreInst *SI) const {
482   return TTIImpl->isLegalToVectorizeStore(SI);
483 }
484
485 bool TargetTransformInfo::isLegalToVectorizeLoadChain(
486     unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
487   return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
488                                               AddrSpace);
489 }
490
491 bool TargetTransformInfo::isLegalToVectorizeStoreChain(
492     unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
493   return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
494                                                AddrSpace);
495 }
496
497 unsigned TargetTransformInfo::getLoadVectorFactor(unsigned VF,
498                                                   unsigned LoadSize,
499                                                   unsigned ChainSizeInBytes,
500                                                   VectorType *VecTy) const {
501   return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
502 }
503
504 unsigned TargetTransformInfo::getStoreVectorFactor(unsigned VF,
505                                                    unsigned StoreSize,
506                                                    unsigned ChainSizeInBytes,
507                                                    VectorType *VecTy) const {
508   return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
509 }
510
511 bool TargetTransformInfo::useReductionIntrinsic(unsigned Opcode,
512                                                 Type *Ty, ReductionFlags Flags) const {
513   return TTIImpl->useReductionIntrinsic(Opcode, Ty, Flags);
514 }
515
516 bool TargetTransformInfo::shouldExpandReduction(const IntrinsicInst *II) const {
517   return TTIImpl->shouldExpandReduction(II);
518 }
519
520 TargetTransformInfo::Concept::~Concept() {}
521
522 TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
523
524 TargetIRAnalysis::TargetIRAnalysis(
525     std::function<Result(const Function &)> TTICallback)
526     : TTICallback(std::move(TTICallback)) {}
527
528 TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F,
529                                                FunctionAnalysisManager &) {
530   return TTICallback(F);
531 }
532
533 AnalysisKey TargetIRAnalysis::Key;
534
535 TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
536   return Result(F.getParent()->getDataLayout());
537 }
538
539 // Register the basic pass.
540 INITIALIZE_PASS(TargetTransformInfoWrapperPass, "tti",
541                 "Target Transform Information", false, true)
542 char TargetTransformInfoWrapperPass::ID = 0;
543
544 void TargetTransformInfoWrapperPass::anchor() {}
545
546 TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
547     : ImmutablePass(ID) {
548   initializeTargetTransformInfoWrapperPassPass(
549       *PassRegistry::getPassRegistry());
550 }
551
552 TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
553     TargetIRAnalysis TIRA)
554     : ImmutablePass(ID), TIRA(std::move(TIRA)) {
555   initializeTargetTransformInfoWrapperPassPass(
556       *PassRegistry::getPassRegistry());
557 }
558
559 TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
560   FunctionAnalysisManager DummyFAM;
561   TTI = TIRA.run(F, DummyFAM);
562   return *TTI;
563 }
564
565 ImmutablePass *
566 llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
567   return new TargetTransformInfoWrapperPass(std::move(TIRA));
568 }