From 85e3875ad7461fa8320db6895e0189cffb91ae7d Mon Sep 17 00:00:00 2001 From: Michael Maitland Date: Tue, 22 Aug 2023 17:00:50 -0700 Subject: [TableGen] Rename ResourceCycles and StartAtCycle to clarify semantics D150312 added a TODO: TODO: consider renaming the field `StartAtCycle` and `Cycles` to `AcquireAtCycle` and `ReleaseAtCycle` respectively, to stress the fact that resource allocation is now represented as an interval, relatively to the issue cycle of the instruction. This patch implements that TODO. This naming clarifies how to use these fields in the scheduler. In addition it was confusing that `StartAtCycle` was singular but `Cycles` was plural. This renaming fixes this inconsistency. This commit as previously reverted since it missed renaming that came down after rebasing. This version of the commit fixes those problems. Differential Revision: https://reviews.llvm.org/D158568 --- llvm/lib/CodeGen/MachineTraceMetrics.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'llvm/lib/CodeGen/MachineTraceMetrics.cpp') diff --git a/llvm/lib/CodeGen/MachineTraceMetrics.cpp b/llvm/lib/CodeGen/MachineTraceMetrics.cpp index 4f66f2e..3e6f36f 100644 --- a/llvm/lib/CodeGen/MachineTraceMetrics.cpp +++ b/llvm/lib/CodeGen/MachineTraceMetrics.cpp @@ -71,7 +71,7 @@ bool MachineTraceMetrics::runOnMachineFunction(MachineFunction &Func) { Loops = &getAnalysis(); SchedModel.init(&ST); BlockInfo.resize(MF->getNumBlockIDs()); - ProcResourceCycles.resize(MF->getNumBlockIDs() * + ProcReleaseAtCycles.resize(MF->getNumBlockIDs() * SchedModel.getNumProcResourceKinds()); return false; } @@ -126,7 +126,7 @@ MachineTraceMetrics::getResources(const MachineBasicBlock *MBB) { PI = SchedModel.getWriteProcResBegin(SC), PE = SchedModel.getWriteProcResEnd(SC); PI != PE; ++PI) { assert(PI->ProcResourceIdx < PRKinds && "Bad processor resource kind"); - PRCycles[PI->ProcResourceIdx] += PI->Cycles; + PRCycles[PI->ProcResourceIdx] += PI->ReleaseAtCycle; } } FBI->InstrCount = InstrCount; @@ -134,19 +134,19 @@ MachineTraceMetrics::getResources(const MachineBasicBlock *MBB) { // Scale the resource cycles so they are comparable. unsigned PROffset = MBB->getNumber() * PRKinds; for (unsigned K = 0; K != PRKinds; ++K) - ProcResourceCycles[PROffset + K] = + ProcReleaseAtCycles[PROffset + K] = PRCycles[K] * SchedModel.getResourceFactor(K); return FBI; } ArrayRef -MachineTraceMetrics::getProcResourceCycles(unsigned MBBNum) const { +MachineTraceMetrics::getProcReleaseAtCycles(unsigned MBBNum) const { assert(BlockInfo[MBBNum].hasResources() && - "getResources() must be called before getProcResourceCycles()"); + "getResources() must be called before getProcReleaseAtCycles()"); unsigned PRKinds = SchedModel.getNumProcResourceKinds(); - assert((MBBNum+1) * PRKinds <= ProcResourceCycles.size()); - return ArrayRef(ProcResourceCycles.data() + MBBNum * PRKinds, PRKinds); + assert((MBBNum+1) * PRKinds <= ProcReleaseAtCycles.size()); + return ArrayRef(ProcReleaseAtCycles.data() + MBBNum * PRKinds, PRKinds); } //===----------------------------------------------------------------------===// @@ -197,7 +197,7 @@ computeDepthResources(const MachineBasicBlock *MBB) { // Compute per-resource depths. ArrayRef PredPRDepths = getProcResourceDepths(PredNum); - ArrayRef PredPRCycles = MTM.getProcResourceCycles(PredNum); + ArrayRef PredPRCycles = MTM.getProcReleaseAtCycles(PredNum); for (unsigned K = 0; K != PRKinds; ++K) ProcResourceDepths[PROffset + K] = PredPRDepths[K] + PredPRCycles[K]; } @@ -212,7 +212,7 @@ computeHeightResources(const MachineBasicBlock *MBB) { // Compute resources for the current block. TBI->InstrHeight = MTM.getResources(MBB)->InstrCount; - ArrayRef PRCycles = MTM.getProcResourceCycles(MBB->getNumber()); + ArrayRef PRCycles = MTM.getProcReleaseAtCycles(MBB->getNumber()); // The trace tail is done. if (!TBI->Succ) { @@ -1204,7 +1204,7 @@ unsigned MachineTraceMetrics::Trace::getResourceDepth(bool Bottom) const { unsigned PRMax = 0; ArrayRef PRDepths = TE.getProcResourceDepths(getBlockNum()); if (Bottom) { - ArrayRef PRCycles = TE.MTM.getProcResourceCycles(getBlockNum()); + ArrayRef PRCycles = TE.MTM.getProcReleaseAtCycles(getBlockNum()); for (unsigned K = 0; K != PRDepths.size(); ++K) PRMax = std::max(PRMax, PRDepths[K] + PRCycles[K]); } else { @@ -1248,8 +1248,8 @@ unsigned MachineTraceMetrics::Trace::getResourceLength( PI != PE; ++PI) { if (PI->ProcResourceIdx != ResourceIdx) continue; - Cycles += - (PI->Cycles * TE.MTM.SchedModel.getResourceFactor(ResourceIdx)); + Cycles += (PI->ReleaseAtCycle * + TE.MTM.SchedModel.getResourceFactor(ResourceIdx)); } } return Cycles; @@ -1258,7 +1258,7 @@ unsigned MachineTraceMetrics::Trace::getResourceLength( for (unsigned K = 0; K != PRDepths.size(); ++K) { unsigned PRCycles = PRDepths[K] + PRHeights[K]; for (const MachineBasicBlock *MBB : Extrablocks) - PRCycles += TE.MTM.getProcResourceCycles(MBB->getNumber())[K]; + PRCycles += TE.MTM.getProcReleaseAtCycles(MBB->getNumber())[K]; PRCycles += extraCycles(ExtraInstrs, K); PRCycles -= extraCycles(RemoveInstrs, K); PRMax = std::max(PRMax, PRCycles); -- cgit v1.1