From 9eda3a0c2e0ca7e6868f6ca10b4b5a8f9f49c4b9 Mon Sep 17 00:00:00 2001 From: Sander de Smalen Date: Wed, 27 Jan 2021 13:15:21 +0000 Subject: [PATCH] [TTI] NFC: Change getGEPCost to return InstructionCost This patch migrates the TTI cost interfaces to return an InstructionCost. See this patch for the introduction of the type: https://reviews.llvm.org/D91174 See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html Differential Revision: https://reviews.llvm.org/D100562 --- include/llvm/Analysis/TargetTransformInfo.h | 20 ++++++++++--------- .../llvm/Analysis/TargetTransformInfoImpl.h | 14 +++++++------ include/llvm/CodeGen/BasicTTIImpl.h | 4 ++-- lib/Analysis/TargetTransformInfo.cpp | 7 ++++--- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 646c61dc464..9031323ea9d 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -263,9 +263,10 @@ public: }; /// Estimate the cost of a GEP operation when lowered. - int getGEPCost(Type *PointeeType, const Value *Ptr, - ArrayRef Operands, - TargetCostKind CostKind = TCK_SizeAndLatency) const; + InstructionCost + getGEPCost(Type *PointeeType, const Value *Ptr, + ArrayRef Operands, + TargetCostKind CostKind = TCK_SizeAndLatency) const; /// \returns A value by which our inlining threshold should be multiplied. /// This is primarily used to bump up the inlining threshold wholesale on @@ -1401,9 +1402,9 @@ class TargetTransformInfo::Concept { public: virtual ~Concept() = 0; virtual const DataLayout &getDataLayout() const = 0; - virtual int getGEPCost(Type *PointeeType, const Value *Ptr, - ArrayRef Operands, - TTI::TargetCostKind CostKind) = 0; + virtual InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, + ArrayRef Operands, + TTI::TargetCostKind CostKind) = 0; virtual unsigned getInliningThresholdMultiplier() = 0; virtual unsigned adjustInliningThreshold(const CallBase *CB) = 0; virtual int getInlinerVectorBonusPercent() = 0; @@ -1693,9 +1694,10 @@ public: return Impl.getDataLayout(); } - int getGEPCost(Type *PointeeType, const Value *Ptr, - ArrayRef Operands, - enum TargetTransformInfo::TargetCostKind CostKind) override { + InstructionCost + getGEPCost(Type *PointeeType, const Value *Ptr, + ArrayRef Operands, + enum TargetTransformInfo::TargetCostKind CostKind) override { return Impl.getGEPCost(PointeeType, Ptr, Operands); } unsigned getInliningThresholdMultiplier() override { diff --git a/include/llvm/Analysis/TargetTransformInfoImpl.h b/include/llvm/Analysis/TargetTransformInfoImpl.h index 966660e1c8f..a57994cf7f8 100644 --- a/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -47,9 +47,10 @@ public: const DataLayout &getDataLayout() const { return DL; } - int getGEPCost(Type *PointeeType, const Value *Ptr, - ArrayRef Operands, - TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) const { + InstructionCost + getGEPCost(Type *PointeeType, const Value *Ptr, + ArrayRef Operands, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) const { // In the basic model, we just assume that all-constant GEPs will be folded // into their uses via addressing modes. for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx) @@ -841,9 +842,10 @@ protected: public: using BaseT::getGEPCost; - int getGEPCost(Type *PointeeType, const Value *Ptr, - ArrayRef Operands, - TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) { + InstructionCost + getGEPCost(Type *PointeeType, const Value *Ptr, + ArrayRef Operands, + TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) { assert(PointeeType && Ptr && "can't get GEPCost of nullptr"); // TODO: will remove this when pointers have an opaque type. assert(Ptr->getType()->getScalarType()->getPointerElementType() == diff --git a/include/llvm/CodeGen/BasicTTIImpl.h b/include/llvm/CodeGen/BasicTTIImpl.h index ebc49bb04c9..dc9bc64b879 100644 --- a/include/llvm/CodeGen/BasicTTIImpl.h +++ b/include/llvm/CodeGen/BasicTTIImpl.h @@ -310,8 +310,8 @@ public: return getTLI()->getTypeLegalizationCost(DL, Ty).first; } - int getGEPCost(Type *PointeeType, const Value *Ptr, - ArrayRef Operands) { + InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, + ArrayRef Operands) { return BaseT::getGEPCost(PointeeType, Ptr, Operands); } diff --git a/lib/Analysis/TargetTransformInfo.cpp b/lib/Analysis/TargetTransformInfo.cpp index 6d78abce8d3..cd11fb83acd 100644 --- a/lib/Analysis/TargetTransformInfo.cpp +++ b/lib/Analysis/TargetTransformInfo.cpp @@ -206,9 +206,10 @@ int TargetTransformInfo::getInlinerVectorBonusPercent() const { return TTIImpl->getInlinerVectorBonusPercent(); } -int TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr, - ArrayRef Operands, - TTI::TargetCostKind CostKind) const { +InstructionCost +TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr, + ArrayRef Operands, + TTI::TargetCostKind CostKind) const { return TTIImpl->getGEPCost(PointeeType, Ptr, Operands, CostKind); }