Lines Matching refs:MBB
83 /// Compute the resource usage in basic block MBB.
85 MachineTraceMetrics::getResources(const MachineBasicBlock *MBB) {
86 assert(MBB && "No basic block");
87 FixedBlockInfo *FBI = &BlockInfo[MBB->getNumber()];
99 for (const auto &MI : *MBB) {
123 unsigned PROffset = MBB->getNumber() * PRKinds;
157 MachineTraceMetrics::Ensemble::getLoopFor(const MachineBasicBlock *MBB) const {
158 return MTM.Loops->getLoopFor(MBB);
161 // Update resource-related information in the TraceBlockInfo for MBB.
162 // Only update resources related to the trace above MBB.
164 computeDepthResources(const MachineBasicBlock *MBB) {
165 TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
167 unsigned PROffset = MBB->getNumber() * PRKinds;
172 TBI->Head = MBB->getNumber();
194 // Update resource-related information in the TraceBlockInfo for MBB.
195 // Only update resources related to the trace below MBB.
197 computeHeightResources(const MachineBasicBlock *MBB) {
198 TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
200 unsigned PROffset = MBB->getNumber() * PRKinds;
203 TBI->InstrHeight = MTM.getResources(MBB)->InstrCount;
204 ArrayRef<unsigned> PRCycles = MTM.getProcResourceCycles(MBB->getNumber());
208 TBI->Tail = MBB->getNumber();
228 // Check if depth resources for MBB are valid and return the TBI.
232 getDepthResources(const MachineBasicBlock *MBB) const {
233 const TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
237 // Check if height resources for MBB are valid and return the TBI.
241 getHeightResources(const MachineBasicBlock *MBB) const {
242 const TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
246 /// Get an array of processor resource depths for MBB. Indexed by processor
248 /// by all blocks preceding MBB in its trace. It does not include instructions
249 /// in MBB.
260 /// Get an array of processor resource heights for MBB. Indexed by processor
311 // Select the preferred predecessor for MBB.
313 MinInstrCountEnsemble::pickTracePred(const MachineBasicBlock *MBB) {
314 if (MBB->pred_empty())
316 const MachineLoop *CurLoop = getLoopFor(MBB);
318 if (CurLoop && MBB == CurLoop->getHeader())
320 unsigned CurCount = MTM.getResources(MBB)->InstrCount;
323 for (const MachineBasicBlock *Pred : MBB->predecessors()) {
337 // Select the preferred successor for MBB.
339 MinInstrCountEnsemble::pickTraceSucc(const MachineBasicBlock *MBB) {
340 if (MBB->pred_empty())
342 const MachineLoop *CurLoop = getLoopFor(MBB);
345 for (const MachineBasicBlock *Succ : MBB->successors()) {
380 void MachineTraceMetrics::invalidate(const MachineBasicBlock *MBB) {
381 DEBUG(dbgs() << "Invalidate traces through BB#" << MBB->getNumber() << '\n');
382 BlockInfo[MBB->getNumber()].invalidate();
385 Ensembles[i]->invalidate(MBB);
452 /// Compute the trace through MBB.
453 void MachineTraceMetrics::Ensemble::computeTrace(const MachineBasicBlock *MBB) {
455 << MBB->getNumber() << '\n');
462 for (auto I : inverse_post_order_ext(MBB, Bounds)) {
480 for (auto I : post_order_ext(MBB, Bounds)) {
502 // Invalidate height resources of blocks above MBB.
507 const MachineBasicBlock *MBB = WorkList.pop_back_val();
508 DEBUG(dbgs() << "Invalidate BB#" << MBB->getNumber() << ' ' << getName()
510 // Find any MBB predecessors that have MBB as their preferred successor.
512 for (const MachineBasicBlock *Pred : MBB->predecessors()) {
516 if (TBI.Succ == MBB) {
527 // Invalidate depth resources of blocks below MBB.
532 const MachineBasicBlock *MBB = WorkList.pop_back_val();
533 DEBUG(dbgs() << "Invalidate BB#" << MBB->getNumber() << ' ' << getName()
535 // Find any MBB successors that have MBB as their preferred predecessor.
537 for (const MachineBasicBlock *Succ : MBB->successors()) {
541 if (TBI.Pred == MBB) {
568 const MachineBasicBlock *MBB = MTM.MF->getBlockNumbered(Num);
569 assert(MBB->isPredecessor(TBI.Pred) && "CFG doesn't match trace");
572 const MachineLoop *Loop = getLoopFor(MBB);
573 assert(!(Loop && MBB == Loop->getHeader()) && "Trace contains backedge");
576 const MachineBasicBlock *MBB = MTM.MF->getBlockNumbered(Num);
577 assert(MBB->isSuccessor(TBI.Succ) && "CFG doesn't match trace");
580 const MachineLoop *Loop = getLoopFor(MBB);
772 /// Compute instruction depths for all instructions above or in MBB in its
773 /// trace. This assumes that the trace through MBB has already been computed.
775 computeInstrDepths(const MachineBasicBlock *MBB) {
781 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
785 Stack.push_back(MBB);
786 MBB = TBI.Pred;
787 } while (MBB);
789 // FIXME: If MBB is non-null at this point, it is the last pre-computed block
799 MBB = Stack.pop_back_val();
800 DEBUG(dbgs() << "\nDepths for BB#" << MBB->getNumber() << ":\n");
801 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
808 ArrayRef<unsigned> PRDepths = getProcResourceDepths(MBB->getNumber());
818 // Also compute the critical path length through MBB when possible.
822 for (const auto &UseMI : *MBB) {
960 const MachineBasicBlock *MBB = Trace[i-1];
961 if (MBB == DefMBB)
963 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
969 /// Compute instruction heights in the trace through MBB. This updates MBB and
973 computeInstrHeights(const MachineBasicBlock *MBB) {
978 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
982 Stack.push_back(MBB);
984 MBB = TBI.Succ;
985 } while (MBB);
998 // MBB is the highest precomputed block in the trace.
999 if (MBB) {
1000 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1018 MBB = Stack.back();
1019 DEBUG(dbgs() << "Heights for BB#" << MBB->getNumber() << ":\n");
1020 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1026 ArrayRef<unsigned> PRHeights = getProcResourceHeights(MBB->getNumber());
1038 // If MBB is the last block in the trace, and it has a back-edge to the
1042 if (const MachineLoop *Loop = getLoopFor(MBB))
1043 if (MBB->isSuccessor(Loop->getHeader()))
1051 getPHIDeps(&PHI, Deps, MBB, MTM.MRI);
1064 for (MachineBasicBlock::const_iterator BI = MBB->end(), BB = MBB->begin();
1106 DEBUG(dbgs() << "BB#" << MBB->getNumber() << " Live-ins:");
1132 MachineTraceMetrics::Ensemble::getTrace(const MachineBasicBlock *MBB) {
1133 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1136 computeTrace(MBB);
1138 computeInstrDepths(MBB);
1140 computeInstrHeights(MBB);
1156 const MachineBasicBlock *MBB = TE.MTM.MF->getBlockNumbered(getBlockNum());
1158 getPHIDeps(PHI, Deps, MBB, TE.MTM.MRI);
1159 assert(Deps.size() == 1 && "PHI doesn't have MBB as a predecessor");
1229 for (const MachineBasicBlock *MBB : Extrablocks)
1230 PRCycles += TE.MTM.getProcResourceCycles(MBB->getNumber())[K];
1241 for (const MachineBasicBlock *MBB : Extrablocks)
1242 Instrs += TE.MTM.getResources(MBB)->InstrCount;