Index: include/llvm/Analysis/TargetTransformInfo.h =================================================================== --- include/llvm/Analysis/TargetTransformInfo.h +++ include/llvm/Analysis/TargetTransformInfo.h @@ -38,6 +38,7 @@ class Type; class User; class Value; +class TargetLibraryInfo; /// \brief Information about a load/store intrinsic defined by the target. struct MemIntrinsicInfo { @@ -449,6 +450,10 @@ unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, ArrayRef Tys) const; + /// \returns The cost of Call instructions. + unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef Tys, + const TargetLibraryInfo *TLI) const; + /// \returns The number of pieces into which the provided type must be /// split during legalization. Zero is returned when the answer is unknown. unsigned getNumberOfParts(Type *Tp) const; @@ -565,6 +570,9 @@ bool IsPairwiseForm) = 0; virtual unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, ArrayRef Tys) = 0; + virtual unsigned getCallInstrCost(Function *F, Type *RetTy, + ArrayRef Tys, + const TargetLibraryInfo *TLI) = 0; virtual unsigned getNumberOfParts(Type *Tp) = 0; virtual unsigned getAddressComputationCost(Type *Ty, bool IsComplex) = 0; virtual unsigned getCostOfKeepingLiveOverCall(ArrayRef Tys) = 0; @@ -719,6 +727,10 @@ ArrayRef Tys) override { return Impl.getIntrinsicInstrCost(ID, RetTy, Tys); } + unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef Tys, + const TargetLibraryInfo *TLI) override { + return Impl.getCallInstrCost(F, RetTy, Tys, TLI); + } unsigned getNumberOfParts(Type *Tp) override { return Impl.getNumberOfParts(Tp); } Index: include/llvm/Analysis/TargetTransformInfoImpl.h =================================================================== --- include/llvm/Analysis/TargetTransformInfoImpl.h +++ include/llvm/Analysis/TargetTransformInfoImpl.h @@ -301,6 +301,11 @@ return 1; } + unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef Tys, + const TargetLibraryInfo *TLI) { + return 1; + } + unsigned getNumberOfParts(Type *Tp) { return 0; } unsigned getAddressComputationCost(Type *Tp, bool) { return 0; } Index: include/llvm/CodeGen/BasicTTIImpl.h =================================================================== --- include/llvm/CodeGen/BasicTTIImpl.h +++ include/llvm/CodeGen/BasicTTIImpl.h @@ -21,6 +21,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetSubtargetInfo.h" +#include "llvm/Analysis/TargetLibraryInfo.h" namespace llvm { @@ -658,6 +659,16 @@ return 10; } + /// Compute a cost of the given call instruction. + /// \param F Called function. + /// \param RetTy,Tys Return value and argument types. + /// \param TLI TargetLibraryInfo. + /// \returns The cost of Call instruction. + unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef Tys, + const TargetLibraryInfo *TLI) { + return 10; + } + unsigned getNumberOfParts(Type *Tp) { std::pair LT = getTLI()->getTypeLegalizationCost(Tp); return LT.first; Index: lib/Analysis/TargetTransformInfo.cpp =================================================================== --- lib/Analysis/TargetTransformInfo.cpp +++ lib/Analysis/TargetTransformInfo.cpp @@ -233,6 +233,13 @@ return TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys); } +unsigned +TargetTransformInfo::getCallInstrCost(Function *F, Type *RetTy, + ArrayRef Tys, + const TargetLibraryInfo *TLI) const { + return TTIImpl->getCallInstrCost(F, RetTy, Tys, TLI); +} + unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const { return TTIImpl->getNumberOfParts(Tp); }