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