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