Lines Matching defs:MBB
95 /// Compute the resource usage in basic block MBB.
97 MachineTraceMetrics::getResources(const MachineBasicBlock *MBB) {
98 assert(MBB && "No basic block");
99 FixedBlockInfo *FBI = &BlockInfo[MBB->getNumber()];
111 for (const auto &MI : *MBB) {
135 unsigned PROffset = MBB->getNumber() * PRKinds;
168 MachineTraceMetrics::Ensemble::getLoopFor(const MachineBasicBlock *MBB) const {
169 return MTM.Loops->getLoopFor(MBB);
172 // Update resource-related information in the TraceBlockInfo for MBB.
173 // Only update resources related to the trace above MBB.
175 computeDepthResources(const MachineBasicBlock *MBB) {
176 TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
178 unsigned PROffset = MBB->getNumber() * PRKinds;
183 TBI->Head = MBB->getNumber();
205 // Update resource-related information in the TraceBlockInfo for MBB.
206 // Only update resources related to the trace below MBB.
208 computeHeightResources(const MachineBasicBlock *MBB) {
209 TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
211 unsigned PROffset = MBB->getNumber() * PRKinds;
214 TBI->InstrHeight = MTM.getResources(MBB)->InstrCount;
215 ArrayRef<unsigned> PRCycles = MTM.getProcReleaseAtCycles(MBB->getNumber());
219 TBI->Tail = MBB->getNumber();
238 // Check if depth resources for MBB are valid and return the TBI.
242 getDepthResources(const MachineBasicBlock *MBB) const {
243 const TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
247 // Check if height resources for MBB are valid and return the TBI.
251 getHeightResources(const MachineBasicBlock *MBB) const {
252 const TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()];
256 /// Get an array of processor resource depths for MBB. Indexed by processor
258 /// by all blocks preceding MBB in its trace. It does not include instructions
259 /// in MBB.
270 /// Get an array of processor resource heights for MBB. Indexed by processor
338 // Select the preferred predecessor for MBB.
340 MinInstrCountEnsemble::pickTracePred(const MachineBasicBlock *MBB) {
341 if (MBB->pred_empty())
343 const MachineLoop *CurLoop = getLoopFor(MBB);
345 if (CurLoop && MBB == CurLoop->getHeader())
347 unsigned CurCount = MTM.getResources(MBB)->InstrCount;
350 for (const MachineBasicBlock *Pred : MBB->predecessors()) {
366 // Select the preferred successor for MBB.
368 MinInstrCountEnsemble::pickTraceSucc(const MachineBasicBlock *MBB) {
369 if (MBB->succ_empty())
371 const MachineLoop *CurLoop = getLoopFor(MBB);
374 for (const MachineBasicBlock *Succ : MBB->successors()) {
415 void MachineTraceMetrics::invalidate(const MachineBasicBlock *MBB) {
416 LLVM_DEBUG(dbgs() << "Invalidate traces through " << printMBBReference(*MBB)
418 BlockInfo[MBB->getNumber()].invalidate();
421 E->invalidate(MBB);
495 /// Compute the trace through MBB.
496 void MachineTraceMetrics::Ensemble::computeTrace(const MachineBasicBlock *MBB) {
498 << printMBBReference(*MBB) << '\n');
505 for (const auto *I : inverse_post_order_ext(MBB, Bounds)) {
523 for (const auto *I : post_order_ext(MBB, Bounds)) {
545 // Invalidate height resources of blocks above MBB.
550 const MachineBasicBlock *MBB = WorkList.pop_back_val();
551 LLVM_DEBUG(dbgs() << "Invalidate " << printMBBReference(*MBB) << ' '
553 // Find any MBB predecessors that have MBB as their preferred successor.
555 for (const MachineBasicBlock *Pred : MBB->predecessors()) {
559 if (TBI.Succ == MBB) {
570 // Invalidate depth resources of blocks below MBB.
575 const MachineBasicBlock *MBB = WorkList.pop_back_val();
576 LLVM_DEBUG(dbgs() << "Invalidate " << printMBBReference(*MBB) << ' '
578 // Find any MBB successors that have MBB as their preferred predecessor.
580 for (const MachineBasicBlock *Succ : MBB->successors()) {
584 if (TBI.Pred == MBB) {
611 const MachineBasicBlock *MBB = MTM.MF->getBlockNumbered(Num);
612 assert(MBB->isPredecessor(TBI.Pred) && "CFG doesn't match trace");
615 const MachineLoop *Loop = getLoopFor(MBB);
616 assert(!(Loop && MBB == Loop->getHeader()) && "Trace contains backedge");
619 const MachineBasicBlock *MBB = MTM.MF->getBlockNumbered(Num);
620 assert(MBB->isSuccessor(TBI.Succ) && "CFG doesn't match trace");
623 const MachineLoop *Loop = getLoopFor(MBB);
834 updateDepth(const MachineBasicBlock *MBB, const MachineInstr &UseMI,
836 updateDepth(BlockInfo[MBB->getNumber()], UseMI, RegUnits);
847 /// Compute instruction depths for all instructions above or in MBB in its
848 /// trace. This assumes that the trace through MBB has already been computed.
850 computeInstrDepths(const MachineBasicBlock *MBB) {
856 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
860 Stack.push_back(MBB);
861 MBB = TBI.Pred;
862 } while (MBB);
864 // FIXME: If MBB is non-null at this point, it is the last pre-computed block
873 MBB = Stack.pop_back_val();
874 LLVM_DEBUG(dbgs() << "\nDepths for " << printMBBReference(*MBB) << ":\n");
875 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
882 ArrayRef<unsigned> PRDepths = getProcResourceDepths(MBB->getNumber());
892 // Also compute the critical path length through MBB when possible.
896 for (const auto &UseMI : *MBB) {
996 for (const MachineBasicBlock *MBB : llvm::reverse(Trace)) {
997 if (MBB == DefMBB)
999 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1005 /// Compute instruction heights in the trace through MBB. This updates MBB and
1009 computeInstrHeights(const MachineBasicBlock *MBB) {
1014 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1018 Stack.push_back(MBB);
1020 MBB = TBI.Succ;
1021 } while (MBB);
1034 // MBB is the highest precomputed block in the trace.
1035 if (MBB) {
1036 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1054 MBB = Stack.back();
1055 LLVM_DEBUG(dbgs() << "Heights for " << printMBBReference(*MBB) << ":\n");
1056 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1062 ArrayRef<unsigned> PRHeights = getProcResourceHeights(MBB->getNumber());
1074 // If MBB is the last block in the trace, and it has a back-edge to the
1078 if (const MachineLoop *Loop = getLoopFor(MBB))
1079 if (MBB->isSuccessor(Loop->getHeader()))
1087 getPHIDeps(PHI, Deps, MBB, MTM.MRI);
1100 for (const MachineInstr &MI : reverse(*MBB)) {
1139 LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << " Live-ins:");
1164 MachineTraceMetrics::Ensemble::getTrace(const MachineBasicBlock *MBB) {
1165 TraceBlockInfo &TBI = BlockInfo[MBB->getNumber()];
1168 computeTrace(MBB);
1170 computeInstrDepths(MBB);
1172 computeInstrHeights(MBB);
1187 const MachineBasicBlock *MBB = TE.MTM.MF->getBlockNumbered(getBlockNum());
1189 getPHIDeps(PHI, Deps, MBB, TE.MTM.MRI);
1190 assert(Deps.size() == 1 && "PHI doesn't have MBB as a predecessor");
1260 for (const MachineBasicBlock *MBB : Extrablocks)
1261 PRCycles += TE.MTM.getProcReleaseAtCycles(MBB->getNumber())[K];
1272 for (const MachineBasicBlock *MBB : Extrablocks)
1273 Instrs += TE.MTM.getResources(MBB)->InstrCount;