32 "cost-kind",
cl::desc(
"Target cost kind"),
35 "throughput",
"Reciprocal throughput"),
37 "latency",
"Instruction latency"),
39 "code-size",
"Code size"),
41 "size-latency",
"Code size and latency")));
44 cl::desc(
"Calculate intrinsics cost based only on argument types"),
47#define CM_NAME "cost-model"
48#define DEBUG_TYPE CM_NAME
73char CostModelAnalysis::ID = 0;
74static const char cm_name[] =
"Cost Model Analysis";
79 return new CostModelAnalysis();
88CostModelAnalysis::runOnFunction(
Function &
F) {
90 auto *TTIWP = getAnalysisIfAvailable<TargetTransformInfoWrapperPass>();
91 TTI = TTIWP ? &TTIWP->getTTI(
F) :
nullptr;
103 auto *II = dyn_cast<IntrinsicInst>(&Inst);
114 OS <<
"Cost Model: Found an estimated cost of " << *CostVal;
116 OS <<
"Cost Model: Invalid cost";
118 OS <<
" for instruction: " << Inst <<
"\n";
126 OS <<
"Printing analysis 'Cost Model Analysis' for function '" <<
F.getName() <<
"':\n";
132 auto *II = dyn_cast<IntrinsicInst>(&Inst);
143 OS <<
"Cost Model: Found an estimated cost of " << *CostVal;
145 OS <<
"Cost Model: Invalid cost";
147 OS <<
" for instruction: " << Inst <<
"\n";
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static cl::opt< TargetTransformInfo::TargetCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(TargetTransformInfo::TCK_RecipThroughput), cl::values(clEnumValN(TargetTransformInfo::TCK_RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(TargetTransformInfo::TCK_Latency, "latency", "Instruction latency"), clEnumValN(TargetTransformInfo::TCK_CodeSize, "code-size", "Code size"), clEnumValN(TargetTransformInfo::TCK_SizeAndLatency, "size-latency", "Code size and latency")))
static cl::opt< bool > TypeBasedIntrinsicCost("type-based-intrinsic-cost", cl::desc("Calculate intrinsics cost based only on argument types"), cl::init(false))
static const char cm_name[]
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
LLVM Basic Block Representation.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
static InstructionCost getInvalid(CostType Val=0)
std::optional< CostType > getValue() const
This function is intended to be used as sparingly as possible, since the class provides the full rang...
A Module instance is used to store all the information related to an LLVM module.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
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.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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.
void initializeCostModelAnalysisPass(PassRegistry &)
FunctionPass * createCostModelAnalysisPass()