28 #define DEBUG_TYPE "machine-trace-metrics"
34 "machine-trace-metrics",
"Machine Trace Metrics",
false,
true)
40 MachineTraceMetrics::MachineTraceMetrics()
42 MRI(
nullptr),
Loops(
nullptr) {
59 Loops = &getAnalysis<MachineLoopInfo>();
72 Ensembles[i] =
nullptr;
86 assert(MBB &&
"No basic block");
93 unsigned InstrCount = 0;
99 for (
const auto &
MI : *MBB) {
100 if (
MI.isTransient())
116 assert(PI->ProcResourceIdx < PRKinds &&
"Bad processor resource kind");
117 PRCycles[PI->ProcResourceIdx] += PI->Cycles;
123 unsigned PROffset = MBB->getNumber() * PRKinds;
124 for (
unsigned K = 0; K != PRKinds; ++K)
125 ProcResourceCycles[PROffset + K] =
133 assert(BlockInfo[MBBNum].hasResources() &&
134 "getResources() must be called before getProcResourceCycles()");
136 assert((MBBNum+1) * PRKinds <= ProcResourceCycles.
size());
147 BlockInfo.resize(
MTM.BlockInfo.size());
149 ProcResourceDepths.
resize(
MTM.BlockInfo.size() * PRKinds);
150 ProcResourceHeights.
resize(
MTM.BlockInfo.size() * PRKinds);
158 return MTM.Loops->getLoopFor(MBB);
163 void MachineTraceMetrics::Ensemble::
166 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
167 unsigned PROffset = MBB->
getNumber() * PRKinds;
173 std::fill(ProcResourceDepths.begin() + PROffset,
174 ProcResourceDepths.begin() + PROffset + PRKinds, 0);
181 TraceBlockInfo *PredTBI = &BlockInfo[PredNum];
182 assert(PredTBI->hasValidDepth() &&
"Trace above has not been computed yet");
183 const FixedBlockInfo *PredFBI = MTM.getResources(TBI->
Pred);
184 TBI->
InstrDepth = PredTBI->InstrDepth + PredFBI->InstrCount;
185 TBI->
Head = PredTBI->Head;
190 for (
unsigned K = 0; K != PRKinds; ++K)
191 ProcResourceDepths[PROffset + K] = PredPRDepths[K] + PredPRCycles[K];
196 void MachineTraceMetrics::Ensemble::
198 TraceBlockInfo *TBI = &BlockInfo[MBB->
getNumber()];
199 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
200 unsigned PROffset = MBB->
getNumber() * PRKinds;
203 TBI->InstrHeight = MTM.getResources(MBB)->InstrCount;
209 std::copy(PRCycles.
begin(), PRCycles.
end(),
210 ProcResourceHeights.begin() + PROffset);
216 unsigned SuccNum = TBI->Succ->getNumber();
217 TraceBlockInfo *SuccTBI = &BlockInfo[SuccNum];
218 assert(SuccTBI->hasValidHeight() &&
"Trace below has not been computed yet");
219 TBI->InstrHeight += SuccTBI->InstrHeight;
220 TBI->Tail = SuccTBI->Tail;
224 for (
unsigned K = 0; K != PRKinds; ++K)
225 ProcResourceHeights[PROffset + K] = SuccPRHeights[K] + PRCycles[K];
255 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
256 assert((MBBNum+1) * PRKinds <= ProcResourceDepths.size());
257 return makeArrayRef(ProcResourceDepths.data() + MBBNum * PRKinds, PRKinds);
268 unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds();
269 assert((MBBNum+1) * PRKinds <= ProcResourceHeights.size());
270 return makeArrayRef(ProcResourceHeights.data() + MBBNum * PRKinds, PRKinds);
301 const char *
getName()
const override {
return "MinInstr"; }
318 if (CurLoop && MBB == CurLoop->
getHeader())
320 unsigned CurCount = MTM.getResources(MBB)->InstrCount;
322 unsigned BestDepth = 0;
325 getDepthResources(Pred);
330 unsigned Depth = PredTBI->
InstrDepth + CurCount;
331 if (!Best || Depth < BestDepth)
332 Best = Pred, BestDepth = Depth;
344 unsigned BestHeight = 0;
347 if (CurLoop && Succ == CurLoop->
getHeader())
353 getHeightResources(Succ);
359 if (!Best || Height < BestHeight)
360 Best = Succ, BestHeight = Height;
382 BlockInfo[MBB->
getNumber()].invalidate();
392 assert(BlockInfo.size() == MF->
getNumBlockIDs() &&
"Outdated BlockInfo size");
415 : Blocks(blocks),
Loops(loops), Downward(
false) {}
436 if (
const MachineLoop *FromLoop = LB.Loops->getLoopFor(From)) {
438 if ((LB.Downward ? To : From) == FromLoop->getHeader())
447 return LB.Visited.insert(To).second;
457 LoopBounds Bounds(BlockInfo, MTM.Loops);
460 Bounds.Downward =
false;
461 Bounds.Visited.clear();
463 DEBUG(
dbgs() <<
" pred for BB#" <<
I->getNumber() <<
": ");
464 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
466 TBI.Pred = pickTracePred(
I);
469 dbgs() <<
"BB#" << TBI.Pred->getNumber() <<
'\n';
474 computeDepthResources(
I);
478 Bounds.Downward =
true;
479 Bounds.Visited.clear();
481 DEBUG(
dbgs() <<
" succ for BB#" <<
I->getNumber() <<
": ");
482 TraceBlockInfo &TBI = BlockInfo[
I->getNumber()];
484 TBI.Succ = pickTraceSucc(
I);
487 dbgs() <<
"BB#" << TBI.Succ->getNumber() <<
'\n';
492 computeHeightResources(
I);
516 if (TBI.
Succ == MBB) {
524 }
while (!WorkList.
empty());
541 if (TBI.
Pred == MBB) {
549 }
while (!WorkList.
empty());
557 for (
const auto &
I : *BadMBB)
563 assert(BlockInfo.size() == MTM.MF->getNumBlockIDs() &&
564 "Outdated BlockInfo size");
565 for (
unsigned Num = 0, e = BlockInfo.size(); Num != e; ++Num) {
571 "Trace is broken, depth should have been invalidated.");
573 assert(!(Loop && MBB == Loop->getHeader()) &&
"Trace contains backedge");
579 "Trace is broken, height should have been invalidated.");
582 assert(!(Loop && Loop == SuccLoop && TBI.
Succ == Loop->getHeader()) &&
583 "Trace contains backedge");
606 DataDep(
const MachineInstr *DefMI,
unsigned DefOp,
unsigned UseOp)
607 : DefMI(DefMI), DefOp(DefOp), UseOp(UseOp) {}
614 assert(!DefI.
atEnd() &&
"Register has no defs");
617 assert((++DefI).atEnd() &&
"Register has multiple defs");
631 bool HasPhysRegs =
false;
682 unsigned getSparseSetIndex()
const {
return RegUnit; }
684 LiveRegUnit(
unsigned RU) : RegUnit(RU), Cycle(0),
MI(nullptr), Op(0) {}
718 if (I == RegUnits.
end())
727 for (
unsigned i = 0, e = Kills.
size(); i != e; ++i)
729 RegUnits.
erase(*Units);
732 for (
unsigned i = 0, e = LiveDefOps.
size(); i != e; ++i) {
733 unsigned DefOp = LiveDefOps[i];
736 LiveRegUnit &LRU = RegUnits[*Units];
754 unsigned MachineTraceMetrics::Ensemble::
755 computeCrossBlockCriticalPath(
const TraceBlockInfo &TBI) {
756 assert(TBI.HasValidInstrDepths &&
"Missing depth info");
757 assert(TBI.HasValidInstrHeights &&
"Missing height info");
759 for (
unsigned i = 0, e = TBI.LiveIns.size(); i != e; ++i) {
760 const LiveInReg &LIR = TBI.LiveIns[i];
763 const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
766 if (!DefTBI.isUsefulDominator(TBI))
768 unsigned Len = LIR.Height + Cycles[DefMI].Depth;
769 MaxLen = std::max(MaxLen, Len);
776 void MachineTraceMetrics::Ensemble::
783 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
784 assert(TBI.hasValidDepth() &&
"Incomplete trace");
785 if (TBI.HasValidInstrDepths)
800 while (!Stack.
empty()) {
803 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
804 TBI.HasValidInstrDepths =
true;
805 TBI.CriticalPath = 0;
809 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrDepth);
811 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
813 unsigned Factor = MTM.SchedModel.getResourceFactor(K);
814 dbgs() <<
format(
"%6uc @ ", MTM.getCycles(PRDepths[K]))
815 << MTM.SchedModel.getProcResource(K)->Name <<
" ("
816 << PRDepths[K]/Factor <<
" ops x" << Factor <<
")\n";
821 if (TBI.HasValidInstrHeights)
822 TBI.CriticalPath = computeCrossBlockCriticalPath(TBI);
824 for (
const auto &UseMI : *MBB) {
834 for (
const DataDep &Dep : Deps) {
835 const TraceBlockInfo&DepTBI =
836 BlockInfo[Dep.DefMI->getParent()->getNumber()];
838 if (!DepTBI.isUsefulDominator(TBI))
840 assert(DepTBI.HasValidInstrDepths &&
"Inconsistent dependency");
841 unsigned DepCycle = Cycles.lookup(Dep.DefMI).Depth;
843 if (!Dep.DefMI->isTransient())
844 DepCycle += MTM.SchedModel
845 .computeOperandLatency(Dep.DefMI, Dep.DefOp, &UseMI, Dep.UseOp);
846 Cycle = std::max(Cycle, DepCycle);
849 InstrCycles &MICycles = Cycles[&UseMI];
850 MICycles.Depth = Cycle;
852 if (!TBI.HasValidInstrHeights) {
857 TBI.CriticalPath = std::max(TBI.CriticalPath, Cycle + MICycles.Height);
858 DEBUG(
dbgs() << TBI.CriticalPath <<
'\t' << Cycle <<
'\t' << UseMI);
889 if (I == RegUnits.
end())
891 unsigned DepHeight = I->Cycle;
895 DepHeight += SchedModel
898 Height = std::max(Height, DepHeight);
905 for (
unsigned i = 0, e = ReadOps.
size(); i != e; ++i) {
908 LiveRegUnit &LRU = RegUnits[*Units];
910 if (LRU.Cycle <= Height && LRU.MI != MI) {
932 if (!Dep.DefMI->isTransient())
939 std::tie(I, New) = Heights.
insert(std::make_pair(Dep.DefMI, UseHeight));
944 if (I->second < UseHeight)
945 I->second = UseHeight;
952 void MachineTraceMetrics::Ensemble::
955 assert(!Trace.
empty() &&
"Trace should contain at least one block");
961 for (
unsigned i = Trace.
size(); i; --i) {
965 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
967 TBI.LiveIns.push_back(Reg);
974 void MachineTraceMetrics::Ensemble::
980 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
981 assert(TBI.hasValidHeight() &&
"Incomplete trace");
982 if (TBI.HasValidInstrHeights)
1002 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1003 for (LiveInReg &LI : TBI.LiveIns) {
1006 unsigned &Height = Heights[MTM.MRI->getVRegDef(LI.Reg)];
1007 if (Height < LI.Height)
1012 RegUnits[LI.Reg].Cycle = LI.Height;
1022 TraceBlockInfo &TBI = BlockInfo[MBB->
getNumber()];
1023 TBI.HasValidInstrHeights =
true;
1024 TBI.CriticalPath = 0;
1027 dbgs() <<
format(
"%7u Instructions\n", TBI.InstrHeight);
1029 for (
unsigned K = 0; K != PRHeights.
size(); ++K)
1031 unsigned Factor = MTM.SchedModel.getResourceFactor(K);
1032 dbgs() <<
format(
"%6uc @ ", MTM.getCycles(PRHeights[K]))
1033 << MTM.SchedModel.getProcResource(K)->Name <<
" ("
1034 << PRHeights[K]/Factor <<
" ops x" << Factor <<
")\n";
1049 for (
const auto &
PHI : *Succ) {
1054 if (!Deps.
empty()) {
1056 unsigned Height = TBI.Succ ? Cycles.lookup(&
PHI).Height : 0;
1059 Heights, MTM.SchedModel, MTM.TII))
1074 if (HeightI != Heights.
end()) {
1075 Cycle = HeightI->second;
1077 Heights.
erase(HeightI);
1088 MTM.SchedModel, MTM.TII, MTM.TRI);
1091 for (
const DataDep &Dep : Deps)
1092 if (
pushDepHeight(Dep, MI, Cycle, Heights, MTM.SchedModel, MTM.TII))
1095 InstrCycles &MICycles = Cycles[
MI];
1096 MICycles.Height = Cycle;
1097 if (!TBI.HasValidInstrDepths) {
1102 TBI.CriticalPath = std::max(TBI.CriticalPath, Cycle + MICycles.Depth);
1103 DEBUG(
dbgs() << TBI.CriticalPath <<
'\t' << Cycle <<
'\t' << *MI);
1109 for (LiveInReg &LIR : TBI.LiveIns) {
1110 const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
1111 LIR.Height = Heights.
lookup(DefMI);
1117 RI = RegUnits.
begin(), RE = RegUnits.
end(); RI != RE; ++RI) {
1118 TBI.LiveIns.push_back(LiveInReg(RI->RegUnit, RI->Cycle));
1120 <<
'@' << RI->Cycle);
1124 if (!TBI.HasValidInstrDepths)
1127 TBI.CriticalPath = std::max(TBI.CriticalPath,
1128 computeCrossBlockCriticalPath(TBI));
1129 DEBUG(
dbgs() <<
"Critical path: " << TBI.CriticalPath <<
'\n');
1140 computeInstrDepths(MBB);
1142 computeInstrHeights(MBB);
1144 return Trace(*
this, TBI);
1149 assert(MI &&
"Not an instruction.");
1151 "MI must be in the trace center block");
1153 return getCriticalPath() - (Cyc.
Depth + Cyc.
Height);
1161 assert(Deps.
size() == 1 &&
"PHI doesn't have MBB as a predecessor");
1162 DataDep &Dep = Deps.
front();
1163 unsigned DepCycle = getInstrCycles(Dep.DefMI).Depth;
1165 if (!Dep.DefMI->isTransient())
1166 DepCycle += TE.MTM.SchedModel
1167 .computeOperandLatency(Dep.DefMI, Dep.DefOp, PHI, Dep.UseOp);
1179 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1180 PRMax = std::max(PRMax, PRDepths[K] + PRCycles[K]);
1182 for (
unsigned K = 0; K != PRDepths.
size(); ++K)
1183 PRMax = std::max(PRMax, PRDepths[K]);
1186 PRMax = TE.MTM.getCycles(PRMax);
1189 unsigned Instrs = TBI.InstrDepth;
1192 Instrs += TE.MTM.BlockInfo[
getBlockNum()].InstrCount;
1193 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1196 return std::max(Instrs, PRMax);
1210 unsigned ResourceIdx)
1212 unsigned Cycles = 0;
1217 PI = TE.MTM.SchedModel.getWriteProcResBegin(
SC),
1218 PE = TE.MTM.SchedModel.getWriteProcResEnd(
SC);
1220 if (PI->ProcResourceIdx != ResourceIdx)
1223 (PI->Cycles * TE.MTM.SchedModel.getResourceFactor(ResourceIdx));
1229 for (
unsigned K = 0; K != PRDepths.
size(); ++K) {
1230 unsigned PRCycles = PRDepths[K] + PRHeights[K];
1232 PRCycles += TE.MTM.getProcResourceCycles(MBB->
getNumber())[K];
1233 PRCycles += extraCycles(ExtraInstrs, K);
1234 PRCycles -= extraCycles(RemoveInstrs, K);
1235 PRMax = std::max(PRMax, PRCycles);
1238 PRMax = TE.MTM.getCycles(PRMax);
1241 unsigned Instrs = TBI.InstrDepth + TBI.InstrHeight;
1244 Instrs += TE.MTM.getResources(MBB)->InstrCount;
1245 Instrs += ExtraInstrs.
size();
1246 Instrs -= RemoveInstrs.
size();
1247 if (
unsigned IW = TE.MTM.SchedModel.getIssueWidth())
1250 return std::max(Instrs, PRMax);
1265 OS <<
getName() <<
" ensemble:\n";
1266 for (
unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
1267 OS <<
" BB#" << i <<
'\t';
1268 BlockInfo[i].print(OS);
1274 if (hasValidDepth()) {
1275 OS <<
"depth=" << InstrDepth;
1277 OS <<
" pred=BB#" << Pred->getNumber();
1280 OS <<
" head=BB#" << Head;
1281 if (HasValidInstrDepths)
1284 OS <<
"depth invalid";
1286 if (hasValidHeight()) {
1287 OS <<
"height=" << InstrHeight;
1289 OS <<
" succ=BB#" << Succ->getNumber();
1292 OS <<
" tail=BB#" << Tail;
1293 if (HasValidInstrHeights)
1296 OS <<
"height invalid";
1297 if (HasValidInstrDepths && HasValidInstrHeights)
1298 OS <<
", crit=" << CriticalPath;
1302 unsigned MBBNum = &TBI - &TE.BlockInfo[0];
1304 OS << TE.getName() <<
" trace BB#" << TBI.Head <<
" --> BB#" << MBBNum
1305 <<
" --> BB#" << TBI.Tail <<
':';
1306 if (TBI.hasValidHeight() && TBI.hasValidDepth())
1307 OS <<
' ' << getInstrCount() <<
" instrs.";
1308 if (TBI.HasValidInstrDepths && TBI.HasValidInstrHeights)
1309 OS <<
' ' << TBI.CriticalPath <<
" cycles.";
1312 OS <<
"\nBB#" << MBBNum;
1315 OS <<
" <- BB#" << Num;
1316 Block = &TE.BlockInfo[Num];
1323 OS <<
" -> BB#" << Num;
1324 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.
void print(raw_ostream &) const
void print(raw_ostream &) const
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
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
getNumber - MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a M...
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 ...
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...
static bool isVirtualRegister(unsigned Reg)
isVirtualRegister - 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.
PrintRegUnit - Helper class for printing register units on a raw_ostream.
void invalidateHeight()
Invalidate height resources when a block below this one has changed.
const_iterator begin(StringRef path)
Get begin iterator over path.
A trace ensemble is a collection of traces selected using the same strategy, for example 'minimum res...
static std::string getBlockNum(MachineBasicBlock *BB)
Helper to print the number of a MBB.
unsigned getResourceFactor(unsigned ResIdx) const
Multiply the number of units consumed for a resource by this factor to normalize it relative to other...
machine trace Machine Trace false
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.
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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...
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
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)
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.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Select the trace through a block that has the fewest instructions.
PrintReg - Helper class for printing registers on a raw_ostream.
const TraceBlockInfo * getHeightResources(const MachineBasicBlock *) const
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
static bool getDataDeps(const MachineInstr *UseMI, SmallVectorImpl< DataDep > &Deps, const MachineRegisterInfo *MRI)
COFF::MachineTypes Machine
void finishPostorder(const MachineBasicBlock *)
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.
static unsigned updatePhysDepsUpwards(const MachineInstr *MI, unsigned Height, SparseSet< LiveRegUnit > &RegUnits, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
bool isDebugValue() const
void invalidateDepth()
Invalidate depth resources when some block above this one has changed.
INITIALIZE_PASS_BEGIN(MachineTraceMetrics,"machine-trace-metrics","Machine Trace Metrics", false, true) INITIALIZE_PASS_END(MachineTraceMetrics
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().
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.
Identify one of the processor resource kinds consumed by a particular scheduling class for the specif...
static void getPHIDeps(const MachineInstr *UseMI, SmallVectorImpl< DataDep > &Deps, const MachineBasicBlock *Pred, const MachineRegisterInfo *MRI)
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool insertEdge(const MachineBasicBlock *From, const MachineBasicBlock *To)
Ensemble(MachineTraceMetrics *)
MachineTraceMetrics & MTM
const MachineOperand & getOperand(unsigned i) const
Summarize the scheduling resources required for an instruction of a particular scheduling class...
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.
static void addLiveIns(LivePhysRegs &LiveRegs, const MachineBasicBlock &MBB)
Add live-in registers of basic block MBB to LiveRegs.
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
contains - Return true if the specified loop is contained within in this loop.
Default po_iterator_storage implementation with an internal set object.
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. ...
machine trace Machine Trace Metrics
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static bool pushDepHeight(const DataDep &Dep, const MachineInstr *UseMI, unsigned UseHeight, MIHeightMap &Heights, const TargetSchedModel &SchedModel, const TargetInstrInfo *TII)
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...
bool hasValidDepth() const
Returns true if the depth resources have been computed from the trace above this block.
bool isSuccessor(const MachineBasicBlock *MBB) const
isSuccessor - Return true if the specified MBB is a successor of this block.
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
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)
Representation of each machine instruction.
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
static bool isPhysicalRegister(unsigned Reg)
isPhysicalRegister - Return true if the specified register number is in the physical register namespa...
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.
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...
iterator find(const KeyT &Val)
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.
unsigned getPHIDepth(const MachineInstr *PHI) const
Return the Depth of a PHI instruction in a trace center block successor.
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.
This class implements an extremely fast bulk output stream that can only output to a stream...
bool isPredecessor(const MachineBasicBlock *MBB) const
isPredecessor - 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...
DenseMap< const MachineInstr *, unsigned > MIHeightMap
Trace getTrace(const MachineBasicBlock *MBB)
Get the trace that passes through MBB.
unsigned getInstrSlack(const MachineInstr *MI) const
Return the slack of MI.
void getAnalysisUsage(AnalysisUsage &) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.