]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Analysis/TargetTransformInfo.cpp
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r303571, 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 int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
153                                               int64_t BaseOffset,
154                                               bool HasBaseReg,
155                                               int64_t Scale,
156                                               unsigned AddrSpace) const {
157   int Cost = TTIImpl->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
158                                            Scale, AddrSpace);
159   assert(Cost >= 0 && "TTI should not produce negative costs!");
160   return Cost;
161 }
162
163 bool TargetTransformInfo::isFoldableMemAccessOffset(Instruction *I,
164                                                     int64_t Offset) const {
165   return TTIImpl->isFoldableMemAccessOffset(I, Offset);
166 }
167
168 bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
169   return TTIImpl->isTruncateFree(Ty1, Ty2);
170 }
171
172 bool TargetTransformInfo::isProfitableToHoist(Instruction *I) const {
173   return TTIImpl->isProfitableToHoist(I);
174 }
175
176 bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
177   return TTIImpl->isTypeLegal(Ty);
178 }
179
180 unsigned TargetTransformInfo::getJumpBufAlignment() const {
181   return TTIImpl->getJumpBufAlignment();
182 }
183
184 unsigned TargetTransformInfo::getJumpBufSize() const {
185   return TTIImpl->getJumpBufSize();
186 }
187
188 bool TargetTransformInfo::shouldBuildLookupTables() const {
189   return TTIImpl->shouldBuildLookupTables();
190 }
191 bool TargetTransformInfo::shouldBuildLookupTablesForConstant(Constant *C) const {
192   return TTIImpl->shouldBuildLookupTablesForConstant(C);
193 }
194
195 unsigned TargetTransformInfo::
196 getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const {
197   return TTIImpl->getScalarizationOverhead(Ty, Insert, Extract);
198 }
199
200 unsigned TargetTransformInfo::
201 getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
202                                  unsigned VF) const {
203   return TTIImpl->getOperandsScalarizationOverhead(Args, VF);
204 }
205
206 bool TargetTransformInfo::supportsEfficientVectorElementLoadStore() const {
207   return TTIImpl->supportsEfficientVectorElementLoadStore();
208 }
209
210 bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
211   return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
212 }
213
214 bool TargetTransformInfo::enableInterleavedAccessVectorization() const {
215   return TTIImpl->enableInterleavedAccessVectorization();
216 }
217
218 bool TargetTransformInfo::isFPVectorizationPotentiallyUnsafe() const {
219   return TTIImpl->isFPVectorizationPotentiallyUnsafe();
220 }
221
222 bool TargetTransformInfo::allowsMisalignedMemoryAccesses(LLVMContext &Context,
223                                                          unsigned BitWidth,
224                                                          unsigned AddressSpace,
225                                                          unsigned Alignment,
226                                                          bool *Fast) const {
227   return TTIImpl->allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
228                                                  Alignment, Fast);
229 }
230
231 TargetTransformInfo::PopcntSupportKind
232 TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
233   return TTIImpl->getPopcntSupport(IntTyWidthInBit);
234 }
235
236 bool TargetTransformInfo::haveFastSqrt(Type *Ty) const {
237   return TTIImpl->haveFastSqrt(Ty);
238 }
239
240 int TargetTransformInfo::getFPOpCost(Type *Ty) const {
241   int Cost = TTIImpl->getFPOpCost(Ty);
242   assert(Cost >= 0 && "TTI should not produce negative costs!");
243   return Cost;
244 }
245
246 int TargetTransformInfo::getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
247                                                const APInt &Imm,
248                                                Type *Ty) const {
249   int Cost = TTIImpl->getIntImmCodeSizeCost(Opcode, Idx, Imm, Ty);
250   assert(Cost >= 0 && "TTI should not produce negative costs!");
251   return Cost;
252 }
253
254 int TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
255   int Cost = TTIImpl->getIntImmCost(Imm, Ty);
256   assert(Cost >= 0 && "TTI should not produce negative costs!");
257   return Cost;
258 }
259
260 int TargetTransformInfo::getIntImmCost(unsigned Opcode, unsigned Idx,
261                                        const APInt &Imm, Type *Ty) const {
262   int Cost = TTIImpl->getIntImmCost(Opcode, Idx, Imm, Ty);
263   assert(Cost >= 0 && "TTI should not produce negative costs!");
264   return Cost;
265 }
266
267 int TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
268                                        const APInt &Imm, Type *Ty) const {
269   int Cost = TTIImpl->getIntImmCost(IID, Idx, Imm, Ty);
270   assert(Cost >= 0 && "TTI should not produce negative costs!");
271   return Cost;
272 }
273
274 unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
275   return TTIImpl->getNumberOfRegisters(Vector);
276 }
277
278 unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
279   return TTIImpl->getRegisterBitWidth(Vector);
280 }
281
282 unsigned TargetTransformInfo::getMinVectorRegisterBitWidth() const {
283   return TTIImpl->getMinVectorRegisterBitWidth();
284 }
285
286 bool TargetTransformInfo::shouldConsiderAddressTypePromotion(
287     const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const {
288   return TTIImpl->shouldConsiderAddressTypePromotion(
289       I, AllowPromotionWithoutCommonHeader);
290 }
291
292 unsigned TargetTransformInfo::getCacheLineSize() const {
293   return TTIImpl->getCacheLineSize();
294 }
295
296 unsigned TargetTransformInfo::getPrefetchDistance() const {
297   return TTIImpl->getPrefetchDistance();
298 }
299
300 unsigned TargetTransformInfo::getMinPrefetchStride() const {
301   return TTIImpl->getMinPrefetchStride();
302 }
303
304 unsigned TargetTransformInfo::getMaxPrefetchIterationsAhead() const {
305   return TTIImpl->getMaxPrefetchIterationsAhead();
306 }
307
308 unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
309   return TTIImpl->getMaxInterleaveFactor(VF);
310 }
311
312 int TargetTransformInfo::getArithmeticInstrCost(
313     unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
314     OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
315     OperandValueProperties Opd2PropInfo,
316     ArrayRef<const Value *> Args) const {
317   int Cost = TTIImpl->getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
318                                              Opd1PropInfo, Opd2PropInfo, Args);
319   assert(Cost >= 0 && "TTI should not produce negative costs!");
320   return Cost;
321 }
322
323 int TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Ty, int Index,
324                                         Type *SubTp) const {
325   int Cost = TTIImpl->getShuffleCost(Kind, Ty, Index, SubTp);
326   assert(Cost >= 0 && "TTI should not produce negative costs!");
327   return Cost;
328 }
329
330 int TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
331                                  Type *Src, const Instruction *I) const {
332   assert ((I == nullptr || I->getOpcode() == Opcode) &&
333           "Opcode should reflect passed instruction.");
334   int Cost = TTIImpl->getCastInstrCost(Opcode, Dst, Src, I);
335   assert(Cost >= 0 && "TTI should not produce negative costs!");
336   return Cost;
337 }
338
339 int TargetTransformInfo::getExtractWithExtendCost(unsigned Opcode, Type *Dst,
340                                                   VectorType *VecTy,
341                                                   unsigned Index) const {
342   int Cost = TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
343   assert(Cost >= 0 && "TTI should not produce negative costs!");
344   return Cost;
345 }
346
347 int TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
348   int Cost = TTIImpl->getCFInstrCost(Opcode);
349   assert(Cost >= 0 && "TTI should not produce negative costs!");
350   return Cost;
351 }
352
353 int TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
354                                  Type *CondTy, const Instruction *I) const {
355   assert ((I == nullptr || I->getOpcode() == Opcode) &&
356           "Opcode should reflect passed instruction.");
357   int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
358   assert(Cost >= 0 && "TTI should not produce negative costs!");
359   return Cost;
360 }
361
362 int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
363                                             unsigned Index) const {
364   int Cost = TTIImpl->getVectorInstrCost(Opcode, Val, Index);
365   assert(Cost >= 0 && "TTI should not produce negative costs!");
366   return Cost;
367 }
368
369 int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
370                                          unsigned Alignment,
371                                          unsigned AddressSpace,
372                                          const Instruction *I) const {
373   assert ((I == nullptr || I->getOpcode() == Opcode) &&
374           "Opcode should reflect passed instruction.");
375   int Cost = TTIImpl->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
376   assert(Cost >= 0 && "TTI should not produce negative costs!");
377   return Cost;
378 }
379
380 int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
381                                                unsigned Alignment,
382                                                unsigned AddressSpace) const {
383   int Cost =
384       TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
385   assert(Cost >= 0 && "TTI should not produce negative costs!");
386   return Cost;
387 }
388
389 int TargetTransformInfo::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
390                                                 Value *Ptr, bool VariableMask,
391                                                 unsigned Alignment) const {
392   int Cost = TTIImpl->getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
393                                              Alignment);
394   assert(Cost >= 0 && "TTI should not produce negative costs!");
395   return Cost;
396 }
397
398 int TargetTransformInfo::getInterleavedMemoryOpCost(
399     unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
400     unsigned Alignment, unsigned AddressSpace) const {
401   int Cost = TTIImpl->getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
402                                                  Alignment, AddressSpace);
403   assert(Cost >= 0 && "TTI should not produce negative costs!");
404   return Cost;
405 }
406
407 int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
408                                     ArrayRef<Type *> Tys, FastMathFlags FMF,
409                                     unsigned ScalarizationCostPassed) const {
410   int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys, FMF,
411                                             ScalarizationCostPassed);
412   assert(Cost >= 0 && "TTI should not produce negative costs!");
413   return Cost;
414 }
415
416 int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
417            ArrayRef<Value *> Args, FastMathFlags FMF, unsigned VF) const {
418   int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Args, FMF, VF);
419   assert(Cost >= 0 && "TTI should not produce negative costs!");
420   return Cost;
421 }
422
423 int TargetTransformInfo::getCallInstrCost(Function *F, Type *RetTy,
424                                           ArrayRef<Type *> Tys) const {
425   int Cost = TTIImpl->getCallInstrCost(F, RetTy, Tys);
426   assert(Cost >= 0 && "TTI should not produce negative costs!");
427   return Cost;
428 }
429
430 unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
431   return TTIImpl->getNumberOfParts(Tp);
432 }
433
434 int TargetTransformInfo::getAddressComputationCost(Type *Tp,
435                                                    ScalarEvolution *SE,
436                                                    const SCEV *Ptr) const {
437   int Cost = TTIImpl->getAddressComputationCost(Tp, SE, Ptr);
438   assert(Cost >= 0 && "TTI should not produce negative costs!");
439   return Cost;
440 }
441
442 int TargetTransformInfo::getReductionCost(unsigned Opcode, Type *Ty,
443                                           bool IsPairwiseForm) const {
444   int Cost = TTIImpl->getReductionCost(Opcode, Ty, IsPairwiseForm);
445   assert(Cost >= 0 && "TTI should not produce negative costs!");
446   return Cost;
447 }
448
449 unsigned
450 TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const {
451   return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
452 }
453
454 bool TargetTransformInfo::getTgtMemIntrinsic(IntrinsicInst *Inst,
455                                              MemIntrinsicInfo &Info) const {
456   return TTIImpl->getTgtMemIntrinsic(Inst, Info);
457 }
458
459 Value *TargetTransformInfo::getOrCreateResultFromMemIntrinsic(
460     IntrinsicInst *Inst, Type *ExpectedType) const {
461   return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
462 }
463
464 bool TargetTransformInfo::areInlineCompatible(const Function *Caller,
465                                               const Function *Callee) const {
466   return TTIImpl->areInlineCompatible(Caller, Callee);
467 }
468
469 unsigned TargetTransformInfo::getLoadStoreVecRegBitWidth(unsigned AS) const {
470   return TTIImpl->getLoadStoreVecRegBitWidth(AS);
471 }
472
473 bool TargetTransformInfo::isLegalToVectorizeLoad(LoadInst *LI) const {
474   return TTIImpl->isLegalToVectorizeLoad(LI);
475 }
476
477 bool TargetTransformInfo::isLegalToVectorizeStore(StoreInst *SI) const {
478   return TTIImpl->isLegalToVectorizeStore(SI);
479 }
480
481 bool TargetTransformInfo::isLegalToVectorizeLoadChain(
482     unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
483   return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
484                                               AddrSpace);
485 }
486
487 bool TargetTransformInfo::isLegalToVectorizeStoreChain(
488     unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
489   return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
490                                                AddrSpace);
491 }
492
493 unsigned TargetTransformInfo::getLoadVectorFactor(unsigned VF,
494                                                   unsigned LoadSize,
495                                                   unsigned ChainSizeInBytes,
496                                                   VectorType *VecTy) const {
497   return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
498 }
499
500 unsigned TargetTransformInfo::getStoreVectorFactor(unsigned VF,
501                                                    unsigned StoreSize,
502                                                    unsigned ChainSizeInBytes,
503                                                    VectorType *VecTy) const {
504   return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
505 }
506
507 bool TargetTransformInfo::useReductionIntrinsic(unsigned Opcode,
508                                                 Type *Ty, ReductionFlags Flags) const {
509   return TTIImpl->useReductionIntrinsic(Opcode, Ty, Flags);
510 }
511
512 bool TargetTransformInfo::shouldExpandReduction(const IntrinsicInst *II) const {
513   return TTIImpl->shouldExpandReduction(II);
514 }
515
516 TargetTransformInfo::Concept::~Concept() {}
517
518 TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
519
520 TargetIRAnalysis::TargetIRAnalysis(
521     std::function<Result(const Function &)> TTICallback)
522     : TTICallback(std::move(TTICallback)) {}
523
524 TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F,
525                                                FunctionAnalysisManager &) {
526   return TTICallback(F);
527 }
528
529 AnalysisKey TargetIRAnalysis::Key;
530
531 TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
532   return Result(F.getParent()->getDataLayout());
533 }
534
535 // Register the basic pass.
536 INITIALIZE_PASS(TargetTransformInfoWrapperPass, "tti",
537                 "Target Transform Information", false, true)
538 char TargetTransformInfoWrapperPass::ID = 0;
539
540 void TargetTransformInfoWrapperPass::anchor() {}
541
542 TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
543     : ImmutablePass(ID) {
544   initializeTargetTransformInfoWrapperPassPass(
545       *PassRegistry::getPassRegistry());
546 }
547
548 TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
549     TargetIRAnalysis TIRA)
550     : ImmutablePass(ID), TIRA(std::move(TIRA)) {
551   initializeTargetTransformInfoWrapperPassPass(
552       *PassRegistry::getPassRegistry());
553 }
554
555 TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
556   FunctionAnalysisManager DummyFAM;
557   TTI = TIRA.run(F, DummyFAM);
558   return *TTI;
559 }
560
561 ImmutablePass *
562 llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
563   return new TargetTransformInfoWrapperPass(std::move(TIRA));
564 }