28
28
29
29
using namespace llvm ;
30
30
31
- enum OutputCostKind {
31
+ enum class OutputCostKind {
32
32
RecipThroughput,
33
33
Latency,
34
34
CodeSize,
@@ -87,6 +87,22 @@ static InstructionCost getCost(Instruction &Inst, TTI::TargetCostKind CostKind,
87
87
return TTI.getInstructionCost (&Inst, CostKind);
88
88
}
89
89
90
+ static TTI::TargetCostKind
91
+ OutputCostKindToTargetCostKind (OutputCostKind CostKind) {
92
+ switch (CostKind) {
93
+ case OutputCostKind::RecipThroughput:
94
+ return TTI::TCK_RecipThroughput;
95
+ case OutputCostKind::Latency:
96
+ return TTI::TCK_Latency;
97
+ case OutputCostKind::CodeSize:
98
+ return TTI::TCK_CodeSize;
99
+ case OutputCostKind::SizeAndLatency:
100
+ return TTI::TCK_SizeAndLatency;
101
+ default :
102
+ llvm_unreachable (" Unexpected OutputCostKind!" );
103
+ };
104
+ }
105
+
90
106
PreservedAnalyses CostModelPrinterPass::run (Function &F,
91
107
FunctionAnalysisManager &AM) {
92
108
auto &TTI = AM.getResult <TargetIRAnalysis>(F);
@@ -111,7 +127,7 @@ PreservedAnalyses CostModelPrinterPass::run(Function &F,
111
127
OS << " for: " << Inst << " \n " ;
112
128
} else {
113
129
InstructionCost Cost =
114
- getCost (Inst, (TTI::TargetCostKind)( unsigned ) CostKind, TTI, TLI);
130
+ getCost (Inst, OutputCostKindToTargetCostKind ( CostKind) , TTI, TLI);
115
131
if (auto CostVal = Cost.getValue ())
116
132
OS << " Found an estimated cost of " << *CostVal;
117
133
else
0 commit comments