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