LLVM: lib/Analysis/CostModel.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
28
29using namespace llvm;
30
38
40 "cost-kind", cl::desc("Target cost kind"),
43 "Reciprocal throughput"),
45 "Instruction latency"),
48 "Code size and latency"),
50
56
58 "intrinsic-cost-strategy",
59 cl::desc("Costing strategy for intrinsic instructions"),
63 "Use TargetTransformInfo::getInstructionCost"),
65 "Use TargetTransformInfo::getIntrinsicInstrCost"),
68 "type-based-intrinsic-cost",
69 "Calculate the intrinsic cost based only on argument types")));
70
71#define CM_NAME "cost-model"
72#define DEBUG_TYPE CM_NAME
73
83 &TLI);
84 return TTI.getIntrinsicInstrCost(ICA, CostKind);
85 }
86
87 return TTI.getInstructionCost(&Inst, CostKind);
88}
89
105
110 OS << "Printing analysis 'Cost Model Analysis' for function '" << F.getName() << "':\n";
113 OS << "Cost Model: ";
115 OS << "Found costs of ";
122 if (RThru == CodeSize && RThru == Lat && RThru == SizeLat)
123 OS << RThru;
124 else
125 OS << "RThru:" << RThru << " CodeSize:" << CodeSize << " Lat:" << Lat
126 << " SizeLat:" << SizeLat;
127 OS << " for: " << Inst << "\n";
128 } else {
131 if (Cost.isValid())
132 OS << "Found an estimated cost of " << Cost.getValue();
133 else
134 OS << "Invalid cost";
135 OS << " for instruction: " << Inst << "\n";
136 }
137 }
138 }
140}
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
static cl::opt< IntrinsicCostStrategy > IntrinsicCost("intrinsic-cost-strategy", cl::desc("Costing strategy for intrinsic instructions"), cl::init(IntrinsicCostStrategy::InstructionCost), cl::values(clEnumValN(IntrinsicCostStrategy::InstructionCost, "instruction-cost", "Use TargetTransformInfo::getInstructionCost"), clEnumValN(IntrinsicCostStrategy::IntrinsicCost, "intrinsic-cost", "Use TargetTransformInfo::getIntrinsicInstrCost"), clEnumValN(IntrinsicCostStrategy::TypeBasedIntrinsicCost, "type-based-intrinsic-cost", "Calculate the intrinsic cost based only on argument types")))
static TTI::TargetCostKind OutputCostKindToTargetCostKind(OutputCostKind CostKind)
Definition CostModel.cpp:91
IntrinsicCostStrategy
Definition CostModel.cpp:51
@ IntrinsicCost
Definition CostModel.cpp:53
@ InstructionCost
Definition CostModel.cpp:52
@ TypeBasedIntrinsicCost
Definition CostModel.cpp:54
OutputCostKind
Definition CostModel.cpp:31
@ Latency
Definition CostModel.cpp:33
@ CodeSize
Definition CostModel.cpp:34
@ SizeAndLatency
Definition CostModel.cpp:35
@ All
Definition CostModel.cpp:36
@ RecipThroughput
Definition CostModel.cpp:32
static InstructionCost getCost(Instruction &Inst, TTI::TargetCostKind CostKind, TargetTransformInfo &TTI, TargetLibraryInfo &TLI)
Definition CostModel.cpp:74
This header defines various interfaces for pass management in LLVM.
uint64_t IntrinsicInst * II
This pass exposes codegen information to IR-level passes.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM Basic Block Representation.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition CostModel.cpp:106
static InstructionCost getInvalid(CostType Val=0)
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Analysis pass providing the TargetTransformInfo.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
TargetCostKind
The kind of cost model.
@ TCK_RecipThroughput
Reciprocal throughput.
@ TCK_CodeSize
Instruction code size.
@ TCK_SizeAndLatency
The weighted sum of size and latency.
@ TCK_Latency
The latency of instruction.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.