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