[PATCH] D102541: [TTI] NFC: Change getRegUsageForType to return InstructionCost.
Daniil Fukalov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 14 16:45:12 PDT 2021
dfukalov created this revision.
dfukalov added a reviewer: sdesmalen.
Herald added a subscriber: hiraditya.
dfukalov requested review of this revision.
Herald added a project: LLVM.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102541
Files:
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6563,8 +6563,8 @@
const auto &TTICapture = TTI;
auto GetRegUsage = [&TTICapture](Type *Ty, ElementCount VF) {
if (Ty->isTokenTy() || !VectorType::isValidElementType(Ty))
- return 0U;
- return TTICapture.getRegUsageForType(VectorType::get(Ty, VF));
+ return 0;
+ return *TTICapture.getRegUsageForType(VectorType::get(Ty, VF)).getValue();
};
for (unsigned int i = 0, s = IdxToInstr.size(); i < s; ++i) {
Index: llvm/lib/Analysis/TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetTransformInfo.cpp
+++ llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -449,7 +449,7 @@
return TTIImpl->isTypeLegal(Ty);
}
-unsigned TargetTransformInfo::getRegUsageForType(Type *Ty) const {
+InstructionCost TargetTransformInfo::getRegUsageForType(Type *Ty) const {
return TTIImpl->getRegUsageForType(Ty);
}
Index: llvm/include/llvm/CodeGen/BasicTTIImpl.h
===================================================================
--- llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -356,9 +356,8 @@
return getTLI()->isTypeLegal(VT);
}
- unsigned getRegUsageForType(Type *Ty) {
- InstructionCost::CostType Val =
- *getTLI()->getTypeLegalizationCost(DL, Ty).first.getValue();
+ InstructionCost getRegUsageForType(Type *Ty) {
+ InstructionCost Val = getTLI()->getTypeLegalizationCost(DL, Ty).first;
assert(Val >= 0 && "Negative cost!");
return Val;
}
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -291,7 +291,7 @@
bool isTypeLegal(Type *Ty) const { return false; }
- unsigned getRegUsageForType(Type *Ty) const { return 1; }
+ InstructionCost getRegUsageForType(Type *Ty) const { return 1; }
bool shouldBuildLookupTables() const { return true; }
Index: llvm/include/llvm/Analysis/TargetTransformInfo.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -709,7 +709,7 @@
bool isTypeLegal(Type *Ty) const;
/// Returns the estimated number of registers required to represent \p Ty.
- unsigned getRegUsageForType(Type *Ty) const;
+ InstructionCost getRegUsageForType(Type *Ty) const;
/// Return true if switches should be turned into lookup tables for the
/// target.
@@ -1528,7 +1528,7 @@
virtual bool isProfitableToHoist(Instruction *I) = 0;
virtual bool useAA() = 0;
virtual bool isTypeLegal(Type *Ty) = 0;
- virtual unsigned getRegUsageForType(Type *Ty) = 0;
+ virtual InstructionCost getRegUsageForType(Type *Ty) = 0;
virtual bool shouldBuildLookupTables() = 0;
virtual bool shouldBuildLookupTablesForConstant(Constant *C) = 0;
virtual bool shouldBuildRelLookupTables() = 0;
@@ -1921,7 +1921,7 @@
}
bool useAA() override { return Impl.useAA(); }
bool isTypeLegal(Type *Ty) override { return Impl.isTypeLegal(Ty); }
- unsigned getRegUsageForType(Type *Ty) override {
+ InstructionCost getRegUsageForType(Type *Ty) override {
return Impl.getRegUsageForType(Ty);
}
bool shouldBuildLookupTables() override {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102541.345586.patch
Type: text/x-patch
Size: 3597 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210514/f85f74af/attachment.bin>
More information about the llvm-commits
mailing list