// Update resource-related information in the TraceBlockInfo for MBB. // Only update resources related to the trace below MBB. void MachineTraceMetrics::Ensemble:: computeHeightResources(const MachineBasicBlock *MBB) { TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()]; unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds(); unsigned PROffset = MBB->getNumber() * PRKinds; // Compute resources for the current block. TBI->InstrHeight = MTM.getResources(MBB)->InstrCount; ArrayRef<unsigned> PRCycles = MTM.getProcResourceCycles(MBB->getNumber()); // The trace tail is done. if (!TBI->Succ) { TBI->Tail = MBB->getNumber(); std::copy(PRCycles.begin(), PRCycles.end(), ProcResourceHeights.begin() + PROffset); return; } // Compute from the block below. A post-order traversal ensures the // predecessor is always computed first. unsigned SuccNum = TBI->Succ->getNumber(); TraceBlockInfo *SuccTBI = &BlockInfo[SuccNum]; assert(SuccTBI->hasValidHeight() && "Trace below has not been computed yet"); TBI->InstrHeight += SuccTBI->InstrHeight; TBI->Tail = SuccTBI->Tail; // Compute per-resource heights. ArrayRef<unsigned> SuccPRHeights = getProcResourceHeights(SuccNum); for (unsigned K = 0; K != PRKinds; ++K) ProcResourceHeights[PROffset + K] = SuccPRHeights[K] + PRCycles[K]; }
// Update resource-related information in the TraceBlockInfo for MBB. // Only update resources related to the trace above MBB. void MachineTraceMetrics::Ensemble:: computeDepthResources(const MachineBasicBlock *MBB) { TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()]; unsigned PRKinds = MTM.SchedModel.getNumProcResourceKinds(); unsigned PROffset = MBB->getNumber() * PRKinds; // Compute resources from trace above. The top block is simple. if (!TBI->Pred) { TBI->InstrDepth = 0; TBI->Head = MBB->getNumber(); std::fill(ProcResourceDepths.begin() + PROffset, ProcResourceDepths.begin() + PROffset + PRKinds, 0); return; } // Compute from the block above. A post-order traversal ensures the // predecessor is always computed first. unsigned PredNum = TBI->Pred->getNumber(); TraceBlockInfo *PredTBI = &BlockInfo[PredNum]; assert(PredTBI->hasValidDepth() && "Trace above has not been computed yet"); const FixedBlockInfo *PredFBI = MTM.getResources(TBI->Pred); TBI->InstrDepth = PredTBI->InstrDepth + PredFBI->InstrCount; TBI->Head = PredTBI->Head; // Compute per-resource depths. ArrayRef<unsigned> PredPRDepths = getProcResourceDepths(PredNum); ArrayRef<unsigned> PredPRCycles = MTM.getProcResourceCycles(PredNum); for (unsigned K = 0; K != PRKinds; ++K) ProcResourceDepths[PROffset + K] = PredPRDepths[K] + PredPRCycles[K]; }
// Update resource-related information in the TraceBlockInfo for MBB. // Only update resources related to the trace above MBB. void MachineTraceMetrics::Ensemble:: computeDepthResources(const MachineBasicBlock *MBB) { TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()]; // Compute resources from trace above. The top block is simple. if (!TBI->Pred) { TBI->InstrDepth = 0; TBI->Head = MBB->getNumber(); return; } // Compute from the block above. A post-order traversal ensures the // predecessor is always computed first. TraceBlockInfo *PredTBI = &BlockInfo[TBI->Pred->getNumber()]; assert(PredTBI->hasValidDepth() && "Trace above has not been computed yet"); const FixedBlockInfo *PredFBI = MTM.getResources(TBI->Pred); TBI->InstrDepth = PredTBI->InstrDepth + PredFBI->InstrCount; TBI->Head = PredTBI->Head; }
// Update resource-related information in the TraceBlockInfo for MBB. // Only update resources related to the trace below MBB. void MachineTraceMetrics::Ensemble:: computeHeightResources(const MachineBasicBlock *MBB) { TraceBlockInfo *TBI = &BlockInfo[MBB->getNumber()]; // Compute resources for the current block. TBI->InstrHeight = MTM.getResources(MBB)->InstrCount; // The trace tail is done. if (!TBI->Succ) { TBI->Tail = MBB->getNumber(); return; } // Compute from the block below. A post-order traversal ensures the // predecessor is always computed first. TraceBlockInfo *SuccTBI = &BlockInfo[TBI->Succ->getNumber()]; assert(SuccTBI->hasValidHeight() && "Trace below has not been computed yet"); TBI->InstrHeight += SuccTBI->InstrHeight; TBI->Tail = SuccTBI->Tail; }