42 #define DEBUG_TYPE "machine-trace-metrics"
48 "Machine Trace Metrics",
false,
true)
71 Loops = &getAnalysis<MachineLoopInfo>();
84 Ensembles[i] =
nullptr;
98 assert(MBB &&
"No basic block");
111 for (
const auto &
MI : *MBB) {
112 if (
MI.isTransient())
128 assert(PI->ProcResourceIdx < PRKinds &&
"Bad processor resource kind");
129 PRCycles[PI->ProcResourceIdx] += PI->Cycles;
135 unsigned PROffset = MBB->getNumber() * PRKinds;
136 for (
unsigned K = 0; K != PRKinds; ++K)
137 ProcResourceCycles[PROffset + K] =
145 assert(BlockInfo[MBBNum].hasResources() &&
146 "getResources() must be called before getProcResourceCycles()");
148 assert((MBBNum+1) * PRKinds <= ProcResourceCycles.
size());
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);
174 void MachineTraceMetrics::Ensemble::
177 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
178 unsigned PROffset = MBB->
getNumber() * PRKinds;
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];
207 void MachineTraceMetrics::Ensemble::
209 TraceBlockInfo *TBI = &BlockInfo[MBB->
getNumber()];
210 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
211 unsigned PROffset = MBB->
getNumber() * PRKinds;
214 TBI->InstrHeight = MTM.getResources(MBB)->InstrCount;
220 std::copy(PRCycles.
begin(), PRCycles.
end(),
221 ProcResourceHeights.begin() + PROffset);
227 unsigned SuccNum = TBI->Succ->getNumber();
228 TraceBlockInfo *SuccTBI = &BlockInfo[SuccNum];
229 assert(SuccTBI->hasValidHeight() &&
"Trace below has not been computed yet");
230 TBI->InstrHeight += SuccTBI->InstrHeight;
231 TBI->Tail = SuccTBI->Tail;
235 for (
unsigned K = 0; K != PRKinds; ++K)
236 ProcResourceHeights[PROffset + K] = SuccPRHeights[K] + PRCycles[K];
266 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
267 assert((MBBNum+1) * PRKinds <= ProcResourceDepths.size());
268 return makeArrayRef(ProcResourceDepths.data() + MBBNum * PRKinds, PRKinds);
279 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
280 assert((MBBNum+1) * PRKinds <= ProcResourceHeights.size());
281 return makeArrayRef(ProcResourceHeights.data() + MBBNum * PRKinds, PRKinds);
313 const char *
getName()
const override {
return "MinInstr"; }
331 if (CurLoop && MBB == CurLoop->
getHeader())
333 unsigned CurCount = MTM.getResources(MBB)->InstrCount;
335 unsigned BestDepth = 0;
338 getDepthResources(Pred);
344 if (!Best || Depth < BestDepth) {
359 unsigned BestHeight = 0;
362 if (CurLoop && Succ == CurLoop->
getHeader())
368 getHeightResources(Succ);
374 if (!Best || Height < BestHeight) {
399 BlockInfo[MBB->
getNumber()].invalidate();
430 bool Downward =
false;
459 if (
const MachineLoop *FromLoop = LB.Loops->getLoopFor(*From)) {
461 if ((LB.Downward ? To : *From) == FromLoop->getHeader())
470 return LB.Visited.insert(To).second;
481 LoopBounds Bounds(BlockInfo, MTM.Loops);
484 Bounds.Downward =
false;
485 Bounds.Visited.clear();
487 DEBUG(
dbgs() <<
" pred for BB#" <<
I->getNumber() <<
": ");
488 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
490 TBI.Pred = pickTracePred(
I);
493 dbgs() <<
"BB#" << TBI.Pred->getNumber() <<
'\n';
498 computeDepthResources(
I);
502 Bounds.Downward =
true;
503 Bounds.Visited.clear();
505 DEBUG(
dbgs() <<
" succ for BB#" <<
I->getNumber() <<
": ");
506 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
508 TBI.Succ = pickTraceSucc(
I);
511 dbgs() <<
"BB#" << TBI.Succ->getNumber() <<
'\n';
516 computeHeightResources(
I);
540 if (TBI.
Succ == MBB) {
548 }
while (!WorkList.
empty());
565 if (TBI.
Pred == MBB) {
573 }
while (!WorkList.
empty());
581 for (
const auto &
I : *BadMBB)
587 assert(BlockInfo.size() == MTM.MF->getNumBlockIDs() &&
588 "Outdated BlockInfo size");
589 for (
unsigned Num = 0, e = BlockInfo.size(); Num != e; ++Num) {
595 "Trace is broken, depth should have been invalidated.");
597 assert(!(Loop && MBB == Loop->getHeader()) &&
"Trace contains backedge");
603 "Trace is broken, height should have been invalidated.");
606 assert(!(Loop && Loop == SuccLoop && TBI.
Succ == Loop->getHeader()) &&
607 "Trace contains backedge");
631 DataDep(
const MachineInstr *DefMI,
unsigned DefOp,
unsigned UseOp)
632 : DefMI(DefMI), DefOp(DefOp), UseOp(UseOp) {}
642 assert((++DefI).atEnd() &&
"Register has multiple defs");
657 bool HasPhysRegs =
false;
709 unsigned getSparseSetIndex()
const {
return RegUnit; }
711 LiveRegUnit(
unsigned RU) : RegUnit(RU) {}
746 if (I == RegUnits.
end())
755 for (
unsigned Kill : Kills)
757 RegUnits.
erase(*Units);
760 for (
unsigned DefOp : LiveDefOps) {
763 LiveRegUnit &LRU = RegUnits[*Units];
781 unsigned MachineTraceMetrics::Ensemble::
782 computeCrossBlockCriticalPath(
const TraceBlockInfo &TBI) {
783 assert(TBI.HasValidInstrDepths &&
"Missing depth info");
784 assert(TBI.HasValidInstrHeights &&
"Missing height info");
786 for (
const LiveInReg &LIR : TBI.LiveIns) {
789 const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
792 if (!DefTBI.isUsefulDominator(TBI))
794 unsigned Len = LIR.Height + Cycles[DefMI].Depth;
802 void MachineTraceMetrics::Ensemble::
809 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
810 assert(TBI.hasValidDepth() &&
"Incomplete trace");
811 if (TBI.HasValidInstrDepths)
826 while (!Stack.
empty()) {
829 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
830 TBI.HasValidInstrDepths =
true;
831 TBI.CriticalPath = 0;
835 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrDepth);
837 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
839 unsigned Factor = MTM.SchedModel.getResourceFactor(K);
840 dbgs() <<
format(
"%6uc @ ", MTM.getCycles(PRDepths[K]))
841 << MTM.SchedModel.getProcResource(K)->Name <<
" ("
842 << PRDepths[K]/Factor <<
" ops x" << Factor <<
")\n";
847 if (TBI.HasValidInstrHeights)
848 TBI.CriticalPath = computeCrossBlockCriticalPath(TBI);
850 for (
const auto &
UseMI : *MBB) {
860 for (
const DataDep &Dep : Deps) {
861 const TraceBlockInfo&DepTBI =
862 BlockInfo[Dep.DefMI->getParent()->getNumber()];
864 if (!DepTBI.isUsefulDominator(TBI))
866 assert(DepTBI.HasValidInstrDepths &&
"Inconsistent dependency");
867 unsigned DepCycle = Cycles.lookup(Dep.DefMI).Depth;
869 if (!Dep.DefMI->isTransient())
870 DepCycle += MTM.SchedModel
871 .computeOperandLatency(Dep.DefMI, Dep.DefOp, &
UseMI, Dep.UseOp);
875 InstrCycles &MICycles = Cycles[&
UseMI];
876 MICycles.Depth = Cycle;
878 if (!TBI.HasValidInstrHeights) {
883 TBI.CriticalPath =
std::max(TBI.CriticalPath, Cycle + MICycles.Height);
884 DEBUG(
dbgs() << TBI.CriticalPath <<
'\t' << Cycle <<
'\t' <<
UseMI);
916 if (I == RegUnits.
end())
918 unsigned DepHeight = I->Cycle;
925 Height =
std::max(Height, DepHeight);
932 for (
unsigned i = 0, e = ReadOps.
size(); i != e; ++i) {
935 LiveRegUnit &LRU = RegUnits[*Units];
937 if (LRU.Cycle <= Height && LRU.MI != &MI) {
957 if (!Dep.DefMI->isTransient())
964 std::tie(I, New) = Heights.
insert(std::make_pair(Dep.DefMI, UseHeight));
969 if (I->second < UseHeight)
970 I->second = UseHeight;
977 void MachineTraceMetrics::Ensemble::
980 assert(!Trace.
empty() &&
"Trace should contain at least one block");
986 for (
unsigned i = Trace.
size(); i; --i) {
990 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
992 TBI.LiveIns.push_back(Reg);
999 void MachineTraceMetrics::Ensemble::
1005 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1006 assert(TBI.hasValidHeight() &&
"Incomplete trace");
1007 if (TBI.HasValidInstrHeights)
1010 TBI.LiveIns.clear();
1027 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1028 for (LiveInReg &LI : TBI.LiveIns) {
1031 unsigned &Height = Heights[MTM.MRI->getVRegDef(LI.Reg)];
1032 if (Height < LI.Height)
1037 RegUnits[LI.Reg].Cycle = LI.Height;
1047 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1048 TBI.HasValidInstrHeights =
true;
1049 TBI.CriticalPath = 0;
1052 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrHeight);
1054 for (
unsigned K = 0; K != PRHeights.
size(); ++K)
1056 unsigned Factor = MTM.SchedModel.getResourceFactor(K);
1057 dbgs() <<
format(
"%6uc @ ", MTM.getCycles(PRHeights[K]))
1058 << MTM.SchedModel.getProcResource(K)->Name <<
" ("
1059 << PRHeights[K]/Factor <<
" ops x" << Factor <<
")\n";
1074 for (
const auto &PHI : *Succ) {
1079 if (!Deps.
empty()) {
1081 unsigned Height = TBI.Succ ? Cycles.lookup(&PHI).Height : 0;
1082 DEBUG(
dbgs() <<
"pred\t" << Height <<
'\t' << PHI);
1085 addLiveIns(Deps.
front().DefMI, Deps.
front().DefOp, Stack);
1099 if (HeightI != Heights.
end()) {
1100 Cycle = HeightI->second;
1102 Heights.
erase(HeightI);
1116 for (
const DataDep &Dep : Deps)
1117 if (
pushDepHeight(Dep, MI, Cycle, Heights, MTM.SchedModel, MTM.TII))
1118 addLiveIns(Dep.DefMI, Dep.DefOp, Stack);
1120 InstrCycles &MICycles = Cycles[&
MI];
1121 MICycles.Height = Cycle;
1122 if (!TBI.HasValidInstrDepths) {
1127 TBI.CriticalPath =
std::max(TBI.CriticalPath, Cycle + MICycles.Depth);
1128 DEBUG(
dbgs() << TBI.CriticalPath <<
'\t' << Cycle <<
'\t' << MI);
1134 for (LiveInReg &LIR : TBI.LiveIns) {
1135 const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
1136 LIR.Height = Heights.
lookup(DefMI);
1142 RI = RegUnits.
begin(), RE = RegUnits.
end(); RI != RE; ++RI) {
1143 TBI.LiveIns.push_back(LiveInReg(RI->RegUnit, RI->Cycle));
1145 <<
'@' << RI->Cycle);
1149 if (!TBI.HasValidInstrDepths)
1152 TBI.CriticalPath =
std::max(TBI.CriticalPath,
1153 computeCrossBlockCriticalPath(TBI));
1154 DEBUG(
dbgs() <<
"Critical path: " << TBI.CriticalPath <<
'\n');
1165 computeInstrDepths(MBB);
1167 computeInstrHeights(MBB);
1169 return Trace(*
this, TBI);
1175 "MI must be in the trace center block");
1177 return getCriticalPath() - (Cyc.
Depth + Cyc.
Height);
1185 assert(Deps.
size() == 1 &&
"PHI doesn't have MBB as a predecessor");
1186 DataDep &Dep = Deps.
front();
1187 unsigned DepCycle = getInstrCycles(*Dep.DefMI).Depth;
1189 if (!Dep.DefMI->isTransient())
1190 DepCycle += TE.MTM.SchedModel.computeOperandLatency(Dep.DefMI, Dep.DefOp,
1203 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1204 PRMax =
std::max(PRMax, PRDepths[K] + PRCycles[K]);
1206 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1207 PRMax =
std::max(PRMax, PRDepths[K]);
1210 PRMax = TE.MTM.getCycles(PRMax);
1213 unsigned Instrs = TBI.InstrDepth;
1216 Instrs += TE.MTM.BlockInfo[getBlockNum()].InstrCount;
1217 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1234 unsigned ResourceIdx)
1236 unsigned Cycles = 0;
1241 PI = TE.MTM.SchedModel.getWriteProcResBegin(
SC),
1242 PE = TE.MTM.SchedModel.getWriteProcResEnd(
SC);
1244 if (PI->ProcResourceIdx != ResourceIdx)
1247 (PI->Cycles * TE.MTM.SchedModel.getResourceFactor(ResourceIdx));
1253 for (
unsigned K = 0; K != PRDepths.
size(); ++K) {
1254 unsigned PRCycles = PRDepths[K] + PRHeights[K];
1256 PRCycles += TE.MTM.getProcResourceCycles(MBB->
getNumber())[K];
1257 PRCycles += extraCycles(ExtraInstrs, K);
1258 PRCycles -= extraCycles(RemoveInstrs, K);
1262 PRMax = TE.MTM.getCycles(PRMax);
1265 unsigned Instrs = TBI.InstrDepth + TBI.InstrHeight;
1268 Instrs += TE.MTM.getResources(MBB)->InstrCount;
1269 Instrs += ExtraInstrs.
size();
1270 Instrs -= RemoveInstrs.
size();
1271 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1289 OS <<
getName() <<
" ensemble:\n";
1290 for (
unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
1291 OS <<
" BB#" << i <<
'\t';
1292 BlockInfo[i].print(OS);
1298 if (hasValidDepth()) {
1299 OS <<
"depth=" << InstrDepth;
1301 OS <<
" pred=BB#" << Pred->getNumber();
1304 OS <<
" head=BB#" << Head;
1305 if (HasValidInstrDepths)
1308 OS <<
"depth invalid";
1310 if (hasValidHeight()) {
1311 OS <<
"height=" << InstrHeight;
1313 OS <<
" succ=BB#" << Succ->getNumber();
1316 OS <<
" tail=BB#" << Tail;
1317 if (HasValidInstrHeights)
1320 OS <<
"height invalid";
1321 if (HasValidInstrDepths && HasValidInstrHeights)
1322 OS <<
", crit=" << CriticalPath;
1326 unsigned MBBNum = &TBI - &TE.BlockInfo[0];
1328 OS << TE.getName() <<
" trace BB#" << TBI.Head <<
" --> BB#" << MBBNum
1329 <<
" --> BB#" << TBI.Tail <<
':';
1330 if (TBI.hasValidHeight() && TBI.hasValidDepth())
1331 OS <<
' ' << getInstrCount() <<
" instrs.";
1332 if (TBI.HasValidInstrDepths && TBI.HasValidInstrHeights)
1333 OS <<
' ' << TBI.CriticalPath <<
" cycles.";
1336 OS <<
"\nBB#" << MBBNum;
1339 OS <<
" <- BB#" << Num;
1340 Block = &TE.BlockInfo[Num];
1347 OS <<
" -> BB#" << Num;
1348 Block = &TE.BlockInfo[Num];
void print(raw_ostream &) const
void push_back(const T &Elt)
bool HasValidInstrDepths
Instruction depths have been computed. This implies hasValidDepth().
const_iterator end(StringRef path)
Get end iterator over path.
mop_iterator operands_end()
const MCSchedClassDesc * resolveSchedClass(const MachineInstr *MI) const
Return the MCSchedClassDesc for this instruction.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
ArrayRef< unsigned > getProcResourceDepths(unsigned MBBNum) const
Get an array of processor resource depths for MBB.
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...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
void print(raw_ostream &) const
void print(raw_ostream &) const
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
MachineBasicBlock * getMBB() const
bool atEnd() const
atEnd - return true if this iterator is equal to reg_end() on the value.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
const MachineBasicBlock * Pred
Trace predecessor, or NULL for the first block in the trace.
unsigned Depth
Earliest issue cycle as determined by data dependencies and instruction latencies from the beginning ...
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool HasCalls
True when the block contains calls.
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
void init(const MCSchedModel &sm, const TargetSubtargetInfo *sti, const TargetInstrInfo *tii)
Initialize the machine model for instruction scheduling.
void invalidateHeight()
Invalidate height resources when a block below this one has changed.
A trace ensemble is a collection of traces selected using the same strategy, for example 'minimum res...
unsigned getResourceFactor(unsigned ResIdx) const
Multiply the number of units consumed for a resource by this factor to normalize it relative to other...
static unsigned InstrCount
po_iterator_storage(LoopBounds &lb)
BlockT * getHeader() const
unsigned InstrCount
The number of non-trivial instructions in the block.
iterator_range< succ_iterator > successors()
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Provide an instruction scheduling machine model to CodeGen passes.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
const MachineLoop * getLoopFor(const MachineBasicBlock *) const
Strategy
Strategies for selecting traces.
bool isUsefulDominator(const TraceBlockInfo &TBI) const
Assuming that this is a dominator of TBI, determine if it contains useful instruction depths...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const_iterator end() const
Reg
All possible values of the reg field in the ModR/M byte.
static StringRef getName(Value *V)
INITIALIZE_PASS_BEGIN(MachineTraceMetrics, DEBUG_TYPE,"Machine Trace Metrics", false, true) INITIALIZE_PASS_END(MachineTraceMetrics
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
const MCSchedModel & getSchedModel() const
Get the machine model for this subtarget's CPU.
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Select the trace through a block that has the fewest instructions.
const TraceBlockInfo * getHeightResources(const MachineBasicBlock *) const
void finishPostorder(const MachineBasicBlock *)
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
size_t size() const
size - Get the array size.
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
const MachineBasicBlock * getParent() const
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
bool isDebugValue() const
void invalidateDepth()
Invalidate depth resources when some block above this one has changed.
void invalidate(const MachineBasicBlock *MBB)
Invalidate traces through BadMBB.
bool erase(const KeyT &Val)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
bool HasValidInstrHeights
Instruction heights have been computed. This implies hasValidHeight().
bool insertEdge(Optional< const MachineBasicBlock * > From, const MachineBasicBlock *To)
typename DenseT::iterator iterator
unsigned InstrHeight
Accumulated number of instructions in the trace below this block.
Ensemble * getEnsemble(Strategy)
Get the trace ensemble representing the given trace selection strategy.
typename DenseT::const_iterator const_iterator
Identify one of the processor resource kinds consumed by a particular scheduling class for the specif...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
MachineInstrBuilder & UseMI
Ensemble(MachineTraceMetrics *)
MachineTraceMetrics & MTM
const MachineOperand & getOperand(unsigned i) const
Summarize the scheduling resources required for an instruction of a particular scheduling class...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
unsigned getOperandNo() const
getOperandNo - Return the operand # of this MachineOperand in its MachineInstr.
Per-basic block information that doesn't depend on the trace through the block.
unsigned getResourceLength(ArrayRef< const MachineBasicBlock * > Extrablocks=None, ArrayRef< const MCSchedClassDesc * > ExtraInstrs=None, ArrayRef< const MCSchedClassDesc * > RemoveInstrs=None) const
Return the resource length of the trace.
Represent the analysis usage information of a pass.
const MachineBasicBlock * Succ
Trace successor, or NULL for the last block in the trace.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
Default po_iterator_storage implementation with an internal set object.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
const FixedBlockInfo * getResources(const MachineBasicBlock *)
Get the fixed resource information about MBB. Compute it on demand.
void setUniverse(unsigned U)
setUniverse - Set the universe size which determines the largest key the set can hold.
iterator_range< pred_iterator > predecessors()
bool empty() const
empty - Check if the array is empty.
unsigned getNumProcResourceKinds() const
Get the number of kinds of resources for this target.
const TraceBlockInfo * getDepthResources(const MachineBasicBlock *) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
A trace represents a plausible sequence of executed basic blocks that passes through the current basi...
const_iterator begin() const
ProcResIter getWriteProcResEnd(const MCSchedClassDesc *SC) const
static void updatePhysDepsDownwards(const MachineInstr *UseMI, SmallVectorImpl< DataDep > &Deps, SparseSet< LiveRegUnit > &RegUnits, const TargetRegisterInfo *TRI)
ArrayRef< unsigned > getProcResourceHeights(unsigned MBBNum) const
Get an array of processor resource heights for MBB.
bool hasInstrSchedModel() const
Return true if this machine model includes an instruction-level scheduling model. ...
Printable PrintRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
MachineOperand class - Representation of each machine instruction operand.
unsigned Height
Minimum number of cycles from this instruction is issued to the of the trace, as determined by data d...
unsigned getPHIDepth(const MachineInstr &PHI) const
Return the Depth of a PHI instruction in a trace center block successor.
bool hasValidDepth() const
Returns true if the depth resources have been computed from the trace above this block.
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
LLVM_NODISCARD T pop_back_val()
CHAIN = SC CHAIN, Imm128 - System call.
iterator_range< po_ext_iterator< T, SetType > > post_order_ext(const T &G, SetType &S)
char & MachineTraceMetricsID
MachineTraceMetrics - This pass computes critical path and CPU resource usage in an ensemble of trace...
bool isTransient() const
Return true if this is a transient instruction that is either very likely to be eliminated during reg...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Per-basic block information that relates to a specific trace through the block.
void setPreservesAll()
Set by analyses that do not transform their input at all.
void invalidate(const MachineBasicBlock *MBB)
Invalidate cached information about MBB.
unsigned Head
The block number of the head of the trace. (When hasValidDepth()).
def_iterator def_begin(unsigned RegNo) const
static bool pushDepHeight(const DataDep &Dep, const MachineInstr &UseMI, unsigned UseHeight, MIHeightMap &Heights, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII)
llvm_unreachable("Unknown RegBank!")
bool hasResources() const
Returns true when resource information for this block has been computed.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
iterator_range< ipo_ext_iterator< T, SetType > > inverse_post_order_ext(const T &G, SetType &S)
static void getPHIDeps(const MachineInstr &UseMI, SmallVectorImpl< DataDep > &Deps, const MachineBasicBlock *Pred, const MachineRegisterInfo *MRI)
unsigned getInstrSlack(const MachineInstr &MI) const
Return the slack of MI.
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
pointer data()
Return a pointer to the vector's buffer, even if empty().
SparseSet - Fast set implmentation for objects that can be identified by small unsigned keys...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Represents a single loop in the control flow graph.
iterator find(const KeyT &Key)
find - Find an element by its key.
InstrCycles represents the cycle height and depth of an instruction in a trace.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
static bool isExitingLoop(const MachineLoop *From, const MachineLoop *To)
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool hasValidHeight() const
Returns true if the height resources have been computed from the trace below this block...
unsigned computeOperandLatency(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const
Compute operand latency based on the available machine model.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const TargetInstrInfo * getInstrInfo() const
mop_iterator operands_begin()
unsigned getResourceDepth(bool Bottom) const
Return the resource depth of the top/bottom of the trace center block.
unsigned InstrDepth
Accumulated number of instructions in the trace above this block.
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...
This class implements an extremely fast bulk output stream that can only output to a stream...
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
ArrayRef< unsigned > getProcResourceCycles(unsigned MBBNum) const
Get the scaled number of cycles used per processor resource in MBB.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
ProcResIter getWriteProcResBegin(const MCSchedClassDesc *SC) const
reg_begin/reg_end - Provide iteration support to walk over all definitions and uses of a register wit...
static bool getDataDeps(const MachineInstr &UseMI, SmallVectorImpl< DataDep > &Deps, const MachineRegisterInfo *MRI)
DenseMap< const MachineInstr *, unsigned > MIHeightMap
static unsigned updatePhysDepsUpwards(const MachineInstr &MI, unsigned Height, SparseSet< LiveRegUnit > &RegUnits, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
Trace getTrace(const MachineBasicBlock *MBB)
Get the trace that passes through MBB.
void getAnalysisUsage(AnalysisUsage &) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.