Skip to content

Commit 9ba07f3

Browse files
committed
[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
1 parent e0edfa0 commit 9ba07f3

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,10 @@ class TargetTransformInfo {
263263
};
264264

265265
/// Estimate the cost of a GEP operation when lowered.
266-
int getGEPCost(Type *PointeeType, const Value *Ptr,
267-
ArrayRef<const Value *> Operands,
268-
TargetCostKind CostKind = TCK_SizeAndLatency) const;
266+
InstructionCost
267+
getGEPCost(Type *PointeeType, const Value *Ptr,
268+
ArrayRef<const Value *> Operands,
269+
TargetCostKind CostKind = TCK_SizeAndLatency) const;
269270

270271
/// \returns A value by which our inlining threshold should be multiplied.
271272
/// This is primarily used to bump up the inlining threshold wholesale on
@@ -1401,9 +1402,9 @@ class TargetTransformInfo::Concept {
14011402
public:
14021403
virtual ~Concept() = 0;
14031404
virtual const DataLayout &getDataLayout() const = 0;
1404-
virtual int getGEPCost(Type *PointeeType, const Value *Ptr,
1405-
ArrayRef<const Value *> Operands,
1406-
TTI::TargetCostKind CostKind) = 0;
1405+
virtual InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr,
1406+
ArrayRef<const Value *> Operands,
1407+
TTI::TargetCostKind CostKind) = 0;
14071408
virtual unsigned getInliningThresholdMultiplier() = 0;
14081409
virtual unsigned adjustInliningThreshold(const CallBase *CB) = 0;
14091410
virtual int getInlinerVectorBonusPercent() = 0;
@@ -1693,9 +1694,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
16931694
return Impl.getDataLayout();
16941695
}
16951696

1696-
int getGEPCost(Type *PointeeType, const Value *Ptr,
1697-
ArrayRef<const Value *> Operands,
1698-
enum TargetTransformInfo::TargetCostKind CostKind) override {
1697+
InstructionCost
1698+
getGEPCost(Type *PointeeType, const Value *Ptr,
1699+
ArrayRef<const Value *> Operands,
1700+
enum TargetTransformInfo::TargetCostKind CostKind) override {
16991701
return Impl.getGEPCost(PointeeType, Ptr, Operands);
17001702
}
17011703
unsigned getInliningThresholdMultiplier() override {

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ class TargetTransformInfoImplBase {
4747

4848
const DataLayout &getDataLayout() const { return DL; }
4949

50-
int getGEPCost(Type *PointeeType, const Value *Ptr,
51-
ArrayRef<const Value *> Operands,
52-
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) const {
50+
InstructionCost
51+
getGEPCost(Type *PointeeType, const Value *Ptr,
52+
ArrayRef<const Value *> Operands,
53+
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) const {
5354
// In the basic model, we just assume that all-constant GEPs will be folded
5455
// into their uses via addressing modes.
5556
for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx)
@@ -841,9 +842,10 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
841842
public:
842843
using BaseT::getGEPCost;
843844

844-
int getGEPCost(Type *PointeeType, const Value *Ptr,
845-
ArrayRef<const Value *> Operands,
846-
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) {
845+
InstructionCost
846+
getGEPCost(Type *PointeeType, const Value *Ptr,
847+
ArrayRef<const Value *> Operands,
848+
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency) {
847849
assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
848850
// TODO: will remove this when pointers have an opaque type.
849851
assert(Ptr->getType()->getScalarType()->getPointerElementType() ==

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
310310
return getTLI()->getTypeLegalizationCost(DL, Ty).first;
311311
}
312312

313-
int getGEPCost(Type *PointeeType, const Value *Ptr,
314-
ArrayRef<const Value *> Operands) {
313+
InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr,
314+
ArrayRef<const Value *> Operands) {
315315
return BaseT::getGEPCost(PointeeType, Ptr, Operands);
316316
}
317317

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ int TargetTransformInfo::getInlinerVectorBonusPercent() const {
206206
return TTIImpl->getInlinerVectorBonusPercent();
207207
}
208208

209-
int TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr,
210-
ArrayRef<const Value *> Operands,
211-
TTI::TargetCostKind CostKind) const {
209+
InstructionCost
210+
TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr,
211+
ArrayRef<const Value *> Operands,
212+
TTI::TargetCostKind CostKind) const {
212213
return TTIImpl->getGEPCost(PointeeType, Ptr, Operands, CostKind);
213214
}
214215

0 commit comments

Comments
 (0)