LLVM API Documentation

TargetTransformInfo.cpp
Go to the documentation of this file.
00001 //===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "llvm/Analysis/TargetTransformInfo.h"
00011 #include "llvm/IR/CallSite.h"
00012 #include "llvm/IR/DataLayout.h"
00013 #include "llvm/IR/Instruction.h"
00014 #include "llvm/IR/Instructions.h"
00015 #include "llvm/IR/IntrinsicInst.h"
00016 #include "llvm/IR/Operator.h"
00017 #include "llvm/Support/ErrorHandling.h"
00018 
00019 using namespace llvm;
00020 
00021 #define DEBUG_TYPE "tti"
00022 
00023 // Setup the analysis group to manage the TargetTransformInfo passes.
00024 INITIALIZE_ANALYSIS_GROUP(TargetTransformInfo, "Target Information", NoTTI)
00025 char TargetTransformInfo::ID = 0;
00026 
00027 TargetTransformInfo::~TargetTransformInfo() {
00028 }
00029 
00030 void TargetTransformInfo::pushTTIStack(Pass *P) {
00031   TopTTI = this;
00032   PrevTTI = &P->getAnalysis<TargetTransformInfo>();
00033 
00034   // Walk up the chain and update the top TTI pointer.
00035   for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI)
00036     PTTI->TopTTI = this;
00037 }
00038 
00039 void TargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const {
00040   AU.addRequired<TargetTransformInfo>();
00041 }
00042 
00043 unsigned TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
00044                                                Type *OpTy) const {
00045   return PrevTTI->getOperationCost(Opcode, Ty, OpTy);
00046 }
00047 
00048 unsigned TargetTransformInfo::getGEPCost(
00049     const Value *Ptr, ArrayRef<const Value *> Operands) const {
00050   return PrevTTI->getGEPCost(Ptr, Operands);
00051 }
00052 
00053 unsigned TargetTransformInfo::getCallCost(FunctionType *FTy,
00054                                           int NumArgs) const {
00055   return PrevTTI->getCallCost(FTy, NumArgs);
00056 }
00057 
00058 unsigned TargetTransformInfo::getCallCost(const Function *F,
00059                                           int NumArgs) const {
00060   return PrevTTI->getCallCost(F, NumArgs);
00061 }
00062 
00063 unsigned TargetTransformInfo::getCallCost(
00064     const Function *F, ArrayRef<const Value *> Arguments) const {
00065   return PrevTTI->getCallCost(F, Arguments);
00066 }
00067 
00068 unsigned TargetTransformInfo::getIntrinsicCost(
00069     Intrinsic::ID IID, Type *RetTy, ArrayRef<Type *> ParamTys) const {
00070   return PrevTTI->getIntrinsicCost(IID, RetTy, ParamTys);
00071 }
00072 
00073 unsigned TargetTransformInfo::getIntrinsicCost(
00074     Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments) const {
00075   return PrevTTI->getIntrinsicCost(IID, RetTy, Arguments);
00076 }
00077 
00078 unsigned TargetTransformInfo::getUserCost(const User *U) const {
00079   return PrevTTI->getUserCost(U);
00080 }
00081 
00082 bool TargetTransformInfo::hasBranchDivergence() const {
00083   return PrevTTI->hasBranchDivergence();
00084 }
00085 
00086 bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
00087   return PrevTTI->isLoweredToCall(F);
00088 }
00089 
00090 void
00091 TargetTransformInfo::getUnrollingPreferences(const Function *F, Loop *L,
00092                                              UnrollingPreferences &UP) const {
00093   PrevTTI->getUnrollingPreferences(F, L, UP);
00094 }
00095 
00096 bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
00097   return PrevTTI->isLegalAddImmediate(Imm);
00098 }
00099 
00100 bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const {
00101   return PrevTTI->isLegalICmpImmediate(Imm);
00102 }
00103 
00104 bool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
00105                                                 int64_t BaseOffset,
00106                                                 bool HasBaseReg,
00107                                                 int64_t Scale) const {
00108   return PrevTTI->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
00109                                         Scale);
00110 }
00111 
00112 int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
00113                                               int64_t BaseOffset,
00114                                               bool HasBaseReg,
00115                                               int64_t Scale) const {
00116   return PrevTTI->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
00117                                        Scale);
00118 }
00119 
00120 bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
00121   return PrevTTI->isTruncateFree(Ty1, Ty2);
00122 }
00123 
00124 bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
00125   return PrevTTI->isTypeLegal(Ty);
00126 }
00127 
00128 unsigned TargetTransformInfo::getJumpBufAlignment() const {
00129   return PrevTTI->getJumpBufAlignment();
00130 }
00131 
00132 unsigned TargetTransformInfo::getJumpBufSize() const {
00133   return PrevTTI->getJumpBufSize();
00134 }
00135 
00136 bool TargetTransformInfo::shouldBuildLookupTables() const {
00137   return PrevTTI->shouldBuildLookupTables();
00138 }
00139 
00140 TargetTransformInfo::PopcntSupportKind
00141 TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
00142   return PrevTTI->getPopcntSupport(IntTyWidthInBit);
00143 }
00144 
00145 bool TargetTransformInfo::haveFastSqrt(Type *Ty) const {
00146   return PrevTTI->haveFastSqrt(Ty);
00147 }
00148 
00149 unsigned TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
00150   return PrevTTI->getIntImmCost(Imm, Ty);
00151 }
00152 
00153 unsigned TargetTransformInfo::getIntImmCost(unsigned Opc, unsigned Idx,
00154                                             const APInt &Imm, Type *Ty) const {
00155   return PrevTTI->getIntImmCost(Opc, Idx, Imm, Ty);
00156 }
00157 
00158 unsigned TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
00159                                             const APInt &Imm, Type *Ty) const {
00160   return PrevTTI->getIntImmCost(IID, Idx, Imm, Ty);
00161 }
00162 
00163 unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
00164   return PrevTTI->getNumberOfRegisters(Vector);
00165 }
00166 
00167 unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
00168   return PrevTTI->getRegisterBitWidth(Vector);
00169 }
00170 
00171 unsigned TargetTransformInfo::getMaxInterleaveFactor() const {
00172   return PrevTTI->getMaxInterleaveFactor();
00173 }
00174 
00175 unsigned TargetTransformInfo::getArithmeticInstrCost(
00176     unsigned Opcode, Type *Ty, OperandValueKind Op1Info,
00177     OperandValueKind Op2Info, OperandValueProperties Opd1PropInfo,
00178     OperandValueProperties Opd2PropInfo) const {
00179   return PrevTTI->getArithmeticInstrCost(Opcode, Ty, Op1Info, Op2Info,
00180                                          Opd1PropInfo, Opd2PropInfo);
00181 }
00182 
00183 unsigned TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp,
00184                                              int Index, Type *SubTp) const {
00185   return PrevTTI->getShuffleCost(Kind, Tp, Index, SubTp);
00186 }
00187 
00188 unsigned TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
00189                                                Type *Src) const {
00190   return PrevTTI->getCastInstrCost(Opcode, Dst, Src);
00191 }
00192 
00193 unsigned TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
00194   return PrevTTI->getCFInstrCost(Opcode);
00195 }
00196 
00197 unsigned TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
00198                                                  Type *CondTy) const {
00199   return PrevTTI->getCmpSelInstrCost(Opcode, ValTy, CondTy);
00200 }
00201 
00202 unsigned TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
00203                                                  unsigned Index) const {
00204   return PrevTTI->getVectorInstrCost(Opcode, Val, Index);
00205 }
00206 
00207 unsigned TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
00208                                               unsigned Alignment,
00209                                               unsigned AddressSpace) const {
00210   return PrevTTI->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
00211   ;
00212 }
00213 
00214 unsigned
00215 TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID,
00216                                            Type *RetTy,
00217                                            ArrayRef<Type *> Tys) const {
00218   return PrevTTI->getIntrinsicInstrCost(ID, RetTy, Tys);
00219 }
00220 
00221 unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
00222   return PrevTTI->getNumberOfParts(Tp);
00223 }
00224 
00225 unsigned TargetTransformInfo::getAddressComputationCost(Type *Tp,
00226                                                         bool IsComplex) const {
00227   return PrevTTI->getAddressComputationCost(Tp, IsComplex);
00228 }
00229 
00230 unsigned TargetTransformInfo::getReductionCost(unsigned Opcode, Type *Ty,
00231                                                bool IsPairwise) const {
00232   return PrevTTI->getReductionCost(Opcode, Ty, IsPairwise);
00233 }
00234 
00235 unsigned TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type*> Tys)
00236   const {
00237   return PrevTTI->getCostOfKeepingLiveOverCall(Tys);
00238 }
00239 
00240 namespace {
00241 
00242 struct NoTTI final : ImmutablePass, TargetTransformInfo {
00243   const DataLayout *DL;
00244 
00245   NoTTI() : ImmutablePass(ID), DL(nullptr) {
00246     initializeNoTTIPass(*PassRegistry::getPassRegistry());
00247   }
00248 
00249   void initializePass() override {
00250     // Note that this subclass is special, and must *not* call initializeTTI as
00251     // it does not chain.
00252     TopTTI = this;
00253     PrevTTI = nullptr;
00254     DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
00255     DL = DLP ? &DLP->getDataLayout() : nullptr;
00256   }
00257 
00258   void getAnalysisUsage(AnalysisUsage &AU) const override {
00259     // Note that this subclass is special, and must *not* call
00260     // TTI::getAnalysisUsage as it breaks the recursion.
00261   }
00262 
00263   /// Pass identification.
00264   static char ID;
00265 
00266   /// Provide necessary pointer adjustments for the two base classes.
00267   void *getAdjustedAnalysisPointer(const void *ID) override {
00268     if (ID == &TargetTransformInfo::ID)
00269       return (TargetTransformInfo*)this;
00270     return this;
00271   }
00272 
00273   unsigned getOperationCost(unsigned Opcode, Type *Ty,
00274                             Type *OpTy) const override {
00275     switch (Opcode) {
00276     default:
00277       // By default, just classify everything as 'basic'.
00278       return TCC_Basic;
00279 
00280     case Instruction::GetElementPtr:
00281       llvm_unreachable("Use getGEPCost for GEP operations!");
00282 
00283     case Instruction::BitCast:
00284       assert(OpTy && "Cast instructions must provide the operand type");
00285       if (Ty == OpTy || (Ty->isPointerTy() && OpTy->isPointerTy()))
00286         // Identity and pointer-to-pointer casts are free.
00287         return TCC_Free;
00288 
00289       // Otherwise, the default basic cost is used.
00290       return TCC_Basic;
00291 
00292     case Instruction::IntToPtr: {
00293       if (!DL)
00294         return TCC_Basic;
00295 
00296       // An inttoptr cast is free so long as the input is a legal integer type
00297       // which doesn't contain values outside the range of a pointer.
00298       unsigned OpSize = OpTy->getScalarSizeInBits();
00299       if (DL->isLegalInteger(OpSize) &&
00300           OpSize <= DL->getPointerTypeSizeInBits(Ty))
00301         return TCC_Free;
00302 
00303       // Otherwise it's not a no-op.
00304       return TCC_Basic;
00305     }
00306     case Instruction::PtrToInt: {
00307       if (!DL)
00308         return TCC_Basic;
00309 
00310       // A ptrtoint cast is free so long as the result is large enough to store
00311       // the pointer, and a legal integer type.
00312       unsigned DestSize = Ty->getScalarSizeInBits();
00313       if (DL->isLegalInteger(DestSize) &&
00314           DestSize >= DL->getPointerTypeSizeInBits(OpTy))
00315         return TCC_Free;
00316 
00317       // Otherwise it's not a no-op.
00318       return TCC_Basic;
00319     }
00320     case Instruction::Trunc:
00321       // trunc to a native type is free (assuming the target has compare and
00322       // shift-right of the same width).
00323       if (DL && DL->isLegalInteger(DL->getTypeSizeInBits(Ty)))
00324         return TCC_Free;
00325 
00326       return TCC_Basic;
00327     }
00328   }
00329 
00330   unsigned getGEPCost(const Value *Ptr,
00331                       ArrayRef<const Value *> Operands) const override {
00332     // In the basic model, we just assume that all-constant GEPs will be folded
00333     // into their uses via addressing modes.
00334     for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx)
00335       if (!isa<Constant>(Operands[Idx]))
00336         return TCC_Basic;
00337 
00338     return TCC_Free;
00339   }
00340 
00341   unsigned getCallCost(FunctionType *FTy, int NumArgs = -1) const override
00342   {
00343     assert(FTy && "FunctionType must be provided to this routine.");
00344 
00345     // The target-independent implementation just measures the size of the
00346     // function by approximating that each argument will take on average one
00347     // instruction to prepare.
00348 
00349     if (NumArgs < 0)
00350       // Set the argument number to the number of explicit arguments in the
00351       // function.
00352       NumArgs = FTy->getNumParams();
00353 
00354     return TCC_Basic * (NumArgs + 1);
00355   }
00356 
00357   unsigned getCallCost(const Function *F, int NumArgs = -1) const override
00358   {
00359     assert(F && "A concrete function must be provided to this routine.");
00360 
00361     if (NumArgs < 0)
00362       // Set the argument number to the number of explicit arguments in the
00363       // function.
00364       NumArgs = F->arg_size();
00365 
00366     if (Intrinsic::ID IID = (Intrinsic::ID)F->getIntrinsicID()) {
00367       FunctionType *FTy = F->getFunctionType();
00368       SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
00369       return TopTTI->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
00370     }
00371 
00372     if (!TopTTI->isLoweredToCall(F))
00373       return TCC_Basic; // Give a basic cost if it will be lowered directly.
00374 
00375     return TopTTI->getCallCost(F->getFunctionType(), NumArgs);
00376   }
00377 
00378   unsigned getCallCost(const Function *F,
00379                        ArrayRef<const Value *> Arguments) const override {
00380     // Simply delegate to generic handling of the call.
00381     // FIXME: We should use instsimplify or something else to catch calls which
00382     // will constant fold with these arguments.
00383     return TopTTI->getCallCost(F, Arguments.size());
00384   }
00385 
00386   unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
00387                             ArrayRef<Type *> ParamTys) const override {
00388     switch (IID) {
00389     default:
00390       // Intrinsics rarely (if ever) have normal argument setup constraints.
00391       // Model them as having a basic instruction cost.
00392       // FIXME: This is wrong for libc intrinsics.
00393       return TCC_Basic;
00394 
00395     case Intrinsic::assume:
00396     case Intrinsic::dbg_declare:
00397     case Intrinsic::dbg_value:
00398     case Intrinsic::invariant_start:
00399     case Intrinsic::invariant_end:
00400     case Intrinsic::lifetime_start:
00401     case Intrinsic::lifetime_end:
00402     case Intrinsic::objectsize:
00403     case Intrinsic::ptr_annotation:
00404     case Intrinsic::var_annotation:
00405       // These intrinsics don't actually represent code after lowering.
00406       return TCC_Free;
00407     }
00408   }
00409 
00410   unsigned
00411   getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
00412                    ArrayRef<const Value *> Arguments) const override {
00413     // Delegate to the generic intrinsic handling code. This mostly provides an
00414     // opportunity for targets to (for example) special case the cost of
00415     // certain intrinsics based on constants used as arguments.
00416     SmallVector<Type *, 8> ParamTys;
00417     ParamTys.reserve(Arguments.size());
00418     for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; ++Idx)
00419       ParamTys.push_back(Arguments[Idx]->getType());
00420     return TopTTI->getIntrinsicCost(IID, RetTy, ParamTys);
00421   }
00422 
00423   unsigned getUserCost(const User *U) const override {
00424     if (isa<PHINode>(U))
00425       return TCC_Free; // Model all PHI nodes as free.
00426 
00427     if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
00428       SmallVector<const Value *, 4> Indices(GEP->idx_begin(), GEP->idx_end());
00429       return TopTTI->getGEPCost(GEP->getPointerOperand(), Indices);
00430     }
00431 
00432     if (ImmutableCallSite CS = U) {
00433       const Function *F = CS.getCalledFunction();
00434       if (!F) {
00435         // Just use the called value type.
00436         Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
00437         return TopTTI->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
00438       }
00439 
00440       SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end());
00441       return TopTTI->getCallCost(F, Arguments);
00442     }
00443 
00444     if (const CastInst *CI = dyn_cast<CastInst>(U)) {
00445       // Result of a cmp instruction is often extended (to be used by other
00446       // cmp instructions, logical or return instructions). These are usually
00447       // nop on most sane targets.
00448       if (isa<CmpInst>(CI->getOperand(0)))
00449         return TCC_Free;
00450     }
00451 
00452     // Otherwise delegate to the fully generic implementations.
00453     return getOperationCost(Operator::getOpcode(U), U->getType(),
00454                             U->getNumOperands() == 1 ?
00455                                 U->getOperand(0)->getType() : nullptr);
00456   }
00457 
00458   bool hasBranchDivergence() const override { return false; }
00459 
00460   bool isLoweredToCall(const Function *F) const override {
00461     // FIXME: These should almost certainly not be handled here, and instead
00462     // handled with the help of TLI or the target itself. This was largely
00463     // ported from existing analysis heuristics here so that such refactorings
00464     // can take place in the future.
00465 
00466     if (F->isIntrinsic())
00467       return false;
00468 
00469     if (F->hasLocalLinkage() || !F->hasName())
00470       return true;
00471 
00472     StringRef Name = F->getName();
00473 
00474     // These will all likely lower to a single selection DAG node.
00475     if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
00476         Name == "fabs" || Name == "fabsf" || Name == "fabsl" || Name == "sin" ||
00477         Name == "sinf" || Name == "sinl" || Name == "cos" || Name == "cosf" ||
00478         Name == "cosl" || Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl")
00479       return false;
00480 
00481     // These are all likely to be optimized into something smaller.
00482     if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
00483         Name == "exp2l" || Name == "exp2f" || Name == "floor" || Name ==
00484         "floorf" || Name == "ceil" || Name == "round" || Name == "ffs" ||
00485         Name == "ffsl" || Name == "abs" || Name == "labs" || Name == "llabs")
00486       return false;
00487 
00488     return true;
00489   }
00490 
00491   void getUnrollingPreferences(const Function *, Loop *,
00492                                UnrollingPreferences &) const override {}
00493 
00494   bool isLegalAddImmediate(int64_t Imm) const override {
00495     return false;
00496   }
00497 
00498   bool isLegalICmpImmediate(int64_t Imm) const override {
00499     return false;
00500   }
00501 
00502   bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
00503                              bool HasBaseReg, int64_t Scale) const override
00504   {
00505     // Guess that reg+reg addressing is allowed. This heuristic is taken from
00506     // the implementation of LSR.
00507     return !BaseGV && BaseOffset == 0 && Scale <= 1;
00508   }
00509 
00510   int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
00511                            bool HasBaseReg, int64_t Scale) const override {
00512     // Guess that all legal addressing mode are free.
00513     if(isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg, Scale))
00514       return 0;
00515     return -1;
00516   }
00517 
00518   bool isTruncateFree(Type *Ty1, Type *Ty2) const override {
00519     return false;
00520   }
00521 
00522   bool isTypeLegal(Type *Ty) const override {
00523     return false;
00524   }
00525 
00526   unsigned getJumpBufAlignment() const override {
00527     return 0;
00528   }
00529 
00530   unsigned getJumpBufSize() const override {
00531     return 0;
00532   }
00533 
00534   bool shouldBuildLookupTables() const override {
00535     return true;
00536   }
00537 
00538   PopcntSupportKind
00539   getPopcntSupport(unsigned IntTyWidthInBit) const override {
00540     return PSK_Software;
00541   }
00542 
00543   bool haveFastSqrt(Type *Ty) const override {
00544     return false;
00545   }
00546 
00547   unsigned getIntImmCost(const APInt &Imm, Type *Ty) const override {
00548     return TCC_Basic;
00549   }
00550 
00551   unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
00552                          Type *Ty) const override {
00553     return TCC_Free;
00554   }
00555 
00556   unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
00557                          Type *Ty) const override {
00558     return TCC_Free;
00559   }
00560 
00561   unsigned getNumberOfRegisters(bool Vector) const override {
00562     return 8;
00563   }
00564 
00565   unsigned  getRegisterBitWidth(bool Vector) const override {
00566     return 32;
00567   }
00568 
00569   unsigned getMaxInterleaveFactor() const override {
00570     return 1;
00571   }
00572 
00573   unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind,
00574                                   OperandValueKind, OperandValueProperties,
00575                                   OperandValueProperties) const override {
00576     return 1;
00577   }
00578 
00579   unsigned getShuffleCost(ShuffleKind Kind, Type *Ty,
00580                           int Index = 0, Type *SubTp = nullptr) const override {
00581     return 1;
00582   }
00583 
00584   unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
00585                             Type *Src) const override {
00586     return 1;
00587   }
00588 
00589   unsigned getCFInstrCost(unsigned Opcode) const override {
00590     return 1;
00591   }
00592 
00593   unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
00594                               Type *CondTy = nullptr) const override {
00595     return 1;
00596   }
00597 
00598   unsigned getVectorInstrCost(unsigned Opcode, Type *Val,
00599                               unsigned Index = -1) const override {
00600     return 1;
00601   }
00602 
00603   unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
00604                            unsigned AddressSpace) const override {
00605     return 1;
00606   }
00607 
00608   unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
00609                                  ArrayRef<Type*> Tys) const override {
00610     return 1;
00611   }
00612 
00613   unsigned getNumberOfParts(Type *Tp) const override {
00614     return 0;
00615   }
00616 
00617   unsigned getAddressComputationCost(Type *Tp, bool) const override {
00618     return 0;
00619   }
00620 
00621   unsigned getReductionCost(unsigned, Type *, bool) const override {
00622     return 1;
00623   }
00624 
00625   unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type*> Tys) const override {
00626     return 0;
00627   }
00628 
00629 };
00630 
00631 } // end anonymous namespace
00632 
00633 INITIALIZE_AG_PASS(NoTTI, TargetTransformInfo, "notti",
00634                    "No target information", true, true, true)
00635 char NoTTI::ID = 0;
00636 
00637 ImmutablePass *llvm::createNoTargetTransformInfoPass() {
00638   return new NoTTI();
00639 }