diff options
author | Michael Maitland <michaeltmaitland@gmail.com> | 2023-08-24 11:57:38 -0700 |
---|---|---|
committer | Michael Maitland <michaeltmaitland@gmail.com> | 2023-08-24 11:58:53 -0700 |
commit | 4d27dffb435ff574d32bc71fbcbb5c038fa18d70 (patch) | |
tree | f5afac27c2b1f0c29573bf018de8743461a78b70 /llvm/lib/CodeGen/MachineScheduler.cpp | |
parent | 71c72a9e173473620f19510de5a661d5dc771948 (diff) | |
download | llvm-4d27dffb435ff574d32bc71fbcbb5c038fa18d70.zip llvm-4d27dffb435ff574d32bc71fbcbb5c038fa18d70.tar.gz llvm-4d27dffb435ff574d32bc71fbcbb5c038fa18d70.tar.bz2 |
Revert "[TableGen] Rename ResourceCycles and StartAtCycle to clarify semantics"
This reverts commit 030d33409568b2f0ea61116e83fd40ca27ba33ac.
This commit is causing build failures
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineScheduler.cpp | 113 |
1 files changed, 52 insertions, 61 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp index da3e4bc..556f003 100644 --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -980,8 +980,8 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceTopDown() const { for (TargetSchedModel::ProcResIter PI = SchedModel.getWriteProcResBegin(SC), PE = SchedModel.getWriteProcResEnd(SC); PI != PE; ++PI) { - if (SU->TopReadyCycle + PI->ReleaseAtCycle - 1 > LastCycle) - LastCycle = SU->TopReadyCycle + PI->ReleaseAtCycle - 1; + if (SU->TopReadyCycle + PI->Cycles - 1 > LastCycle) + LastCycle = SU->TopReadyCycle + PI->Cycles - 1; } } // Print the header with the cycles @@ -1017,20 +1017,19 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceTopDown() const { llvm::stable_sort(ResourcesIt, [](const MCWriteProcResEntry &LHS, const MCWriteProcResEntry &RHS) -> bool { - return LHS.AcquireAtCycle < RHS.AcquireAtCycle || - (LHS.AcquireAtCycle == RHS.AcquireAtCycle && - LHS.ReleaseAtCycle < RHS.ReleaseAtCycle); + return LHS.StartAtCycle < RHS.StartAtCycle || + (LHS.StartAtCycle == RHS.StartAtCycle && + LHS.Cycles < RHS.Cycles); }); for (const MCWriteProcResEntry &PI : ResourcesIt) { C = FirstCycle; const std::string ResName = SchedModel.getResourceName(PI.ProcResourceIdx); dbgs() << llvm::right_justify(ResName + " ", HeaderColWidth); - for (; C < SU->TopReadyCycle + PI.AcquireAtCycle; ++C) { + for (; C < SU->TopReadyCycle + PI.StartAtCycle; ++C) { dbgs() << llvm::left_justify("|", ColWidth); } - for (unsigned I = 0, E = PI.ReleaseAtCycle - PI.AcquireAtCycle; I != E; - ++I, ++C) + for (unsigned I = 0, E = PI.Cycles - PI.StartAtCycle; I != E; ++I, ++C) dbgs() << llvm::left_justify("| x", ColWidth); while (C++ <= LastCycle) dbgs() << llvm::left_justify("|", ColWidth); @@ -1062,8 +1061,8 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceBottomUp() const { for (TargetSchedModel::ProcResIter PI = SchedModel.getWriteProcResBegin(SC), PE = SchedModel.getWriteProcResEnd(SC); PI != PE; ++PI) { - if ((int)SU->BotReadyCycle - PI->ReleaseAtCycle + 1 < LastCycle) - LastCycle = (int)SU->BotReadyCycle - PI->ReleaseAtCycle + 1; + if ((int)SU->BotReadyCycle - PI->Cycles + 1 < LastCycle) + LastCycle = (int)SU->BotReadyCycle - PI->Cycles + 1; } } // Print the header with the cycles @@ -1098,20 +1097,19 @@ LLVM_DUMP_METHOD void ScheduleDAGMI::dumpScheduleTraceBottomUp() const { llvm::stable_sort(ResourcesIt, [](const MCWriteProcResEntry &LHS, const MCWriteProcResEntry &RHS) -> bool { - return LHS.AcquireAtCycle < RHS.AcquireAtCycle || - (LHS.AcquireAtCycle == RHS.AcquireAtCycle && - LHS.ReleaseAtCycle < RHS.ReleaseAtCycle); + return LHS.StartAtCycle < RHS.StartAtCycle || + (LHS.StartAtCycle == RHS.StartAtCycle && + LHS.Cycles < RHS.Cycles); }); for (const MCWriteProcResEntry &PI : ResourcesIt) { C = FirstCycle; const std::string ResName = SchedModel.getResourceName(PI.ProcResourceIdx); dbgs() << llvm::right_justify(ResName + " ", HeaderColWidth); - for (; C > ((int)SU->BotReadyCycle - (int)PI.AcquireAtCycle); --C) { + for (; C > ((int)SU->BotReadyCycle - (int)PI.StartAtCycle); --C) { dbgs() << llvm::left_justify("|", ColWidth); } - for (unsigned I = 0, E = PI.ReleaseAtCycle - PI.AcquireAtCycle; I != E; - ++I, --C) + for (unsigned I = 0, E = PI.Cycles - PI.StartAtCycle; I != E; ++I, --C) dbgs() << llvm::left_justify("| x", ColWidth); while (C-- >= LastCycle) dbgs() << llvm::left_justify("|", ColWidth); @@ -2239,9 +2237,8 @@ init(ScheduleDAGMI *DAG, const TargetSchedModel *SchedModel) { PE = SchedModel->getWriteProcResEnd(SC); PI != PE; ++PI) { unsigned PIdx = PI->ProcResourceIdx; unsigned Factor = SchedModel->getResourceFactor(PIdx); - assert(PI->ReleaseAtCycle >= PI->AcquireAtCycle); - RemainingCounts[PIdx] += - (Factor * (PI->ReleaseAtCycle - PI->AcquireAtCycle)); + assert(PI->Cycles >= PI->StartAtCycle); + RemainingCounts[PIdx] += (Factor * (PI->Cycles - PI->StartAtCycle)); } } } @@ -2294,15 +2291,15 @@ unsigned SchedBoundary::getLatencyStallCycles(SUnit *SU) { /// Compute the next cycle at which the given processor resource unit /// can be scheduled. unsigned SchedBoundary::getNextResourceCycleByInstance(unsigned InstanceIdx, - unsigned ReleaseAtCycle, - unsigned AcquireAtCycle) { + unsigned Cycles, + unsigned StartAtCycle) { if (SchedModel && SchedModel->enableIntervals()) { if (isTop()) return ReservedResourceSegments[InstanceIdx].getFirstAvailableAtFromTop( - CurrCycle, AcquireAtCycle, ReleaseAtCycle); + CurrCycle, StartAtCycle, Cycles); return ReservedResourceSegments[InstanceIdx].getFirstAvailableAtFromBottom( - CurrCycle, AcquireAtCycle, ReleaseAtCycle); + CurrCycle, StartAtCycle, Cycles); } unsigned NextUnreserved = ReservedCycles[InstanceIdx]; @@ -2311,7 +2308,7 @@ unsigned SchedBoundary::getNextResourceCycleByInstance(unsigned InstanceIdx, return CurrCycle; // For bottom-up scheduling add the cycles needed for the current operation. if (!isTop()) - NextUnreserved = std::max(CurrCycle, NextUnreserved + ReleaseAtCycle); + NextUnreserved = std::max(CurrCycle, NextUnreserved + Cycles); return NextUnreserved; } @@ -2320,8 +2317,7 @@ unsigned SchedBoundary::getNextResourceCycleByInstance(unsigned InstanceIdx, /// instance in the reserved cycles vector. std::pair<unsigned, unsigned> SchedBoundary::getNextResourceCycle(const MCSchedClassDesc *SC, unsigned PIdx, - unsigned ReleaseAtCycle, - unsigned AcquireAtCycle) { + unsigned Cycles, unsigned StartAtCycle) { if (MischedDetailResourceBooking) { LLVM_DEBUG(dbgs() << " Resource booking (@" << CurrCycle << "c): \n"); LLVM_DEBUG(dumpReservedCycles()); @@ -2350,15 +2346,15 @@ SchedBoundary::getNextResourceCycle(const MCSchedClassDesc *SC, unsigned PIdx, make_range(SchedModel->getWriteProcResBegin(SC), SchedModel->getWriteProcResEnd(SC))) if (ResourceGroupSubUnitMasks[PIdx][PE.ProcResourceIdx]) - return std::make_pair(getNextResourceCycleByInstance( - StartIndex, ReleaseAtCycle, AcquireAtCycle), - StartIndex); + return std::make_pair( + getNextResourceCycleByInstance(StartIndex, Cycles, StartAtCycle), + StartIndex); auto SubUnits = SchedModel->getProcResource(PIdx)->SubUnitsIdxBegin; for (unsigned I = 0, End = NumberOfInstances; I < End; ++I) { unsigned NextUnreserved, NextInstanceIdx; std::tie(NextUnreserved, NextInstanceIdx) = - getNextResourceCycle(SC, SubUnits[I], ReleaseAtCycle, AcquireAtCycle); + getNextResourceCycle(SC, SubUnits[I], Cycles, StartAtCycle); if (MinNextUnreserved > NextUnreserved) { InstanceIdx = NextInstanceIdx; MinNextUnreserved = NextUnreserved; @@ -2370,7 +2366,7 @@ SchedBoundary::getNextResourceCycle(const MCSchedClassDesc *SC, unsigned PIdx, for (unsigned I = StartIndex, End = StartIndex + NumberOfInstances; I < End; ++I) { unsigned NextUnreserved = - getNextResourceCycleByInstance(I, ReleaseAtCycle, AcquireAtCycle); + getNextResourceCycleByInstance(I, Cycles, StartAtCycle); if (MischedDetailResourceBooking) LLVM_DEBUG(dbgs() << " Instance " << I - StartIndex << " available @" << NextUnreserved << "c\n"); @@ -2427,14 +2423,14 @@ bool SchedBoundary::checkHazard(SUnit *SU) { make_range(SchedModel->getWriteProcResBegin(SC), SchedModel->getWriteProcResEnd(SC))) { unsigned ResIdx = PE.ProcResourceIdx; - unsigned ReleaseAtCycle = PE.ReleaseAtCycle; - unsigned AcquireAtCycle = PE.AcquireAtCycle; + unsigned Cycles = PE.Cycles; + unsigned StartAtCycle = PE.StartAtCycle; unsigned NRCycle, InstanceIdx; std::tie(NRCycle, InstanceIdx) = - getNextResourceCycle(SC, ResIdx, ReleaseAtCycle, AcquireAtCycle); + getNextResourceCycle(SC, ResIdx, Cycles, StartAtCycle); if (NRCycle > CurrCycle) { #if LLVM_ENABLE_ABI_BREAKING_CHECKS - MaxObservedStall = std::max(ReleaseAtCycle, MaxObservedStall); + MaxObservedStall = std::max(Cycles, MaxObservedStall); #endif LLVM_DEBUG(dbgs() << " SU(" << SU->NodeNum << ") " << SchedModel->getResourceName(ResIdx) @@ -2576,22 +2572,18 @@ void SchedBoundary::incExecutedResources(unsigned PIdx, unsigned Count) { /// Add the given processor resource to this scheduled zone. /// -/// \param ReleaseAtCycle indicates the number of consecutive (non-pipelined) -/// cycles during which this resource is released. -/// -/// \param AcquireAtCycle indicates the number of consecutive (non-pipelined) -/// cycles at which the resource is aquired after issue (assuming no stalls). +/// \param Cycles indicates the number of consecutive (non-pipelined) cycles +/// during which this resource is consumed. /// /// \return the next cycle at which the instruction may execute without /// oversubscribing resources. unsigned SchedBoundary::countResource(const MCSchedClassDesc *SC, unsigned PIdx, - unsigned ReleaseAtCycle, - unsigned NextCycle, - unsigned AcquireAtCycle) { + unsigned Cycles, unsigned NextCycle, + unsigned StartAtCycle) { unsigned Factor = SchedModel->getResourceFactor(PIdx); - unsigned Count = Factor * (ReleaseAtCycle- AcquireAtCycle); + unsigned Count = Factor * (Cycles - StartAtCycle); LLVM_DEBUG(dbgs() << " " << SchedModel->getResourceName(PIdx) << " +" - << ReleaseAtCycle << "x" << Factor << "u\n"); + << Cycles << "x" << Factor << "u\n"); // Update Executed resources counts. incExecutedResources(PIdx, Count); @@ -2610,7 +2602,7 @@ unsigned SchedBoundary::countResource(const MCSchedClassDesc *SC, unsigned PIdx, // For reserved resources, record the highest cycle using the resource. unsigned NextAvailable, InstanceIdx; std::tie(NextAvailable, InstanceIdx) = - getNextResourceCycle(SC, PIdx, ReleaseAtCycle, AcquireAtCycle); + getNextResourceCycle(SC, PIdx, Cycles, StartAtCycle); if (NextAvailable > CurrCycle) { LLVM_DEBUG(dbgs() << " Resource conflict: " << SchedModel->getResourceName(PIdx) @@ -2689,9 +2681,8 @@ void SchedBoundary::bumpNode(SUnit *SU) { for (TargetSchedModel::ProcResIter PI = SchedModel->getWriteProcResBegin(SC), PE = SchedModel->getWriteProcResEnd(SC); PI != PE; ++PI) { - unsigned RCycle = - countResource(SC, PI->ProcResourceIdx, PI->ReleaseAtCycle, NextCycle, - PI->AcquireAtCycle); + unsigned RCycle = countResource(SC, PI->ProcResourceIdx, PI->Cycles, + NextCycle, PI->StartAtCycle); if (RCycle > NextCycle) NextCycle = RCycle; } @@ -2708,27 +2699,27 @@ void SchedBoundary::bumpNode(SUnit *SU) { if (SchedModel && SchedModel->enableIntervals()) { unsigned ReservedUntil, InstanceIdx; - std::tie(ReservedUntil, InstanceIdx) = getNextResourceCycle( - SC, PIdx, PI->ReleaseAtCycle, PI->AcquireAtCycle); + std::tie(ReservedUntil, InstanceIdx) = + getNextResourceCycle(SC, PIdx, PI->Cycles, PI->StartAtCycle); if (isTop()) { ReservedResourceSegments[InstanceIdx].add( ResourceSegments::getResourceIntervalTop( - NextCycle, PI->AcquireAtCycle, PI->ReleaseAtCycle), + NextCycle, PI->StartAtCycle, PI->Cycles), MIResourceCutOff); } else { ReservedResourceSegments[InstanceIdx].add( ResourceSegments::getResourceIntervalBottom( - NextCycle, PI->AcquireAtCycle, PI->ReleaseAtCycle), + NextCycle, PI->StartAtCycle, PI->Cycles), MIResourceCutOff); } } else { unsigned ReservedUntil, InstanceIdx; - std::tie(ReservedUntil, InstanceIdx) = getNextResourceCycle( - SC, PIdx, PI->ReleaseAtCycle, PI->AcquireAtCycle); + std::tie(ReservedUntil, InstanceIdx) = + getNextResourceCycle(SC, PIdx, PI->Cycles, PI->StartAtCycle); if (isTop()) { ReservedCycles[InstanceIdx] = - std::max(ReservedUntil, NextCycle + PI->ReleaseAtCycle); + std::max(ReservedUntil, NextCycle + PI->Cycles); } else ReservedCycles[InstanceIdx] = NextCycle; } @@ -2926,9 +2917,9 @@ initResourceDelta(const ScheduleDAGMI *DAG, PI = SchedModel->getWriteProcResBegin(SC), PE = SchedModel->getWriteProcResEnd(SC); PI != PE; ++PI) { if (PI->ProcResourceIdx == Policy.ReduceResIdx) - ResDelta.CritResources += PI->ReleaseAtCycle; + ResDelta.CritResources += PI->Cycles; if (PI->ProcResourceIdx == Policy.DemandResIdx) - ResDelta.DemandedResources += PI->ReleaseAtCycle; + ResDelta.DemandedResources += PI->Cycles; } } @@ -4256,7 +4247,7 @@ static bool sortIntervals(const ResourceSegments::IntervalTy &A, } unsigned ResourceSegments::getFirstAvailableAt( - unsigned CurrCycle, unsigned AcquireAtCycle, unsigned Cycle, + unsigned CurrCycle, unsigned StartAtCycle, unsigned Cycle, std::function<ResourceSegments::IntervalTy(unsigned, unsigned, unsigned)> IntervalBuilder) const { assert(std::is_sorted(std::begin(_Intervals), std::end(_Intervals), @@ -4264,7 +4255,7 @@ unsigned ResourceSegments::getFirstAvailableAt( "Cannot execute on an un-sorted set of intervals."); unsigned RetCycle = CurrCycle; ResourceSegments::IntervalTy NewInterval = - IntervalBuilder(RetCycle, AcquireAtCycle, Cycle); + IntervalBuilder(RetCycle, StartAtCycle, Cycle); for (auto &Interval : _Intervals) { if (!intersects(NewInterval, Interval)) continue; @@ -4274,7 +4265,7 @@ unsigned ResourceSegments::getFirstAvailableAt( assert(Interval.second > NewInterval.first && "Invalid intervals configuration."); RetCycle += (unsigned)Interval.second - (unsigned)NewInterval.first; - NewInterval = IntervalBuilder(RetCycle, AcquireAtCycle, Cycle); + NewInterval = IntervalBuilder(RetCycle, StartAtCycle, Cycle); } return RetCycle; } |