31 "cost-kind",
cl::desc(
"Target cost kind"),
34 "throughput",
"Reciprocal throughput"),
36 "latency",
"Instruction latency"),
38 "code-size",
"Code size")));
40 #define CM_NAME "cost-model" 41 #define DEBUG_TYPE CM_NAME 48 CostModelAnalysis() :
FunctionPass(ID),
F(
nullptr), TTI(
nullptr) {
57 unsigned getInstructionCost(
const Instruction *
I)
const {
75 static const char cm_name[] =
"Cost Model Analysis";
80 return new CostModelAnalysis();
84 CostModelAnalysis::getAnalysisUsage(
AnalysisUsage &AU)
const {
91 auto *TTIWP = getAnalysisIfAvailable<TargetTransformInfoWrapperPass>();
92 TTI = TTIWP ? &TTIWP->getTTI(F) :
nullptr;
103 unsigned Cost = TTI->getInstructionCost(&Inst,
CostKind);
104 if (Cost != (
unsigned)-1)
105 OS <<
"Cost Model: Found an estimated cost of " << Cost;
107 OS <<
"Cost Model: Unknown cost";
109 OS <<
" for instruction: " << Inst <<
"\n";
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
void initializeCostModelAnalysisPass(PassRegistry &)
block Block Frequency true
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")))
static const char cm_name[]
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
void setPreservesAll()
Set by analyses that do not transform their input at all.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
FunctionPass * createCostModelAnalysisPass()
This class implements an extremely fast bulk output stream that can only output to a stream...