41#define DEBUG_TYPE "machine-trace-metrics"
48 "Machine Trace Metrics",
false,
true)
55 std::fill(std::begin(Ensembles), std::end(Ensembles),
nullptr);
68 TII = ST.getInstrInfo();
69 TRI = ST.getRegisterInfo();
71 Loops = &getAnalysis<MachineLoopInfoWrapperPass>().getLI();
111 for (
const auto &
MI : *
MBB) {
112 if (
MI.isTransient())
128 assert(PI->ProcResourceIdx < PRKinds &&
"Bad processor resource kind");
129 PRCycles[PI->ProcResourceIdx] += PI->ReleaseAtCycle;
136 for (
unsigned K = 0; K != PRKinds; ++K)
137 ProcReleaseAtCycles[PROffset + K] =
145 assert(BlockInfo[MBBNum].hasResources() &&
146 "getResources() must be called before getProcReleaseAtCycles()");
148 assert((MBBNum+1) * PRKinds <= ProcReleaseAtCycles.
size());
149 return ArrayRef(ProcReleaseAtCycles.
data() + MBBNum * PRKinds, PRKinds);
158 BlockInfo.resize(
MTM.BlockInfo.size());
160 ProcResourceDepths.
resize(
MTM.BlockInfo.size() * PRKinds);
161 ProcResourceHeights.
resize(
MTM.BlockInfo.size() * PRKinds);
169 return MTM.Loops->getLoopFor(
MBB);
174void MachineTraceMetrics::Ensemble::
177 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
184 std::fill(ProcResourceDepths.begin() + PROffset,
185 ProcResourceDepths.begin() + PROffset + PRKinds, 0);
192 TraceBlockInfo *PredTBI = &BlockInfo[PredNum];
193 assert(PredTBI->hasValidDepth() &&
"Trace above has not been computed yet");
194 const FixedBlockInfo *PredFBI = MTM.getResources(TBI->
Pred);
195 TBI->
InstrDepth = PredTBI->InstrDepth + PredFBI->InstrCount;
196 TBI->
Head = PredTBI->Head;
201 for (
unsigned K = 0; K != PRKinds; ++K)
202 ProcResourceDepths[PROffset + K] = PredPRDepths[K] + PredPRCycles[K];
207void MachineTraceMetrics::Ensemble::
210 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
214 TBI->InstrHeight = MTM.getResources(
MBB)->InstrCount;
220 llvm::copy(PRCycles, ProcResourceHeights.begin() + PROffset);
226 unsigned SuccNum = TBI->Succ->getNumber();
227 TraceBlockInfo *SuccTBI = &BlockInfo[SuccNum];
228 assert(SuccTBI->hasValidHeight() &&
"Trace below has not been computed yet");
229 TBI->InstrHeight += SuccTBI->InstrHeight;
230 TBI->Tail = SuccTBI->Tail;
234 for (
unsigned K = 0;
K != PRKinds; ++
K)
235 ProcResourceHeights[PROffset + K] = SuccPRHeights[K] + PRCycles[K];
265 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
266 assert((MBBNum+1) * PRKinds <= ProcResourceDepths.size());
267 return ArrayRef(ProcResourceDepths.data() + MBBNum * PRKinds, PRKinds);
278 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
279 assert((MBBNum+1) * PRKinds <= ProcResourceHeights.size());
280 return ArrayRef(ProcResourceHeights.data() + MBBNum * PRKinds, PRKinds);
312 const char *
getName()
const override {
return "MinInstr"; }
324 const char *
getName()
const override {
return "Local"; }
347 unsigned CurCount = MTM.getResources(
MBB)->InstrCount;
349 unsigned BestDepth = 0;
352 getDepthResources(Pred);
358 if (!Best ||
Depth < BestDepth) {
373 unsigned BestHeight = 0;
376 if (CurLoop && Succ == CurLoop->
getHeader())
382 getHeightResources(Succ);
388 if (!Best || Height < BestHeight) {
400 "Invalid trace strategy enum");
401 Ensemble *&E = Ensembles[
static_cast<size_t>(strategy)];
408 return (E =
new MinInstrCountEnsemble(
this));
410 return (E =
new LocalEnsemble(
this));
449 bool Downward =
false;
480 if ((LB.Downward ? To : *
From) == FromLoop->getHeader())
489 return LB.Visited.insert(To).second;
500 LoopBounds Bounds(BlockInfo, MTM.Loops);
503 Bounds.Downward =
false;
504 Bounds.Visited.clear();
507 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
509 TBI.Pred = pickTracePred(
I);
517 computeDepthResources(
I);
521 Bounds.Downward =
true;
522 Bounds.Visited.clear();
525 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
527 TBI.Succ = pickTraceSucc(
I);
535 computeHeightResources(
I);
567 }
while (!WorkList.
empty());
592 }
while (!WorkList.
empty());
600 for (
const auto &
I : *BadMBB)
606 assert(BlockInfo.size() == MTM.MF->getNumBlockIDs() &&
607 "Outdated BlockInfo size");
608 for (
unsigned Num = 0, e = BlockInfo.size(); Num != e; ++Num) {
614 "Trace is broken, depth should have been invalidated.");
622 "Trace is broken, height should have been invalidated.");
626 "Trace contains backedge");
661 assert((++DefI).atEnd() &&
"Register has multiple defs");
673 if (
UseMI.isDebugInstr())
676 bool HasPhysRegs =
false;
683 if (Reg.isPhysical()) {
705 for (
unsigned i = 1; i !=
UseMI.getNumOperands(); i += 2) {
706 if (
UseMI.getOperand(i + 1).getMBB() == Pred) {
724 if (!MO.isReg() || !MO.getReg().isPhysical())
733 }
else if (MO.isKill())
740 if (
I == RegUnits.
end())
742 Deps.
push_back(DataDep(
I->MI,
I->Op, MO.getOperandNo()));
751 RegUnits.
erase(Unit);
754 for (
unsigned DefOp : LiveDefOps) {
775unsigned MachineTraceMetrics::Ensemble::
776computeCrossBlockCriticalPath(
const TraceBlockInfo &TBI) {
777 assert(TBI.HasValidInstrDepths &&
"Missing depth info");
778 assert(TBI.HasValidInstrHeights &&
"Missing height info");
780 for (
const LiveInReg &LIR : TBI.LiveIns) {
781 if (!LIR.Reg.isVirtual())
786 if (!DefTBI.isUsefulDominator(TBI))
788 unsigned Len = LIR.Height + Cycles[
DefMI].Depth;
789 MaxLen = std::max(MaxLen, Len);
806 for (
const DataDep &Dep : Deps) {
808 BlockInfo[Dep.DefMI->getParent()->getNumber()];
813 unsigned DepCycle = Cycles.lookup(Dep.DefMI).Depth;
815 if (!Dep.DefMI->isTransient())
816 DepCycle += MTM.SchedModel
817 .computeOperandLatency(Dep.DefMI, Dep.DefOp, &
UseMI, Dep.UseOp);
843 for (; Start !=
End; Start++)
844 updateDepth(Start->getParent(), *Start, RegUnits);
849void MachineTraceMetrics::Ensemble::
860 Stack.push_back(
MBB);
872 while (!Stack.empty()) {
873 MBB = Stack.pop_back_val();
876 TBI.HasValidInstrDepths =
true;
877 TBI.CriticalPath = 0;
881 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrDepth);
883 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
885 unsigned Factor = MTM.SchedModel.getResourceFactor(K);
886 dbgs() <<
format(
"%6uc @ ", MTM.getCycles(PRDepths[K]))
887 << MTM.SchedModel.getProcResource(K)->Name <<
" ("
888 << PRDepths[K]/Factor <<
" ops x" << Factor <<
")\n";
893 if (TBI.HasValidInstrHeights)
894 TBI.CriticalPath = computeCrossBlockCriticalPath(TBI);
897 updateDepth(TBI,
UseMI, RegUnits);
916 if (!Reg.isPhysical())
926 if (
I == RegUnits.
end())
928 unsigned DepHeight =
I->Cycle;
929 if (!
MI.isTransient()) {
935 Height = std::max(Height, DepHeight);
942 for (
unsigned Op : ReadOps) {
947 if (LRU.
Cycle <= Height && LRU.
MI != &
MI) {
967 if (!Dep.DefMI->isTransient())
974 std::tie(
I, New) = Heights.
insert(std::make_pair(Dep.DefMI, UseHeight));
979 if (
I->second < UseHeight)
980 I->second = UseHeight;
987void MachineTraceMetrics::Ensemble::
1001 TBI.LiveIns.push_back(Reg);
1008void MachineTraceMetrics::Ensemble::
1015 assert(TBI.hasValidHeight() &&
"Incomplete trace");
1016 if (TBI.HasValidInstrHeights)
1019 TBI.LiveIns.clear();
1037 for (LiveInReg &LI : TBI.LiveIns) {
1038 if (LI.Reg.isVirtual()) {
1040 unsigned &Height = Heights[MTM.MRI->getVRegDef(LI.Reg)];
1041 if (Height < LI.Height)
1046 RegUnits[LI.Reg].Cycle = LI.Height;
1057 TBI.HasValidInstrHeights =
true;
1058 TBI.CriticalPath = 0;
1061 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrHeight);
1063 for (
unsigned K = 0;
K != PRHeights.
size(); ++
K)
1065 unsigned Factor = MTM.SchedModel.getResourceFactor(K);
1066 dbgs() <<
format(
"%6uc @ ", MTM.getCycles(PRHeights[K]))
1067 << MTM.SchedModel.getProcResource(K)->Name <<
" ("
1068 << PRHeights[
K]/Factor <<
" ops x" << Factor <<
")\n";
1083 for (
const auto &
PHI : *Succ) {
1088 if (!Deps.
empty()) {
1090 unsigned Height = TBI.Succ ? Cycles.lookup(&
PHI).Height : 0;
1105 if (HeightI != Heights.
end()) {
1106 Cycle = HeightI->second;
1108 Heights.
erase(HeightI);
1122 for (
const DataDep &Dep : Deps)
1126 InstrCycles &MICycles = Cycles[&
MI];
1127 MICycles.Height =
Cycle;
1128 if (!TBI.HasValidInstrDepths) {
1133 TBI.CriticalPath = std::max(TBI.CriticalPath,
Cycle + MICycles.Depth);
1140 for (LiveInReg &LIR : TBI.LiveIns) {
1148 TBI.LiveIns.push_back(LiveInReg(RU.RegUnit, RU.Cycle));
1154 if (!TBI.HasValidInstrDepths)
1157 TBI.CriticalPath = std::max(TBI.CriticalPath,
1158 computeCrossBlockCriticalPath(TBI));
1159 LLVM_DEBUG(
dbgs() <<
"Critical path: " << TBI.CriticalPath <<
'\n');
1170 computeInstrDepths(
MBB);
1172 computeInstrHeights(
MBB);
1174 return Trace(*
this, TBI);
1179 assert(getBlockNum() ==
unsigned(
MI.getParent()->getNumber()) &&
1180 "MI must be in the trace center block");
1182 return getCriticalPath() - (Cyc.
Depth + Cyc.
Height);
1190 assert(Deps.
size() == 1 &&
"PHI doesn't have MBB as a predecessor");
1191 DataDep &Dep = Deps.
front();
1192 unsigned DepCycle = getInstrCycles(*Dep.DefMI).Depth;
1194 if (!Dep.DefMI->isTransient())
1195 DepCycle += TE.MTM.SchedModel.computeOperandLatency(Dep.DefMI, Dep.DefOp,
1208 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1209 PRMax = std::max(PRMax, PRDepths[K] + PRCycles[K]);
1211 for (
unsigned PRD : PRDepths)
1212 PRMax = std::max(PRMax, PRD);
1215 PRMax = TE.MTM.getCycles(PRMax);
1218 unsigned Instrs = TBI.InstrDepth;
1221 Instrs += TE.MTM.BlockInfo[getBlockNum()].InstrCount;
1222 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1225 return std::max(Instrs, PRMax);
1239 unsigned ResourceIdx)
1241 unsigned Cycles = 0;
1246 PI = TE.MTM.SchedModel.getWriteProcResBegin(SC),
1247 PE = TE.MTM.SchedModel.getWriteProcResEnd(SC);
1249 if (PI->ProcResourceIdx != ResourceIdx)
1251 Cycles += (PI->ReleaseAtCycle *
1252 TE.MTM.SchedModel.getResourceFactor(ResourceIdx));
1258 for (
unsigned K = 0; K != PRDepths.
size(); ++K) {
1259 unsigned PRCycles = PRDepths[K] + PRHeights[K];
1261 PRCycles += TE.MTM.getProcReleaseAtCycles(
MBB->
getNumber())[K];
1262 PRCycles += extraCycles(ExtraInstrs, K);
1263 PRCycles -= extraCycles(RemoveInstrs, K);
1264 PRMax = std::max(PRMax, PRCycles);
1267 PRMax = TE.MTM.getCycles(PRMax);
1270 unsigned Instrs = TBI.InstrDepth + TBI.InstrHeight;
1273 Instrs += TE.MTM.getResources(
MBB)->InstrCount;
1274 Instrs += ExtraInstrs.
size();
1275 Instrs -= RemoveInstrs.
size();
1276 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1279 return std::max(Instrs, PRMax);
1295 for (
unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
1296 OS <<
" %bb." << i <<
'\t';
1297 BlockInfo[i].print(
OS);
1303 if (hasValidDepth()) {
1304 OS <<
"depth=" << InstrDepth;
1309 OS <<
" head=%bb." << Head;
1310 if (HasValidInstrDepths)
1313 OS <<
"depth invalid";
1315 if (hasValidHeight()) {
1316 OS <<
"height=" << InstrHeight;
1321 OS <<
" tail=%bb." <<
Tail;
1322 if (HasValidInstrHeights)
1325 OS <<
"height invalid";
1326 if (HasValidInstrDepths && HasValidInstrHeights)
1327 OS <<
", crit=" << CriticalPath;
1331 unsigned MBBNum = &TBI - &TE.BlockInfo[0];
1333 OS << TE.getName() <<
" trace %bb." << TBI.Head <<
" --> %bb." << MBBNum
1334 <<
" --> %bb." << TBI.Tail <<
':';
1335 if (TBI.hasValidHeight() && TBI.hasValidDepth())
1336 OS <<
' ' << getInstrCount() <<
" instrs.";
1337 if (TBI.HasValidInstrDepths && TBI.HasValidInstrHeights)
1338 OS <<
' ' << TBI.CriticalPath <<
" cycles.";
1341 OS <<
"\n%bb." << MBBNum;
1342 while (
Block->hasValidDepth() &&
Block->Pred) {
1343 unsigned Num =
Block->Pred->getNumber();
1345 Block = &TE.BlockInfo[Num];
1350 while (
Block->hasValidHeight() &&
Block->Succ) {
1351 unsigned Num =
Block->Succ->getNumber();
1353 Block = &TE.BlockInfo[Num];
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
bbsections Prepares for basic block by splitting functions into clusters of basic blocks
BlockVerifier::State From
COFF::MachineTypes Machine
static unsigned InstrCount
This file defines the DenseMap class.
DenseMap< Block *, BlockRelaxAux > Blocks
unsigned const TargetRegisterInfo * TRI
static bool pushDepHeight(const DataDep &Dep, const MachineInstr &UseMI, unsigned UseHeight, MIHeightMap &Heights, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII)
static void getPHIDeps(const MachineInstr &UseMI, SmallVectorImpl< DataDep > &Deps, const MachineBasicBlock *Pred, const MachineRegisterInfo *MRI)
static bool getDataDeps(const MachineInstr &UseMI, SmallVectorImpl< DataDep > &Deps, const MachineRegisterInfo *MRI)
static void updatePhysDepsDownwards(const MachineInstr *UseMI, SmallVectorImpl< DataDep > &Deps, SparseSet< LiveRegUnit > &RegUnits, const TargetRegisterInfo *TRI)
static unsigned updatePhysDepsUpwards(const MachineInstr &MI, unsigned Height, SparseSet< LiveRegUnit > &RegUnits, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
static bool isExitingLoop(const MachineLoop *From, const MachineLoop *To)
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This file defines the SparseSet class derived from the version described in Briggs,...
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
This class represents an Operation in the Expression.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
A possibly irreducible generalization of a Loop.
BlockT * getHeader() const
Represents a single loop in the control flow graph.
Wrapper class representing physical registers. Should be passed by value.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
iterator_range< succ_iterator > successors()
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
iterator_range< pred_iterator > predecessors()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
Register getReg(unsigned Idx) const
Get the register for the operand index.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
iterator_range< mop_iterator > operands()
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Register getReg() const
getReg - Returns the register number.
reg_begin/reg_end - Provide iteration support to walk over all definitions and uses of a register wit...
unsigned getOperandNo() const
getOperandNo - Return the operand # of this MachineOperand in its MachineInstr.
bool atEnd() const
atEnd - return true if this iterator is equal to reg_end() on the value.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A trace ensemble is a collection of traces selected using the same strategy, for example 'minimum res...
void invalidate(const MachineBasicBlock *MBB)
Invalidate traces through BadMBB.
ArrayRef< unsigned > getProcResourceHeights(unsigned MBBNum) const
Get an array of processor resource heights for MBB.
void updateDepth(TraceBlockInfo &TBI, const MachineInstr &, SparseSet< LiveRegUnit > &RegUnits)
Updates the depth of an machine instruction, given RegUnits.
const MachineLoop * getLoopFor(const MachineBasicBlock *) const
const TraceBlockInfo * getHeightResources(const MachineBasicBlock *) const
void updateDepths(MachineBasicBlock::iterator Start, MachineBasicBlock::iterator End, SparseSet< LiveRegUnit > &RegUnits)
Updates the depth of the instructions from Start to End.
const TraceBlockInfo * getDepthResources(const MachineBasicBlock *) const
ArrayRef< unsigned > getProcResourceDepths(unsigned MBBNum) const
Get an array of processor resource depths for MBB.
Ensemble(MachineTraceMetrics *)
MachineTraceMetrics & MTM
void print(raw_ostream &) const
Trace getTrace(const MachineBasicBlock *MBB)
Get the trace that passes through MBB.
A trace represents a plausible sequence of executed basic blocks that passes through the current basi...
unsigned getInstrSlack(const MachineInstr &MI) const
Return the slack of MI.
bool isDepInTrace(const MachineInstr &DefMI, const MachineInstr &UseMI) const
A dependence is useful if the basic block of the defining instruction is part of the trace of the use...
unsigned getResourceLength(ArrayRef< const MachineBasicBlock * > Extrablocks=std::nullopt, ArrayRef< const MCSchedClassDesc * > ExtraInstrs=std::nullopt, ArrayRef< const MCSchedClassDesc * > RemoveInstrs=std::nullopt) const
Return the resource length of the trace.
unsigned getPHIDepth(const MachineInstr &PHI) const
Return the Depth of a PHI instruction in a trace center block successor.
void print(raw_ostream &) const
unsigned getResourceDepth(bool Bottom) const
Return the resource depth of the top/bottom of the trace center block.
Ensemble * getEnsemble(MachineTraceStrategy)
Get the trace ensemble representing the given trace selection strategy.
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void invalidate(const MachineBasicBlock *MBB)
Invalidate cached information about MBB.
void getAnalysisUsage(AnalysisUsage &) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
const FixedBlockInfo * getResources(const MachineBasicBlock *)
Get the fixed resource information about MBB. Compute it on demand.
ArrayRef< unsigned > getProcReleaseAtCycles(unsigned MBBNum) const
Get the scaled number of cycles used per processor resource in MBB.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
SparseSet - Fast set implementation for objects that can be identified by small unsigned keys.
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
typename DenseT::iterator iterator
const_iterator end() const
void setUniverse(unsigned U)
setUniverse - Set the universe size which determines the largest key the set can hold.
iterator find(const KeyT &Key)
find - Find an element by its key.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Provide an instruction scheduling machine model to CodeGen passes.
ProcResIter getWriteProcResEnd(const MCSchedClassDesc *SC) const
bool hasInstrSchedModel() const
Return true if this machine model includes an instruction-level scheduling model.
unsigned getResourceFactor(unsigned ResIdx) const
Multiply the number of units consumed for a resource by this factor to normalize it relative to other...
const MCSchedClassDesc * resolveSchedClass(const MachineInstr *MI) const
Return the MCSchedClassDesc for this instruction.
void init(const TargetSubtargetInfo *TSInfo)
Initialize the machine model for instruction scheduling.
unsigned computeOperandLatency(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const
Compute operand latency based on the available machine model.
unsigned getNumProcResourceKinds() const
Get the number of kinds of resources for this target.
ProcResIter getWriteProcResBegin(const MCSchedClassDesc *SC) const
TargetSubtargetInfo - Generic base class for all target subtargets.
bool insertEdge(std::optional< const MachineBasicBlock * > From, const MachineBasicBlock *To)
void finishPostorder(const MachineBasicBlock *)
po_iterator_storage(LoopBounds &lb)
Default po_iterator_storage implementation with an internal set object.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
MachineTraceStrategy
Strategies for selecting traces.
@ TS_MinInstrCount
Select the trace through a block that has the fewest instructions.
@ TS_Local
Select the trace that contains only the current basic block.
iterator_range< po_ext_iterator< T, SetType > > post_order_ext(const T &G, SetType &S)
iterator_range< ipo_ext_iterator< T, SetType > > inverse_post_order_ext(const T &G, SetType &S)
Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
auto reverse(ContainerTy &&C)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
char & MachineTraceMetricsID
MachineTraceMetrics - This pass computes critical path and CPU resource usage in an ensemble of trace...
DWARFExpression::Operation Op
OutputIt copy(R &&Range, OutputIt Out)
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
void addLiveIns(MachineBasicBlock &MBB, const LivePhysRegs &LiveRegs)
Adds registers contained in LiveRegs to the block live-in list of MBB.
Summarize the scheduling resources required for an instruction of a particular scheduling class.
Identify one of the processor resource kinds consumed by a particular scheduling class for the specif...
Per-basic block information that doesn't depend on the trace through the block.
bool hasResources() const
Returns true when resource information for this block has been computed.
unsigned InstrCount
The number of non-trivial instructions in the block.
bool HasCalls
True when the block contains calls.
InstrCycles represents the cycle height and depth of an instruction in a trace.
unsigned Height
Minimum number of cycles from this instruction is issued to the of the trace, as determined by data d...
unsigned Depth
Earliest issue cycle as determined by data dependencies and instruction latencies from the beginning ...
Per-basic block information that relates to a specific trace through the block.
unsigned InstrDepth
Accumulated number of instructions in the trace above this block.
void invalidateDepth()
Invalidate depth resources when some block above this one has changed.
const MachineBasicBlock * Pred
Trace predecessor, or NULL for the first block in the trace.
unsigned InstrHeight
Accumulated number of instructions in the trace below this block.
const MachineBasicBlock * Succ
Trace successor, or NULL for the last block in the trace.
bool hasValidDepth() const
Returns true if the depth resources have been computed from the trace above this block.
bool isUsefulDominator(const TraceBlockInfo &TBI) const
Assuming that this is a dominator of TBI, determine if it contains useful instruction depths.
void invalidateHeight()
Invalidate height resources when a block below this one has changed.
unsigned CriticalPath
Critical path length.
void print(raw_ostream &) const
unsigned Head
The block number of the head of the trace. (When hasValidDepth()).
bool HasValidInstrDepths
Instruction depths have been computed. This implies hasValidDepth().
bool hasValidHeight() const
Returns true if the height resources have been computed from the trace below this block.
bool HasValidInstrHeights
Instruction heights have been computed. This implies hasValidHeight().