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;
235 for (
unsigned K = 0; K != PRKinds; ++K)
236 ProcResourceHeights[PROffset + K] = SuccPRHeights[K] + PRCycles[K];
267 assert((MBBNum+1) * PRKinds <= ProcResourceDepths.
size());
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())
335 unsigned BestDepth = 0;
344 if (!Best || Depth < BestDepth) {
359 unsigned BestHeight = 0;
362 if (CurLoop && Succ == CurLoop->
getHeader())
374 if (!Best || Height < BestHeight) {
400 BlockInfo[MBB->
getNumber()].invalidate();
403 Ensembles[i]->invalidate(MBB);
410 assert(BlockInfo.size() == MF->getNumBlockIDs() &&
"Outdated BlockInfo size");
413 Ensembles[i]->verify();
431 bool Downward =
false;
460 if (
const MachineLoop *FromLoop = LB.Loops->getLoopFor(*From)) {
462 if ((LB.Downward ? To : *From) == FromLoop->getHeader())
471 return LB.Visited.insert(To).second;
482 LoopBounds Bounds(BlockInfo,
MTM.Loops);
485 Bounds.Downward =
false;
486 Bounds.Visited.clear();
489 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
499 computeDepthResources(
I);
503 Bounds.Downward =
true;
504 Bounds.Visited.clear();
507 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
517 computeHeightResources(
I);
541 if (TBI.
Succ == MBB) {
549 }
while (!WorkList.
empty());
566 if (TBI.
Pred == MBB) {
574 }
while (!WorkList.
empty());
582 for (
const auto &
I : *BadMBB)
589 "Outdated BlockInfo size");
590 for (
unsigned Num = 0, e = BlockInfo.size(); Num != e; ++Num) {
596 "Trace is broken, depth should have been invalidated.");
598 assert(!(Loop && MBB == Loop->getHeader()) &&
"Trace contains backedge");
604 "Trace is broken, height should have been invalidated.");
607 assert(!(Loop && Loop == SuccLoop && TBI.
Succ == Loop->getHeader()) &&
608 "Trace contains backedge");
632 DataDep(
const MachineInstr *DefMI,
unsigned DefOp,
unsigned UseOp)
633 :
DefMI(DefMI), DefOp(DefOp), UseOp(UseOp) {}
643 assert((++DefI).atEnd() &&
"Register has multiple defs");
658 bool HasPhysRegs =
false;
728 if (I == RegUnits.
end())
737 for (
unsigned Kill : Kills)
739 RegUnits.
erase(*Units);
742 for (
unsigned DefOp : LiveDefOps) {
763 unsigned MachineTraceMetrics::Ensemble::
764 computeCrossBlockCriticalPath(
const TraceBlockInfo &TBI) {
765 assert(TBI.HasValidInstrDepths &&
"Missing depth info");
766 assert(TBI.HasValidInstrHeights &&
"Missing height info");
768 for (
const LiveInReg &LIR : TBI.LiveIns) {
774 if (!DefTBI.isUsefulDominator(TBI))
776 unsigned Len = LIR.Height + Cycles[
DefMI].Depth;
794 for (
const DataDep &Dep : Deps) {
796 BlockInfo[Dep.DefMI->getParent()->getNumber()];
801 unsigned DepCycle = Cycles.lookup(Dep.DefMI).Depth;
803 if (!Dep.DefMI->isTransient())
804 DepCycle +=
MTM.SchedModel
810 MICycles.
Depth = Cycle;
831 for (; Start != End; Start++)
837 void MachineTraceMetrics::Ensemble::
860 while (!Stack.
empty()) {
871 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
876 << PRDepths[K]/Factor <<
" ops x" << Factor <<
")\n";
884 for (
const auto &
UseMI : *MBB) {
917 if (I == RegUnits.
end())
919 unsigned DepHeight = I->Cycle;
926 Height =
std::max(Height, DepHeight);
933 for (
unsigned i = 0, e = ReadOps.
size(); i != e; ++i) {
938 if (LRU.
Cycle <= Height && LRU.
MI != &MI) {
958 if (!Dep.DefMI->isTransient())
965 std::tie(I, New) = Heights.
insert(std::make_pair(Dep.DefMI, UseHeight));
970 if (I->second < UseHeight)
971 I->second = UseHeight;
978 void MachineTraceMetrics::Ensemble::
981 assert(!Trace.
empty() &&
"Trace should contain at least one block");
987 for (
unsigned i = Trace.
size(); i; --i) {
991 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
993 TBI.LiveIns.push_back(Reg);
1000 void MachineTraceMetrics::Ensemble::
1006 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1007 assert(TBI.hasValidHeight() &&
"Incomplete trace");
1008 if (TBI.HasValidInstrHeights)
1011 TBI.LiveIns.clear();
1028 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1029 for (LiveInReg &LI : TBI.LiveIns) {
1033 if (Height < LI.Height)
1038 RegUnits[LI.Reg].Cycle = LI.Height;
1048 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1049 TBI.HasValidInstrHeights =
true;
1050 TBI.CriticalPath = 0;
1053 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrHeight);
1055 for (
unsigned K = 0; K != PRHeights.
size(); ++K)
1060 << PRHeights[K]/Factor <<
" ops x" << Factor <<
")\n";
1075 for (
const auto &PHI : *Succ) {
1080 if (!Deps.
empty()) {
1082 unsigned Height = TBI.Succ ? Cycles.lookup(&PHI).Height : 0;
1100 if (HeightI != Heights.
end()) {
1101 Cycle = HeightI->second;
1103 Heights.
erase(HeightI);
1117 for (
const DataDep &Dep : Deps)
1121 InstrCycles &MICycles = Cycles[&
MI];
1122 MICycles.Height = Cycle;
1123 if (!TBI.HasValidInstrDepths) {
1128 TBI.CriticalPath =
std::max(TBI.CriticalPath, Cycle + MICycles.Depth);
1129 LLVM_DEBUG(
dbgs() << TBI.CriticalPath <<
'\t' << Cycle <<
'\t' << MI);
1135 for (LiveInReg &LIR : TBI.LiveIns) {
1137 LIR.Height = Heights.
lookup(DefMI);
1143 RI = RegUnits.
begin(), RE = RegUnits.
end(); RI != RE; ++RI) {
1144 TBI.LiveIns.push_back(LiveInReg(RI->RegUnit, RI->Cycle));
1150 if (!TBI.HasValidInstrDepths)
1153 TBI.CriticalPath =
std::max(TBI.CriticalPath,
1154 computeCrossBlockCriticalPath(TBI));
1155 LLVM_DEBUG(
dbgs() <<
"Critical path: " << TBI.CriticalPath <<
'\n');
1166 computeInstrDepths(MBB);
1168 computeInstrHeights(MBB);
1170 return Trace(*
this, TBI);
1176 "MI must be in the trace center block");
1178 return getCriticalPath() - (Cyc.
Depth + Cyc.
Height);
1186 assert(Deps.
size() == 1 &&
"PHI doesn't have MBB as a predecessor");
1187 DataDep &Dep = Deps.
front();
1188 unsigned DepCycle = getInstrCycles(*Dep.DefMI).Depth;
1190 if (!Dep.DefMI->isTransient())
1191 DepCycle += TE.MTM.SchedModel.computeOperandLatency(Dep.DefMI, Dep.DefOp,
1204 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1205 PRMax =
std::max(PRMax, PRDepths[K] + PRCycles[K]);
1207 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1208 PRMax =
std::max(PRMax, PRDepths[K]);
1211 PRMax = TE.MTM.getCycles(PRMax);
1214 unsigned Instrs = TBI.InstrDepth;
1217 Instrs += TE.MTM.BlockInfo[getBlockNum()].InstrCount;
1218 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1235 unsigned ResourceIdx)
1237 unsigned Cycles = 0;
1242 PI = TE.MTM.SchedModel.getWriteProcResBegin(
SC),
1243 PE = TE.MTM.SchedModel.getWriteProcResEnd(
SC);
1245 if (PI->ProcResourceIdx != ResourceIdx)
1248 (PI->Cycles * TE.MTM.SchedModel.getResourceFactor(ResourceIdx));
1254 for (
unsigned K = 0; K != PRDepths.
size(); ++K) {
1255 unsigned PRCycles = PRDepths[K] + PRHeights[K];
1257 PRCycles += TE.MTM.getProcResourceCycles(MBB->
getNumber())[K];
1258 PRCycles += extraCycles(ExtraInstrs, K);
1259 PRCycles -= extraCycles(RemoveInstrs, K);
1263 PRMax = TE.MTM.getCycles(PRMax);
1266 unsigned Instrs = TBI.InstrDepth + TBI.InstrHeight;
1269 Instrs += TE.MTM.getResources(MBB)->InstrCount;
1270 Instrs += ExtraInstrs.
size();
1271 Instrs -= RemoveInstrs.
size();
1272 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1290 OS <<
getName() <<
" ensemble:\n";
1291 for (
unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
1292 OS <<
" %bb." << i <<
'\t';
1293 BlockInfo[i].print(OS);
1299 if (hasValidDepth()) {
1300 OS <<
"depth=" << InstrDepth;
1305 OS <<
" head=%bb." << Head;
1306 if (HasValidInstrDepths)
1309 OS <<
"depth invalid";
1311 if (hasValidHeight()) {
1312 OS <<
"height=" << InstrHeight;
1317 OS <<
" tail=%bb." << Tail;
1318 if (HasValidInstrHeights)
1321 OS <<
"height invalid";
1322 if (HasValidInstrDepths && HasValidInstrHeights)
1323 OS <<
", crit=" << CriticalPath;
1327 unsigned MBBNum = &TBI - &TE.BlockInfo[0];
1329 OS << TE.getName() <<
" trace %bb." << TBI.Head <<
" --> %bb." << MBBNum
1330 <<
" --> %bb." << TBI.Tail <<
':';
1331 if (TBI.hasValidHeight() && TBI.hasValidDepth())
1332 OS <<
' ' << getInstrCount() <<
" instrs.";
1333 if (TBI.HasValidInstrDepths && TBI.HasValidInstrHeights)
1334 OS <<
' ' << TBI.CriticalPath <<
" cycles.";
1337 OS <<
"\n%bb." << MBBNum;
1341 Block = &TE.BlockInfo[Num];
1349 Block = &TE.BlockInfo[Num];
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
This class represents lattice values for constants.
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 push_back(const T &Elt)
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
Retuns the total number of operands.
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.
BlockVerifier::State From
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.