42 #define DEBUG_TYPE "machine-trace-metrics" 49 "Machine Trace Metrics",
false,
true)
72 Loops = &getAnalysis<MachineLoopInfo>();
85 Ensembles[i] =
nullptr;
99 assert(MBB &&
"No basic block");
112 for (
const auto &
MI : *MBB) {
113 if (
MI.isTransient())
129 assert(PI->ProcResourceIdx < PRKinds &&
"Bad processor resource kind");
130 PRCycles[PI->ProcResourceIdx] += PI->Cycles;
136 unsigned PROffset = MBB->getNumber() * PRKinds;
137 for (
unsigned K = 0; K != PRKinds; ++K)
138 ProcResourceCycles[PROffset + K] =
146 assert(BlockInfo[MBBNum].hasResources() &&
147 "getResources() must be called before getProcResourceCycles()");
149 assert((MBBNum+1) * PRKinds <= ProcResourceCycles.
size());
159 BlockInfo.resize(
MTM.BlockInfo.size());
161 ProcResourceDepths.
resize(
MTM.BlockInfo.size() * PRKinds);
162 ProcResourceHeights.
resize(
MTM.BlockInfo.size() * PRKinds);
175 void MachineTraceMetrics::Ensemble::
179 unsigned PROffset = MBB->
getNumber() * PRKinds;
185 std::fill(ProcResourceDepths.
begin() + PROffset,
186 ProcResourceDepths.
begin() + PROffset + PRKinds, 0);
202 for (
unsigned K = 0; K != PRKinds; ++K)
203 ProcResourceDepths[PROffset + K] = PredPRDepths[K] + PredPRCycles[K];
208 void MachineTraceMetrics::Ensemble::
212 unsigned PROffset = MBB->
getNumber() * PRKinds;
222 ProcResourceHeights.
begin() + PROffset);
236 for (
unsigned K = 0; K != PRKinds; ++K)
237 ProcResourceHeights[PROffset + K] = SuccPRHeights[K] + PRCycles[K];
268 assert((MBBNum+1) * PRKinds <= ProcResourceDepths.
size());
281 assert((MBBNum+1) * PRKinds <= ProcResourceHeights.
size());
282 return makeArrayRef(ProcResourceHeights.
data() + MBBNum * PRKinds, PRKinds);
314 const char *
getName()
const override {
return "MinInstr"; }
332 if (CurLoop && MBB == CurLoop->
getHeader())
336 unsigned BestDepth = 0;
345 if (!Best || Depth < BestDepth) {
360 unsigned BestHeight = 0;
363 if (CurLoop && Succ == CurLoop->
getHeader())
375 if (!Best || Height < BestHeight) {
401 BlockInfo[MBB->
getNumber()].invalidate();
404 Ensembles[i]->invalidate(MBB);
411 assert(BlockInfo.size() == MF->getNumBlockIDs() &&
"Outdated BlockInfo size");
414 Ensembles[i]->verify();
432 bool Downward =
false;
461 if (
const MachineLoop *FromLoop = LB.Loops->getLoopFor(*From)) {
463 if ((LB.Downward ? To : *From) == FromLoop->getHeader())
472 return LB.Visited.insert(To).second;
483 LoopBounds Bounds(BlockInfo,
MTM.Loops);
486 Bounds.Downward =
false;
487 Bounds.Visited.clear();
490 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
500 computeDepthResources(
I);
504 Bounds.Downward =
true;
505 Bounds.Visited.clear();
508 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
518 computeHeightResources(
I);
542 if (TBI.
Succ == MBB) {
550 }
while (!WorkList.
empty());
567 if (TBI.
Pred == MBB) {
575 }
while (!WorkList.
empty());
583 for (
const auto &
I : *BadMBB)
590 "Outdated BlockInfo size");
591 for (
unsigned Num = 0, e = BlockInfo.size(); Num != e; ++Num) {
597 "Trace is broken, depth should have been invalidated.");
599 assert(!(Loop && MBB == Loop->getHeader()) &&
"Trace contains backedge");
605 "Trace is broken, height should have been invalidated.");
608 assert(!(Loop && Loop == SuccLoop && TBI.
Succ == Loop->getHeader()) &&
609 "Trace contains backedge");
633 DataDep(
const MachineInstr *DefMI,
unsigned DefOp,
unsigned UseOp)
634 :
DefMI(DefMI), DefOp(DefOp), UseOp(UseOp) {}
644 assert((++DefI).atEnd() &&
"Register has multiple defs");
659 bool HasPhysRegs =
false;
729 if (I == RegUnits.
end())
738 for (
unsigned Kill : Kills)
740 RegUnits.
erase(*Units);
743 for (
unsigned DefOp : LiveDefOps) {
764 unsigned MachineTraceMetrics::Ensemble::
765 computeCrossBlockCriticalPath(
const TraceBlockInfo &TBI) {
766 assert(TBI.HasValidInstrDepths &&
"Missing depth info");
767 assert(TBI.HasValidInstrHeights &&
"Missing height info");
769 for (
const LiveInReg &LIR : TBI.LiveIns) {
775 if (!DefTBI.isUsefulDominator(TBI))
777 unsigned Len = LIR.Height + Cycles[
DefMI].Depth;
795 for (
const DataDep &Dep : Deps) {
797 BlockInfo[Dep.DefMI->getParent()->getNumber()];
802 unsigned DepCycle = Cycles.lookup(Dep.DefMI).Depth;
804 if (!Dep.DefMI->isTransient())
805 DepCycle +=
MTM.SchedModel
811 MICycles.
Depth = Cycle;
832 for (; Start != End; Start++)
838 void MachineTraceMetrics::Ensemble::
861 while (!Stack.
empty()) {
872 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
877 << PRDepths[K]/Factor <<
" ops x" << Factor <<
")\n";
885 for (
const auto &
UseMI : *MBB) {
918 if (I == RegUnits.
end())
920 unsigned DepHeight = I->Cycle;
927 Height =
std::max(Height, DepHeight);
934 for (
unsigned i = 0, e = ReadOps.
size(); i != e; ++i) {
939 if (LRU.
Cycle <= Height && LRU.
MI != &MI) {
959 if (!Dep.DefMI->isTransient())
966 std::tie(I, New) = Heights.
insert(std::make_pair(Dep.DefMI, UseHeight));
971 if (I->second < UseHeight)
972 I->second = UseHeight;
979 void MachineTraceMetrics::Ensemble::
982 assert(!Trace.
empty() &&
"Trace should contain at least one block");
988 for (
unsigned i = Trace.
size(); i; --i) {
992 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
994 TBI.LiveIns.push_back(Reg);
1001 void MachineTraceMetrics::Ensemble::
1007 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1008 assert(TBI.hasValidHeight() &&
"Incomplete trace");
1009 if (TBI.HasValidInstrHeights)
1012 TBI.LiveIns.clear();
1029 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1030 for (LiveInReg &LI : TBI.LiveIns) {
1034 if (Height < LI.Height)
1039 RegUnits[LI.Reg].Cycle = LI.Height;
1049 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1050 TBI.HasValidInstrHeights =
true;
1051 TBI.CriticalPath = 0;
1054 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrHeight);
1056 for (
unsigned K = 0; K != PRHeights.
size(); ++K)
1061 << PRHeights[K]/Factor <<
" ops x" << Factor <<
")\n";
1076 for (
const auto &PHI : *Succ) {
1081 if (!Deps.
empty()) {
1083 unsigned Height = TBI.Succ ? Cycles.lookup(&PHI).Height : 0;
1101 if (HeightI != Heights.
end()) {
1102 Cycle = HeightI->second;
1104 Heights.
erase(HeightI);
1118 for (
const DataDep &Dep : Deps)
1122 InstrCycles &MICycles = Cycles[&
MI];
1123 MICycles.Height = Cycle;
1124 if (!TBI.HasValidInstrDepths) {
1129 TBI.CriticalPath =
std::max(TBI.CriticalPath, Cycle + MICycles.Depth);
1130 LLVM_DEBUG(
dbgs() << TBI.CriticalPath <<
'\t' << Cycle <<
'\t' << MI);
1136 for (LiveInReg &LIR : TBI.LiveIns) {
1138 LIR.Height = Heights.
lookup(DefMI);
1144 RI = RegUnits.
begin(), RE = RegUnits.
end(); RI != RE; ++RI) {
1145 TBI.LiveIns.push_back(LiveInReg(RI->RegUnit, RI->Cycle));
1151 if (!TBI.HasValidInstrDepths)
1154 TBI.CriticalPath =
std::max(TBI.CriticalPath,
1155 computeCrossBlockCriticalPath(TBI));
1156 LLVM_DEBUG(
dbgs() <<
"Critical path: " << TBI.CriticalPath <<
'\n');
1167 computeInstrDepths(MBB);
1169 computeInstrHeights(MBB);
1171 return Trace(*
this, TBI);
1177 "MI must be in the trace center block");
1179 return getCriticalPath() - (Cyc.
Depth + Cyc.
Height);
1187 assert(Deps.
size() == 1 &&
"PHI doesn't have MBB as a predecessor");
1188 DataDep &Dep = Deps.
front();
1189 unsigned DepCycle = getInstrCycles(*Dep.DefMI).Depth;
1191 if (!Dep.DefMI->isTransient())
1192 DepCycle += TE.MTM.SchedModel.computeOperandLatency(Dep.DefMI, Dep.DefOp,
1205 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1206 PRMax =
std::max(PRMax, PRDepths[K] + PRCycles[K]);
1208 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1209 PRMax =
std::max(PRMax, PRDepths[K]);
1212 PRMax = TE.MTM.getCycles(PRMax);
1215 unsigned Instrs = TBI.InstrDepth;
1218 Instrs += TE.MTM.BlockInfo[getBlockNum()].InstrCount;
1219 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1236 unsigned ResourceIdx)
1238 unsigned Cycles = 0;
1243 PI = TE.MTM.SchedModel.getWriteProcResBegin(
SC),
1244 PE = TE.MTM.SchedModel.getWriteProcResEnd(
SC);
1246 if (PI->ProcResourceIdx != ResourceIdx)
1249 (PI->Cycles * TE.MTM.SchedModel.getResourceFactor(ResourceIdx));
1255 for (
unsigned K = 0; K != PRDepths.
size(); ++K) {
1256 unsigned PRCycles = PRDepths[K] + PRHeights[K];
1258 PRCycles += TE.MTM.getProcResourceCycles(MBB->
getNumber())[K];
1259 PRCycles += extraCycles(ExtraInstrs, K);
1260 PRCycles -= extraCycles(RemoveInstrs, K);
1264 PRMax = TE.MTM.getCycles(PRMax);
1267 unsigned Instrs = TBI.InstrDepth + TBI.InstrHeight;
1270 Instrs += TE.MTM.getResources(MBB)->InstrCount;
1271 Instrs += ExtraInstrs.
size();
1272 Instrs -= RemoveInstrs.
size();
1273 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1291 OS <<
getName() <<
" ensemble:\n";
1292 for (
unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
1293 OS <<
" %bb." << i <<
'\t';
1294 BlockInfo[i].print(OS);
1300 if (hasValidDepth()) {
1301 OS <<
"depth=" << InstrDepth;
1306 OS <<
" head=%bb." << Head;
1307 if (HasValidInstrDepths)
1310 OS <<
"depth invalid";
1312 if (hasValidHeight()) {
1313 OS <<
"height=" << InstrHeight;
1318 OS <<
" tail=%bb." << Tail;
1319 if (HasValidInstrHeights)
1322 OS <<
"height invalid";
1323 if (HasValidInstrDepths && HasValidInstrHeights)
1324 OS <<
", crit=" << CriticalPath;
1328 unsigned MBBNum = &TBI - &TE.BlockInfo[0];
1330 OS << TE.getName() <<
" trace %bb." << TBI.Head <<
" --> %bb." << MBBNum
1331 <<
" --> %bb." << TBI.Tail <<
':';
1332 if (TBI.hasValidHeight() && TBI.hasValidDepth())
1333 OS <<
' ' << getInstrCount() <<
" instrs.";
1334 if (TBI.HasValidInstrDepths && TBI.HasValidInstrHeights)
1335 OS <<
' ' << TBI.CriticalPath <<
" cycles.";
1338 OS <<
"\n%bb." << MBBNum;
1342 Block = &TE.BlockInfo[Num];
1350 Block = &TE.BlockInfo[Num];
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()
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
ProcResIter getWriteProcResBegin(const MCSchedClassDesc *SC) const
MachineBasicBlock * getMBB() const
Compute iterated dominance frontiers using a linear time algorithm.
const MachineBasicBlock * Pred
Trace predecessor, or NULL for the first block in the trace.
void updateDepths(MachineBasicBlock::iterator Start, MachineBasicBlock::iterator End, SparseSet< LiveRegUnit > &RegUnits)
Updates the depth of the instructions from Start to End.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
unsigned Depth
Earliest issue cycle as determined by data dependencies and instruction latencies from the beginning ...
void print(raw_ostream &) const
unsigned getReg() const
getReg - Returns the register number.
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
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.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
const MachineLoop * getLoopFor(const MachineBasicBlock *) const
unsigned computeOperandLatency(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const
Compute operand latency based on the available machine model.
void invalidateHeight()
Invalidate height resources when a block below this one has changed.
ProcResIter getWriteProcResEnd(const MCSchedClassDesc *SC) const
bool isTransient() const
Return true if this is a transient instruction that is either very likely to be eliminated during reg...
A trace ensemble is a collection of traces selected using the same strategy, for example 'minimum res...
block Block Frequency true
static unsigned InstrCount
unsigned getNumRegUnits() const
Return the number of (native) register units in the target.
po_iterator_storage(LoopBounds &lb)
unsigned InstrCount
The number of non-trivial instructions in the block.
void updateDepth(TraceBlockInfo &TBI, const MachineInstr &, SparseSet< LiveRegUnit > &RegUnits)
Updates the depth of an machine instruction, given RegUnits.
iterator_range< succ_iterator > successors()
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool hasResources() const
Returns true when resource information for this block has been computed.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Provide an instruction scheduling machine model to CodeGen passes.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Strategy
Strategies for selecting traces.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
def_iterator def_begin(unsigned RegNo) const
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. ...
ArrayRef< unsigned > getProcResourceCycles(unsigned MBBNum) const
Get the scaled number of cycles used per processor resource in MBB.
Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
BlockT * getHeader() const
bool hasValidHeight() const
Returns true if the height resources have been computed from the trace below this block...
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
virtual const MachineBasicBlock * pickTraceSucc(const MachineBasicBlock *)=0
Select the trace through a block that has the fewest instructions.
bool hasValidDepth() const
Returns true if the depth resources have been computed from the trace above this block.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
void addLiveIns(MachineBasicBlock &MBB, const LivePhysRegs &LiveRegs)
Adds registers contained in LiveRegs to the block live-in list of MBB.
COFF::MachineTypes Machine
void finishPostorder(const MachineBasicBlock *)
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
virtual const TargetInstrInfo * getInstrInfo() const
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
void invalidateDepth()
Invalidate depth resources when some block above this one has changed.
void invalidate(const MachineBasicBlock *MBB)
Invalidate traces through BadMBB.
unsigned CriticalPath
Critical path length.
bool erase(const KeyT &Val)
MachineBasicBlock * getBlockNumbered(unsigned N) const
getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the mach...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
unsigned const MachineRegisterInfo * MRI
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().
typename DenseT::iterator iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
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
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Ensemble(MachineTraceMetrics *)
MachineTraceMetrics & MTM
Summarize the scheduling resources required for an instruction of a particular scheduling class...
Per-basic block information that doesn't depend on the trace through the block.
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
Represent the analysis usage information of a pass.
const MachineBasicBlock * Succ
Trace successor, or NULL for the last block in the trace.
Default po_iterator_storage implementation with an internal set object.
bool atEnd() const
atEnd - return true if this iterator is equal to reg_end() on the value.
const FixedBlockInfo * getResources(const MachineBasicBlock *)
Get the fixed resource information about MBB. Compute it on demand.
unsigned Tail
The block number of the tail of the trace. (When hasValidHeight()).
void setUniverse(unsigned U)
setUniverse - Set the universe size which determines the largest key the set can hold.
iterator_range< pred_iterator > predecessors()
void init(const TargetSubtargetInfo *TSInfo)
Initialize the machine model for instruction scheduling.
virtual const char * getName() const =0
virtual const MachineBasicBlock * pickTracePred(const MachineBasicBlock *)=0
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 end() const
bool isDebugInstr() const
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void updatePhysDepsDownwards(const MachineInstr *UseMI, SmallVectorImpl< DataDep > &Deps, SparseSet< LiveRegUnit > &RegUnits, const TargetRegisterInfo *TRI)
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
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...
MachineInstrBuilder MachineInstrBuilder & DefMI
const_iterator begin() const
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...
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.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
const TraceBlockInfo * getHeightResources(const MachineBasicBlock *) const
void setPreservesAll()
Set by analyses that do not transform their input at all.
unsigned getResourceFactor(unsigned ResIdx) const
Multiply the number of units consumed for a resource by this factor to normalize it relative to other...
void invalidate(const MachineBasicBlock *MBB)
Invalidate cached information about MBB.
unsigned Head
The block number of the head of the trace. (When hasValidDepth()).
unsigned getNumProcResourceKinds() const
Get the number of kinds of resources for this target.
const MCSchedClassDesc * resolveSchedClass(const MachineInstr *MI) const
Return the MCSchedClassDesc for this instruction.
static bool pushDepHeight(const DataDep &Dep, const MachineInstr &UseMI, unsigned UseHeight, MIHeightMap &Heights, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII)
const MachineBasicBlock * getParent() const
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)
bool insertEdge(Optional< const MachineBasicBlock *> From, const MachineBasicBlock *To)
static void getPHIDeps(const MachineInstr &UseMI, SmallVectorImpl< DataDep > &Deps, const MachineBasicBlock *Pred, const MachineRegisterInfo *MRI)
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
unsigned getOperandNo() const
getOperandNo - Return the operand # of this MachineOperand in its MachineInstr.
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.
LLVM_NODISCARD bool empty() const
Represents a single loop in the control flow graph.
INITIALIZE_PASS_BEGIN(MachineTraceMetrics, DEBUG_TYPE, "Machine Trace Metrics", false, true) INITIALIZE_PASS_END(MachineTraceMetrics
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.
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 isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
const TraceBlockInfo * getDepthResources(const MachineBasicBlock *) const
unsigned getResourceDepth(bool Bottom) const
Return the resource depth of the top/bottom of the trace center block.
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...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
unsigned getPHIDepth(const MachineInstr &PHI) const
Return the Depth of a PHI instruction in a trace center block successor.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCProcResourceDesc * getProcResource(unsigned PIdx) const
Get a processor resource by ID for convenience.
mop_iterator operands_begin()
void print(raw_ostream &) const
void print(raw_ostream &) const
MachineLoop * getLoopFor(const MachineBasicBlock *BB) const
Return the innermost loop that BB lives in.
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.
ArrayRef< unsigned > getProcResourceDepths(unsigned MBBNum) const
Get an array of processor resource depths for MBB.
unsigned InstrDepth
Accumulated number of instructions in the trace above this block.
This class implements an extremely fast bulk output stream that can only output to a stream...
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 getInstrSlack(const MachineInstr &MI) const
Return the slack of MI.
const MachineOperand & getOperand(unsigned i) const
OutputIt copy(R &&Range, OutputIt Out)
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)
bool isUsefulDominator(const TraceBlockInfo &TBI) const
Assuming that this is a dominator of TBI, determine if it contains useful instruction depths...
static unsigned updatePhysDepsUpwards(const MachineInstr &MI, unsigned Height, SparseSet< LiveRegUnit > &RegUnits, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
bool empty() const
empty - Check if the array is empty.
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.