44#define DEBUG_TYPE "machine-scheduler"
51 return O.error(
"'" + Arg +
"' value invalid for uint argument!");
54 return O.error(
"'" + Arg +
"' value must be in the range [0, 100]!");
61 cl::desc(
"Percent of VGPR limits that we should use as RP threshold "
62 "during scheduling. We have two limits relevant to scheduling: "
63 "Critical (avoid decreasing occupancy), Excess (avoid spilling). "
64 "This flag scales both limits back by an equal percent: (0 = use "
65 " default calculation, 1-100 = use percentage), default: 0"),
88 Context->RegClassInfo->getNumAllocatableRegs(&AMDGPU::SGPR_32RegClass);
90 Context->RegClassInfo->getNumAllocatableRegs(&AMDGPU::VGPR_32RegClass);
92 Context->RegClassInfo->getNumAllocatableRegs(&AMDGPU::AGPR_32RegClass);
120 "VGPRCriticalLimit calculation method.\n");
124 unsigned Addressable =
127 VGPRBudget = std::max(VGPRBudget, Granule);
146 <<
". VGPRCriticalLimit: " << OriginalVGPRCriticalLimit
164 <<
", UnifiedVGPRCriticalLimit = "
197 if (!
Op.isReg() ||
Op.isImplicit())
199 if (
Op.getReg().isPhysical() ||
200 (
Op.isDef() &&
Op.getSubReg() != AMDGPU::NoSubRegister))
206std::pair<unsigned, unsigned>
208 if (!
CLOpts.avgpr_banking)
209 return {RP.getArchVGPRNum(), RP.getAGPRNum()};
217 std::vector<unsigned> &Pressure,
218 std::vector<unsigned> &MaxPressure) {
241 unsigned SGPRPressure,
242 unsigned VGPRPressure,
243 unsigned AGPRPressure,
bool IsBottomUp) {
247 if (!
DAG->isTrackingPressure())
250 unsigned NewSGPRPressure, NewVGPRPressure, NewAGPRPressure;
252 unsigned CandUnifiedVGPRPressure = 0;
258 NewVGPRPressure, NewAGPRPressure);
279 Pressure[AMDGPU::RegisterPressureSets::SReg_32] = SGPRPressure;
280 Pressure[AMDGPU::RegisterPressureSets::VGPR_32] = VGPRPressure;
281 Pressure[AMDGPU::RegisterPressureSets::AGPR_32] = AGPRPressure;
283 for (
const auto &Diff :
DAG->getPressureDiff(SU)) {
289 (IsBottomUp ? Diff.getUnitInc() : -Diff.getUnitInc());
292#ifdef EXPENSIVE_CHECKS
293 std::vector<unsigned> CheckPressure, CheckMaxPressure;
296 if (
Pressure[AMDGPU::RegisterPressureSets::SReg_32] !=
297 CheckPressure[AMDGPU::RegisterPressureSets::SReg_32] ||
298 Pressure[AMDGPU::RegisterPressureSets::VGPR_32] !=
299 CheckPressure[AMDGPU::RegisterPressureSets::VGPR_32] ||
300 Pressure[AMDGPU::RegisterPressureSets::AGPR_32] !=
301 CheckPressure[AMDGPU::RegisterPressureSets::AGPR_32]) {
302 errs() <<
"Register Pressure is inaccurate when calculated through "
304 <<
"SGPR got " <<
Pressure[AMDGPU::RegisterPressureSets::SReg_32]
306 << CheckPressure[AMDGPU::RegisterPressureSets::SReg_32] <<
"\n"
307 <<
"VGPR got " <<
Pressure[AMDGPU::RegisterPressureSets::VGPR_32]
309 << CheckPressure[AMDGPU::RegisterPressureSets::VGPR_32] <<
"\n"
310 <<
"AGPR got " <<
Pressure[AMDGPU::RegisterPressureSets::AGPR_32]
312 << CheckPressure[AMDGPU::RegisterPressureSets::AGPR_32] <<
"\n";
318 NewSGPRPressure =
Pressure[AMDGPU::RegisterPressureSets::SReg_32];
319 NewVGPRPressure =
Pressure[AMDGPU::RegisterPressureSets::VGPR_32];
320 NewAGPRPressure =
Pressure[AMDGPU::RegisterPressureSets::AGPR_32];
331 const unsigned MaxVGPRPressureInc = 16;
332 bool ShouldTrackVGPRs = VGPRPressure + MaxVGPRPressureInc >=
VGPRExcessLimit;
335 bool ShouldTrackSGPRs =
336 !ShouldTrackVGPRs && !ShouldTrackAGPRs && SGPRPressure >=
SGPRExcessLimit;
373 Excess.
getPSet() != AMDGPU::RegisterPressureSets::SReg_32;
374 if (!HasBankExcess || UnifiedExcess > Excess.
getUnitInc()) {
388 bool UnifiedVGPRFile =
MF->getSubtarget<
GCNSubtarget>().hasGFX90AInsts();
390 if (UnifiedVGPRFile) {
398 int VGPRDelta = NewVGPRPressure - VectorCriticalLimit;
401 : std::numeric_limits<int>::min();
403 if (SGPRDelta >= 0 || VGPRDelta >= 0 || AGPRDelta >= 0) {
406 if (VGPRDelta >= SGPRDelta && VGPRDelta >= AGPRDelta) {
410 }
else if (AGPRDelta >= SGPRDelta) {
424 bool HasBufferedModel =
427 return Combined <= PendingQueueLimit && HasBufferedModel;
444 dbgs() <<
"Prefer:\t\t";
445 DAG->dumpNode(*Preferred.
SU);
449 DAG->dumpNode(*Current.
SU);
452 dbgs() <<
"Reason:\t\t";
466 unsigned SGPRPressure = 0;
467 unsigned VGPRPressure = 0;
468 unsigned AGPRPressure = 0;
470 if (
DAG->isTrackingPressure()) {
472 SGPRPressure =
Pressure[AMDGPU::RegisterPressureSets::SReg_32];
473 VGPRPressure =
Pressure[AMDGPU::RegisterPressureSets::VGPR_32];
474 AGPRPressure =
Pressure[AMDGPU::RegisterPressureSets::AGPR_32];
479 SGPRPressure =
T->getPressure().getSGPRNum();
480 std::tie(VGPRPressure, AGPRPressure) =
486 for (
SUnit *SU : AQ) {
490 VGPRPressure, AGPRPressure, IsBottomUp);
511 for (
SUnit *SU : PQ) {
515 VGPRPressure, AGPRPressure, IsBottomUp);
535 bool &PickedPending) {
557 bool BotPending =
false;
577 "Last pick result should correspond to re-picking right now");
582 bool TopPending =
false;
602 "Last pick result should correspond to re-picking right now");
612 PickedPending = BotPending && TopPending;
615 if (BotPending || TopPending) {
622 Cand.setBest(TryCand);
627 IsTopNode = Cand.AtTop;
634 if (
DAG->top() ==
DAG->bottom()) {
636 Bot.Available.empty() &&
Bot.Pending.empty() &&
"ReadyQ garbage");
642 PickedPending =
false;
678 if (ReadyCycle > CurrentCycle)
743 if (
DAG->isTrackingPressure() &&
749 if (
DAG->isTrackingPressure() &&
754 bool SameBoundary = Zone !=
nullptr;
773 if (
CLOpts.rewrite_mfma_form_sched_stage)
778 if (IsLegacyScheduler)
797 if (
DAG->isTrackingPressure() &&
807 bool SameBoundary = Zone !=
nullptr;
842 bool CandIsClusterSucc =
844 bool TryCandIsClusterSucc =
846 if (
tryGreater(TryCandIsClusterSucc, CandIsClusterSucc, TryCand, Cand,
851 if (
DAG->isTrackingPressure() &&
857 if (
DAG->isTrackingPressure() &&
903 if (
DAG->isTrackingPressure()) {
919 bool CandIsClusterSucc =
921 bool TryCandIsClusterSucc =
923 if (
tryGreater(TryCandIsClusterSucc, CandIsClusterSucc, TryCand, Cand,
932 bool SameBoundary = Zone !=
nullptr;
949 if (TryMayLoad || CandMayLoad) {
950 bool TryLongLatency =
952 bool CandLongLatency =
956 Zone->
isTop() ? CandLongLatency : TryLongLatency, TryCand,
974 if (
DAG->isTrackingPressure() &&
993 !
Rem.IsAcyclicLatencyLimited &&
tryLatency(TryCand, Cand, *Zone))
1011 StartingOccupancy(MFI.getOccupancy()), MinOccupancy(StartingOccupancy),
1012 RegionLiveOuts(this,
true) {
1018 LLVM_DEBUG(
dbgs() <<
"Starting occupancy is " << StartingOccupancy <<
".\n");
1019 if (ST.getCLOpts().schedule_relaxed_occupancy) {
1020 MinOccupancy = std::min(MFI.getMinAllowedOccupancy(), StartingOccupancy);
1021 if (MinOccupancy != StartingOccupancy)
1022 LLVM_DEBUG(
dbgs() <<
"Allowing Occupancy drops to " << MinOccupancy
1027std::unique_ptr<GCNSchedStage>
1029 switch (SchedStageID) {
1031 return std::make_unique<OccInitialScheduleStage>(SchedStageID, *
this);
1033 return std::make_unique<RewriteMFMAFormStage>(SchedStageID, *
this);
1035 return std::make_unique<UnclusteredHighRPStage>(SchedStageID, *
this);
1037 return std::make_unique<ClusteredLowOccStage>(SchedStageID, *
this);
1039 return std::make_unique<PreRARematStage>(SchedStageID, *
this);
1041 return std::make_unique<ILPInitialScheduleStage>(SchedStageID, *
this);
1043 return std::make_unique<MemoryClauseInitialScheduleStage>(SchedStageID,
1046 return std::make_unique<LiveIntervalRPStage>(SchedStageID, *
this);
1060 std::function<
void(
const GCNRegPressure &)> PressureCallback)
const {
1061 if (Regions[RegionIdx].first == Regions[RegionIdx].second) {
1063 if (PressureCallback)
1064 PressureCallback(RP);
1069 RPTracker.
reset(*Regions[RegionIdx].first, Regions[RegionIdx].second,
1070 &LiveIns[RegionIdx]);
1072 if (PressureCallback) {
1074 RPTracker.setPressureCallback(std::move(PressureCallback));
1077 RPTracker.advance(Regions[RegionIdx].second);
1083 assert(RegionBegin != RegionEnd &&
"Region must not be empty");
1087void GCNScheduleDAGMILive::computeBlockPressure(
unsigned RegionIdx,
1099 const MachineBasicBlock *OnlySucc =
nullptr;
1102 if (!Candidate->empty() && Candidate->pred_size() == 1) {
1103 SlotIndexes *Ind =
LIS->getSlotIndexes();
1105 OnlySucc = Candidate;
1110 size_t CurRegion = RegionIdx;
1111 for (
size_t E = Regions.size(); CurRegion !=
E; ++CurRegion)
1112 if (Regions[CurRegion].first->getParent() !=
MBB)
1117 auto LiveInIt = MBBLiveIns.find(
MBB);
1118 auto &Rgn = Regions[CurRegion];
1120 if (LiveInIt != MBBLiveIns.end()) {
1121 auto LiveIn = std::move(LiveInIt->second);
1123 MBBLiveIns.erase(LiveInIt);
1126 auto LRS = BBLiveInMap.lookup(NonDbgMI);
1127#ifdef EXPENSIVE_CHECKS
1136 if (Regions[CurRegion].first ==
I || NonDbgMI ==
I) {
1137 LiveIns[CurRegion] =
RPTracker.getLiveRegs();
1141 if (Regions[CurRegion].second ==
I) {
1142 Pressure[CurRegion] =
RPTracker.moveMaxPressure();
1143 if (CurRegion-- == RegionIdx)
1145 auto &Rgn = Regions[CurRegion];
1158 MBBLiveIns[OnlySucc] =
RPTracker.moveLiveRegs();
1163GCNScheduleDAGMILive::getRegionLiveInMap()
const {
1164 assert(!Regions.empty());
1165 std::vector<MachineInstr *> RegionFirstMIs;
1166 RegionFirstMIs.reserve(Regions.size());
1168 RegionFirstMIs.push_back(
1175GCNScheduleDAGMILive::getRegionLiveOutMap()
const {
1176 assert(!Regions.empty());
1177 std::vector<MachineInstr *> RegionLastMIs;
1178 RegionLastMIs.reserve(Regions.size());
1189 IdxToInstruction.clear();
1192 IsLiveOut ? DAG->getRegionLiveOutMap() : DAG->getRegionLiveInMap();
1193 for (
unsigned I = 0;
I < DAG->Regions.size();
I++) {
1194 auto &[RegionBegin, RegionEnd] = DAG->Regions[
I];
1196 if (RegionBegin == RegionEnd)
1200 IdxToInstruction[
I] = RegionKey;
1208 LiveIns.resize(Regions.size());
1209 Pressure.resize(Regions.size());
1210 RegionsWithHighRP.resize(
static_cast<unsigned>(Regions.size()));
1211 RegionsWithExcessRP.resize(
static_cast<unsigned>(Regions.size()));
1212 RegionsWithIGLPInstrs.resize(
static_cast<unsigned>(Regions.size()));
1213 RegionsWithHighRP.reset();
1214 RegionsWithExcessRP.reset();
1215 RegionsWithIGLPInstrs.reset();
1220void GCNScheduleDAGMILive::runSchedStages() {
1221 LLVM_DEBUG(
dbgs() <<
"All regions recorded, starting actual scheduling.\n");
1224 if (!Regions.
empty()) {
1225 BBLiveInMap = getRegionLiveInMap();
1231 if (ST.
getCLOpts().print_max_reg_pressure_regusage_before_scheduler) {
1240 if (!Stage->initGCNSchedStage())
1243 for (
auto Region : Regions) {
1247 if (!Stage->initGCNRegion()) {
1248 Stage->advanceRegion();
1254 const unsigned RegionIdx = Stage->getRegionIdx();
1257 MRI, RegionLiveOuts.getLiveRegsForRegionIdx(RegionIdx));
1261 Stage->finalizeGCNRegion();
1262 Stage->advanceRegion();
1266 Stage->finalizeGCNSchedStage();
1270 if (ST.getCLOpts().print_max_reg_pressure_regusage_after_scheduler) {
1282 OS <<
"Max Occupancy Initial Schedule";
1285 OS <<
"Instruction Rewriting Reschedule";
1288 OS <<
"Unclustered High Register Pressure Reschedule";
1291 OS <<
"Clustered Low Occupancy Reschedule";
1294 OS <<
"Pre-RA Rematerialize";
1297 OS <<
"Max ILP Initial Schedule";
1300 OS <<
"Max memory clause Initial Schedule";
1303 OS <<
"Live Interval RP Reschedule";
1323void RewriteMFMAFormStage::findReachingDefs(
1345 while (!Worklist.
empty()) {
1360 for (MachineBasicBlock *PredMBB : DefMBB->
predecessors()) {
1361 if (Visited.
insert(PredMBB).second)
1367void RewriteMFMAFormStage::findReachingUses(
1371 for (MachineOperand &UseMO :
1374 findReachingDefs(UseMO, LIS, ReachingDefIndexes);
1378 if (
any_of(ReachingDefIndexes, [DefIdx](SlotIndex RDIdx) {
1390 if (!
ST.hasGFX90AInsts() ||
MFI.getMinWavesPerEU() > 1)
1393 RegionsWithExcessArchVGPR.resize(
static_cast<unsigned>(
DAG.Regions.size()));
1394 RegionsWithExcessArchVGPR.reset();
1398 RegionsWithExcessArchVGPR[
Region] =
true;
1401 if (RegionsWithExcessArchVGPR.none())
1404 TII =
ST.getInstrInfo();
1405 SRI =
ST.getRegisterInfo();
1407 std::vector<std::pair<MachineInstr *, unsigned>> RewriteCands;
1411 if (!initHeuristics(RewriteCands, CopyForUse, CopyForDef))
1414 int64_t
Cost = getRewriteCost(RewriteCands, CopyForUse, CopyForDef);
1421 return rewrite(RewriteCands);
1425 if (!
ST.getCLOpts().unclustered_high_rp_reschedule)
1431 if (
DAG.RegionsWithHighRP.none() &&
DAG.RegionsWithExcessRP.none())
1438 InitialOccupancy =
DAG.MinOccupancy;
1441 TempTargetOccupancy =
MFI.getMaxWavesPerEU() >
DAG.MinOccupancy
1442 ? InitialOccupancy + 1
1444 IsAnyRegionScheduled =
false;
1445 S.SGPRLimitBias =
S.HighRPSGPRBias;
1446 S.VGPRLimitBias =
S.HighRPVGPRBias;
1450 <<
"Retrying function scheduling without clustering. "
1451 "Aggressively try to reduce register pressure to achieve occupancy "
1452 << TempTargetOccupancy <<
".\n");
1458 if (!
ST.getCLOpts().clustered_low_occupancy_reschedule)
1467 if (
DAG.StartingOccupancy <=
DAG.MinOccupancy)
1471 dbgs() <<
"Retrying function scheduling with lowest recorded occupancy "
1472 <<
DAG.MinOccupancy <<
".\n");
1487 unsigned MaxSGPRs =
ST.getMaxNumSGPRs(
F);
1488 unsigned MaxVGPRs =
ST.getMaxNumVGPRs(
F);
1490 const unsigned VGPRBlockSize =
MFI.getDynamicVGPRBlockSize();
1491 bool HasVectorRegisterExcess =
false;
1493 if (
GCNRPTarget(MaxSGPRs, MaxVGPRs,
MF, RP).hasVectorRegisterExcess()) {
1494 HasVectorRegisterExcess =
true;
1498 if (HasVectorRegisterExcess ||
DAG.MinOccupancy >=
MFI.getMaxWavesPerEU()) {
1501 TargetOcc = std::nullopt;
1505 TargetOcc =
DAG.MinOccupancy + 1;
1506 MaxSGPRs =
ST.getMaxNumSGPRs(*TargetOcc,
false);
1507 MaxVGPRs =
ST.getMaxNumVGPRs(*TargetOcc, VGPRBlockSize);
1511 dbgs() <<
"In function ";
1512 MF.getFunction().printAsOperand(
dbgs(),
false);
1513 dbgs() <<
": rematerializing to ";
1515 dbgs() <<
"increase occupancy from " << *TargetOcc - 1 <<
'\n';
1517 dbgs() <<
"reduce spilling (minimum target occupancy is "
1518 <<
MFI.getMinWavesPerEU() <<
")\n";
1522 LiveOuts.reserve(
DAG.Regions.size());
1523 DAG.RegionLiveOuts.buildLiveRegMap();
1525 LiveOuts.push_back(
DAG.RegionLiveOuts.getLiveRegsForRegionIdx(
RegionIdx));
1527 Strategy = std::make_unique<GCNRematStrategy>(
MF,
DAG.Regions,
DAG.LiveIns,
1528 LiveOuts, *
DAG.LIS, *
DAG.MBFI);
1529 if (TargetOcc.has_value()) {
1536 Strategy->startRecordingRemats();
1539 RescheduleRegions.resize(
DAG.Regions.size());
1541 Strategy->rematerializeFor(MaxSGPRs, MaxVGPRs,
1542 !TargetOcc.has_value(),
1543 RescheduleRegions, &MaxPressure);
1544 if (RescheduleRegions.none())
1549 for (
unsigned RegionIdx : RescheduleRegions.set_bits()) {
1555 AchievedOcc =
MFI.getMaxWavesPerEU();
1557 AchievedOcc = std::min(AchievedOcc, RP.getOccupancy(
ST, VGPRBlockSize));
1560 dbgs() <<
"Retrying function scheduling with new min. occupancy of "
1561 << AchievedOcc <<
" from rematerializing (original was "
1562 <<
DAG.MinOccupancy;
1564 dbgs() <<
", target was " << *TargetOcc;
1568 DAG.setTargetOccupancy(getStageTargetOccupancy());
1579 S.SGPRLimitBias =
S.VGPRLimitBias = 0;
1580 if (
DAG.MinOccupancy > InitialOccupancy) {
1581 assert(IsAnyRegionScheduled);
1583 <<
" stage successfully increased occupancy to "
1584 <<
DAG.MinOccupancy <<
'\n');
1585 }
else if (!IsAnyRegionScheduled) {
1586 assert(
DAG.MinOccupancy == InitialOccupancy);
1588 <<
": No regions scheduled, min occupancy stays at "
1589 <<
DAG.MinOccupancy <<
", MFI occupancy stays at "
1590 <<
MFI.getOccupancy() <<
".\n");
1598 if (
DAG.begin() ==
DAG.end())
1605 unsigned NumRegionInstrs =
1606 static_cast<unsigned>(std::distance(
DAG.begin(),
DAG.end()));
1610 if (
DAG.begin() == std::prev(
DAG.end()))
1616 <<
"\n From: " << *
DAG.begin() <<
" To: ";
1618 else dbgs() <<
"End";
1619 dbgs() <<
" RegionInstrs: " << NumRegionInstrs <<
'\n');
1627 for (
auto &
I :
DAG) {
1640 dbgs() <<
"Pressure before scheduling:\nRegion live-ins:"
1642 <<
"Region live-in pressure: "
1646 S.HasHighPressure =
false;
1668 unsigned DynamicVGPRBlockSize =
DAG.MFI.getDynamicVGPRBlockSize();
1671 unsigned CurrentTargetOccupancy =
1672 IsAnyRegionScheduled ?
DAG.MinOccupancy : TempTargetOccupancy;
1674 (CurrentTargetOccupancy <= InitialOccupancy ||
1675 DAG.Pressure[
RegionIdx].getOccupancy(
ST, DynamicVGPRBlockSize) !=
1682 if (!IsAnyRegionScheduled && IsSchedulingThisRegion) {
1683 IsAnyRegionScheduled =
true;
1684 if (
MFI.getMaxWavesPerEU() >
DAG.MinOccupancy)
1685 DAG.setTargetOccupancy(TempTargetOccupancy);
1687 return IsSchedulingThisRegion;
1703 return !RevertAllRegions && RescheduleRegions[
RegionIdx] &&
1723 if (
S.HasHighPressure)
1744 if (
DAG.MinOccupancy < *TargetOcc) {
1746 <<
" cannot meet occupancy target, interrupting "
1747 "re-scheduling in all regions\n");
1748 RevertAllRegions =
true;
1755 unsigned MaxVGPRs =
ST.getMaxNumVGPRs(
MF);
1758 unsigned MaxArchVGPRs = std::min(MaxVGPRs,
ST.getAddressableNumArchVGPRs());
1763 bool AVGPRBanking =
ST.getCLOpts().avgpr_banking;
1764 unsigned ArchVGPRBankLimit, AGPRBankLimit;
1765 std::tie(ArchVGPRBankLimit, AGPRBankLimit) =
S.getBankLimits();
1766 unsigned BankedArchVGPRPeak = 0, BankedAGPRPeak = 0, BankedUnifiedPeak = 0;
1770 auto [ArchNum, AccNum] =
1771 RP.getBankedVGPRNum(ArchVGPRBankLimit, AGPRBankLimit);
1772 BankedArchVGPRPeak = std::max(BankedArchVGPRPeak, ArchNum);
1773 BankedAGPRPeak = std::max(BankedAGPRPeak, AccNum);
1775 std::max(BankedUnifiedPeak,
1786 unsigned DynamicVGPRBlockSize =
DAG.MFI.getDynamicVGPRBlockSize();
1788 bool UnifiedVGPRFile =
ST.hasGFX90AInsts();
1789 unsigned VectorCriticalLimit =
1790 UnifiedVGPRFile ?
S.UnifiedVGPRCriticalLimit :
S.VGPRCriticalLimit;
1794 PressureAfter.getVGPRNum(UnifiedVGPRFile) <= VectorCriticalLimit &&
1795 (!UnifiedVGPRFile ||
1805 unsigned TargetOccupancy = std::min(
1806 S.getTargetOccupancy(),
ST.getOccupancyWithWorkGroupSizes(
MF).second);
1807 unsigned WavesAfter = std::min(
1808 TargetOccupancy,
PressureAfter.getOccupancy(
ST, DynamicVGPRBlockSize));
1809 unsigned WavesBefore = std::min(
1811 LLVM_DEBUG(
dbgs() <<
"Occupancy before scheduling: " << WavesBefore
1812 <<
", after " << WavesAfter <<
".\n");
1818 unsigned NewOccupancy = std::max(WavesAfter, WavesBefore);
1822 if (WavesAfter < WavesBefore && WavesAfter <
DAG.MinOccupancy &&
1823 WavesAfter >=
MFI.getMinAllowedOccupancy()) {
1824 LLVM_DEBUG(
dbgs() <<
"Function is memory bound, allow occupancy drop up to "
1825 <<
MFI.getMinAllowedOccupancy() <<
" waves\n");
1826 NewOccupancy = WavesAfter;
1829 if (NewOccupancy <
DAG.MinOccupancy) {
1830 DAG.MinOccupancy = NewOccupancy;
1831 MFI.limitOccupancy(
DAG.MinOccupancy);
1833 <<
DAG.MinOccupancy <<
".\n");
1835 unsigned MaxSGPRs =
ST.getMaxNumSGPRs(
MF);
1837 bool BankExcess = AVGPRBanking
1838 ? BankedArchVGPRPeak > ArchVGPRBankLimit ||
1839 BankedAGPRPeak > AGPRBankLimit
1843 unsigned VGPRNum = AVGPRBanking && UnifiedVGPRFile
1846 if (VGPRNum > MaxVGPRs || BankExcess ||
1866 unsigned ReadyCycle = CurrCycle;
1867 for (
auto &
D : SU.
Preds) {
1868 if (
D.isAssignedRegDep()) {
1871 unsigned DefReady = ReadyCycles[
DAG.getSUnit(
DefMI)->NodeNum];
1872 ReadyCycle = std::max(ReadyCycle, DefReady +
Latency);
1875 ReadyCycles[SU.
NodeNum] = ReadyCycle;
1882 std::pair<MachineInstr *, unsigned>
B)
const {
1883 return A.second <
B.second;
1889 if (ReadyCycles.empty())
1891 unsigned BBNum = ReadyCycles.begin()->first->getParent()->getNumber();
1892 dbgs() <<
"\n################## Schedule time ReadyCycles for MBB : " << BBNum
1893 <<
" ##################\n# Cycle #\t\t\tInstruction "
1897 for (
auto &
I : ReadyCycles) {
1898 if (
I.second > IPrev + 1)
1899 dbgs() <<
"****************************** BUBBLE OF " <<
I.second - IPrev
1900 <<
" CYCLES DETECTED ******************************\n\n";
1901 dbgs() <<
"[ " <<
I.second <<
" ] : " << *
I.first <<
"\n";
1914 unsigned SumBubbles = 0;
1916 unsigned CurrCycle = 0;
1917 for (
auto &SU : InputSchedule) {
1918 unsigned ReadyCycle =
1920 SumBubbles += ReadyCycle - CurrCycle;
1922 ReadyCyclesSorted.insert(std::make_pair(SU.getInstr(), ReadyCycle));
1924 CurrCycle = ++ReadyCycle;
1947 unsigned SumBubbles = 0;
1949 unsigned CurrCycle = 0;
1950 for (
auto &
MI :
DAG) {
1954 unsigned ReadyCycle =
1956 SumBubbles += ReadyCycle - CurrCycle;
1958 ReadyCyclesSorted.insert(std::make_pair(SU->
getInstr(), ReadyCycle));
1960 CurrCycle = ++ReadyCycle;
1977 if (WavesAfter <
DAG.MinOccupancy)
1981 if (
DAG.MFI.isDynamicVGPREnabled()) {
1984 DAG.MFI.getDynamicVGPRBlockSize());
1987 if (BlocksAfter > BlocksBefore)
2029 <<
"\n\t *** In shouldRevertScheduling ***\n"
2030 <<
" *********** BEFORE UnclusteredHighRPStage ***********\n");
2034 <<
"\n *********** AFTER UnclusteredHighRPStage ***********\n");
2036 unsigned OldMetric = MBefore.
getMetric();
2037 unsigned NewMetric = MAfter.
getMetric();
2038 unsigned ScheduleMetricBias =
ST.getCLOpts().schedule_metric_bias;
2039 unsigned WavesBefore = std::min(
2040 S.getTargetOccupancy(),
2047 LLVM_DEBUG(
dbgs() <<
"\tMetric before " << MBefore <<
"\tMetric after "
2048 << MAfter <<
"Profit: " << Profit <<
"\n");
2078 unsigned WavesAfter) {
2083 if (!
ST.getCLOpts().lirp_reschedule)
2089 if (!
S.VGPRThresholdPercent) {
2090 LLVM_DEBUG(
dbgs() <<
"LIRP: expected VGPRThresholdPercent to be enabled, "
2091 "not using live interval RP reschedule stage\n");
2099 const AMDGPUOptions &CLOpts =
ST.getCLOpts();
2100 unsigned InstantRP =
DAG.Pressure[
RegionIdx].getArchVGPRNum();
2101 auto [RegionBegin, RegionEnd] =
DAG.Regions[
RegionIdx];
2102 if (RegionBegin == RegionEnd)
2109 unsigned NewVGPRThresholdPercent =
2110 (
S.VGPRThresholdPercent * CLOpts.lirp_vgpr_reduction + 99) / 100;
2113 <<
", VGPRThresholdPercent: " <<
S.VGPRThresholdPercent
2114 <<
" -> " << NewVGPRThresholdPercent
2115 <<
", VGPRExcessLimit=" <<
S.VGPRExcessLimit
2116 <<
", VGPRCriticalLimit=" <<
S.VGPRCriticalLimit
2117 <<
", InstantRP=" << InstantRP <<
", LIRP=" << LIRP);
2119 bool DoRescheduling =
false;
2121 unsigned InstantRPLowerBound =
2122 S.VGPRExcessLimit * CLOpts.lirp_instant_lower_bound / 100;
2123 if (LIRP >
S.VGPRExcessLimit) {
2124 LLVM_DEBUG(
dbgs() <<
" [LIRP exceeds the limit (" <<
S.VGPRExcessLimit
2125 <<
"), rescheduling]");
2126 DoRescheduling =
true;
2127 }
else if (LIRP > InstantRP && InstantRP > InstantRPLowerBound) {
2128 unsigned IncreasePercent = ((LIRP - InstantRP) * 100) / InstantRP;
2129 if (IncreasePercent > CLOpts.lirp_threshold) {
2131 << CLOpts.lirp_threshold <<
"%, rescheduling]");
2132 DoRescheduling =
true;
2138 SavedVGPRExcessLimit =
S.VGPRExcessLimit;
2139 SavedVGPRCriticalLimit =
S.VGPRCriticalLimit;
2140 SavedUnifiedVGPRCriticalLimit =
S.UnifiedVGPRCriticalLimit;
2141 SavedVGPRThresholdPercent =
S.VGPRThresholdPercent;
2142 S.VGPRThresholdPercent = NewVGPRThresholdPercent;
2150 S.VGPRExcessLimit = SavedVGPRExcessLimit;
2151 S.VGPRCriticalLimit = SavedVGPRCriticalLimit;
2152 S.UnifiedVGPRCriticalLimit = SavedUnifiedVGPRCriticalLimit;
2153 S.VGPRThresholdPercent = SavedVGPRThresholdPercent;
2162 LLVM_DEBUG(
dbgs() <<
"New pressure will result in more spilling.\n");
2170 if (
DAG.SUnits.empty())
2175 LLVM_DEBUG(
dbgs() <<
"Metric before " << MBefore <<
"\tMetric after "
2188 LLVM_DEBUG(
dbgs() <<
"Equivalent RP, new schedule does not reduce "
2192 LLVM_DEBUG(
dbgs() <<
"Equivalent RP, keeping schedule with better "
2202 "instruction number mismatch");
2203 if (MIOrder.
empty())
2216 if (MII != RegionEnd) {
2218 bool NonDebugReordered =
2219 !
MI->isDebugInstr() &&
2225 if (NonDebugReordered)
2226 DAG.LIS->handleMove(*
MI,
true);
2233 if (!
MI->isDebugInstr()) {
2235 SlotIndex PrevIdx =
DAG.LIS->getSlotIndexes()->getIndexBefore(*
MI);
2236 if (PrevIdx >= MIIdx)
2237 DAG.LIS->handleMove(*
MI,
true);
2241 if (
MI->isDebugInstr()) {
2248 DAG.ShouldTrackLaneMasks);
2267 if (RD->
getOpcode() == AMDGPU::AV_MOV_B32_IMM_PSEUDO ||
2268 RD->
getOpcode() == AMDGPU::AV_MOV_B64_IMM_PSEUDO)
2275bool RewriteMFMAFormStage::hasUseRequiringVGPR(
2278 for (SlotIndex RDIdx : Src2ReachingDefs) {
2279 const MachineInstr *RD =
DAG.LIS->getInstructionFromIndex(RDIdx);
2281 findReachingUses(RD,
DAG.LIS, ReachingUses);
2282 for (
const MachineOperand *UseMO : ReachingUses) {
2294void RewriteMFMAFormStage::resetRewriteCandsToVGPR(
2295 ArrayRef<std::pair<MachineInstr *, unsigned>> RewriteCands) {
2296 for (
auto [
MI, OriginalOpcode] : RewriteCands) {
2299 DAG.MRI.getRegClass(
MI->getOperand(0).getReg());
2301 DAG.MRI.setRegClass(
MI->getOperand(0).getReg(), VDefRC);
2302 MI->setDesc(TII->get(OriginalOpcode));
2304 MachineOperand *
Src2 = TII->getNamedOperand(*
MI, AMDGPU::OpName::src2);
2313 DAG.MRI.setRegClass(
Src2->getReg(), VUseRC);
2317bool RewriteMFMAFormStage::isRewriteCandidate(
MachineInstr *
MI)
const {
2318 if (!
static_cast<const SIInstrInfo *
>(
DAG.TII)->isMAI(*
MI))
2323 Register DstReg =
MI->getOperand(0).getReg();
2324 for (
const MachineInstr &
UseMI :
DAG.MRI.use_nodbg_instructions(DstReg)) {
2331bool RewriteMFMAFormStage::initHeuristics(
2332 std::vector<std::pair<MachineInstr *, unsigned>> &RewriteCands,
2339 SmallPtrSet<MachineInstr *, 16> RewriteSet;
2340 DenseSet<Register> CandSrc2Regs;
2341 for (MachineBasicBlock &
MBB :
MF) {
2342 for (MachineInstr &
MI :
MBB) {
2343 if (!isRewriteCandidate(&
MI))
2346 MachineOperand *
Src2 = TII->getNamedOperand(
MI, AMDGPU::OpName::src2);
2347 if (Src2 &&
Src2->isReg())
2353 for (MachineBasicBlock &
MBB :
MF) {
2354 for (MachineInstr &
MI :
MBB) {
2355 if (!isRewriteCandidate(&
MI))
2359 assert(ReplacementOp != -1);
2361 RewriteCands.push_back({&
MI,
MI.getOpcode()});
2362 MI.setDesc(TII->get(ReplacementOp));
2364 MachineOperand *
Src2 = TII->getNamedOperand(
MI, AMDGPU::OpName::src2);
2365 if (
Src2->isReg()) {
2367 findReachingDefs(*Src2,
DAG.LIS, Src2ReachingDefs);
2371 bool Src2NeedsVGPR = hasUseRequiringVGPR(Src2ReachingDefs, RewriteSet);
2372 Src2NeedsVGPRCache[&
MI] = Src2NeedsVGPR;
2374 for (SlotIndex RDIdx : Src2ReachingDefs) {
2375 MachineInstr *RD =
DAG.LIS->getInstructionFromIndex(RDIdx);
2376 if (!Src2NeedsVGPR &&
2383 MachineOperand &Dst =
MI.getOperand(0);
2386 findReachingUses(&
MI,
DAG.LIS, DstReachingUses);
2388 for (MachineOperand *RUOp : DstReachingUses) {
2389 MachineInstr *UserMI = RUOp->getParent();
2391 if (TII->isMAI(*UserMI) && RewriteSet.
contains(UserMI))
2397 CopyForUse[UserMI->
getParent()].insert(RUOp->getReg());
2399 if (TII->isMAI(*UserMI))
2403 findReachingDefs(*RUOp,
DAG.LIS, DstUsesReachingDefs);
2405 for (SlotIndex RDIndex : DstUsesReachingDefs) {
2406 MachineInstr *RD =
DAG.LIS->getInstructionFromIndex(RDIndex);
2407 if (TII->isMAI(*RD))
2421 DAG.MRI.setRegClass(Dst.getReg(), ADefRC);
2422 if (
Src2->isReg()) {
2428 DAG.MRI.setRegClass(
Src2->getReg(), AUseRC);
2437int64_t RewriteMFMAFormStage::getRewriteCost(
2438 ArrayRef<std::pair<MachineInstr *, unsigned>> RewriteCands,
2441 MachineBlockFrequencyInfo *MBFI =
DAG.MBFI;
2443 int64_t BestSpillCost = 0;
2447 std::pair<unsigned, unsigned> MaxVectorRegs =
2448 ST.getMaxNumVectorRegs(
MF.getFunction());
2449 unsigned ArchVGPRThreshold = MaxVectorRegs.first;
2450 unsigned AGPRThreshold = MaxVectorRegs.second;
2451 unsigned CombinedThreshold =
ST.getMaxNumVGPRs(
MF);
2454 if (!RegionsWithExcessArchVGPR[Region])
2459 MF, ArchVGPRThreshold, AGPRThreshold, CombinedThreshold);
2467 MF, ArchVGPRThreshold, AGPRThreshold, CombinedThreshold);
2473 bool RelativeFreqIsDenom = EntryFreq > BlockFreq;
2474 uint64_t RelativeFreq = EntryFreq && BlockFreq
2475 ? (RelativeFreqIsDenom ? EntryFreq / BlockFreq
2476 : BlockFreq / EntryFreq)
2481 int64_t SpillCost = ((int)SpillCostAfter - (int)SpillCostBefore) * 2;
2484 if (RelativeFreqIsDenom)
2485 SpillCost /= (int64_t)RelativeFreq;
2487 SpillCost *= (int64_t)RelativeFreq;
2490 if (SpillCost > 0) {
2491 resetRewriteCandsToVGPR(RewriteCands);
2495 if (SpillCost < BestSpillCost)
2496 BestSpillCost = SpillCost;
2501 Cost = BestSpillCost;
2504 unsigned CopyCost = 0;
2508 for (MachineInstr *
DefMI : CopyForDef) {
2516 CopyCost +=
static_cast<unsigned>(RC->
getCopyCost() * DefFreq);
2520 for (
auto &[UseBlock, UseRegs] : CopyForUse) {
2526 CopyCost +=
static_cast<unsigned>(RC->
getCopyCost() * UseFreq);
2534 resetRewriteCandsToVGPR(RewriteCands);
2536 return Cost + CopyCost;
2539bool RewriteMFMAFormStage::rewrite(
2540 ArrayRef<std::pair<MachineInstr *, unsigned>> RewriteCands) {
2541 DenseMap<MachineInstr *, unsigned> FirstMIToRegion;
2542 DenseMap<MachineInstr *, unsigned> LastMIToRegion;
2550 if (
Entry.second !=
Entry.first->getParent()->end())
2593 DenseSet<Register> RewriteRegs;
2596 DenseMap<Register, Register> RedefMap;
2598 DenseMap<Register, DenseSet<MachineOperand *>>
ReplaceMap;
2600 DenseMap<Register, SmallPtrSet<MachineInstr *, 8>> ReachingDefCopyMap;
2603 DenseMap<unsigned, DenseMap<Register, SmallPtrSet<MachineOperand *, 8>>>
2608 SmallPtrSet<MachineInstr *, 16> RewriteCandsSet;
2609 DenseSet<Register> RewriteSrc2Regs;
2610 for (
auto &[
MI, OriginalOpcode] : RewriteCands) {
2612 MachineOperand *
Src2 = TII->getNamedOperand(*
MI, AMDGPU::OpName::src2);
2613 if (Src2 &&
Src2->isReg())
2617 for (
auto &[
MI, OriginalOpcode] : RewriteCands) {
2619 if (ReplacementOp == -1)
2621 MI->setDesc(TII->get(ReplacementOp));
2624 MachineOperand *
Src2 = TII->getNamedOperand(*
MI, AMDGPU::OpName::src2);
2625 if (
Src2->isReg()) {
2632 findReachingDefs(*Src2,
DAG.LIS, Src2ReachingDefs);
2633 SmallSetVector<MachineInstr *, 8> Src2DefsReplace;
2637 bool Src2NeedsVGPR = Src2NeedsVGPRCache.lookup(
MI);
2639 for (SlotIndex RDIndex : Src2ReachingDefs) {
2640 MachineInstr *RD =
DAG.LIS->getInstructionFromIndex(RDIndex);
2641 if (!Src2NeedsVGPR &&
2645 Src2DefsReplace.
insert(RD);
2648 if (!Src2DefsReplace.
empty()) {
2649 auto RI = RedefMap.
find(Src2Reg);
2650 if (RI != RedefMap.
end()) {
2651 MappedReg = RI->second;
2656 SRI->getEquivalentVGPRClass(Src2RC);
2659 MappedReg =
DAG.MRI.createVirtualRegister(VGPRRC);
2660 RedefMap[Src2Reg] = MappedReg;
2665 for (MachineInstr *RD : Src2DefsReplace) {
2667 if (ReachingDefCopyMap[Src2Reg].insert(RD).second) {
2668 MachineInstrBuilder VGPRCopy =
2671 .
addDef(MappedReg, {}, 0)
2672 .addUse(Src2Reg, {}, 0);
2673 DAG.LIS->InsertMachineInstrInMaps(*VGPRCopy);
2678 unsigned UpdateRegion = LastMIToRegion[RD];
2679 DAG.Regions[UpdateRegion].second = VGPRCopy;
2680 LastMIToRegion.
erase(RD);
2687 RewriteRegs.
insert(Src2Reg);
2697 MachineOperand *Dst = &
MI->getOperand(0);
2706 SmallVector<MachineInstr *, 8> DstUseDefsReplace;
2708 findReachingUses(
MI,
DAG.LIS, DstReachingUses);
2710 for (MachineOperand *RUOp : DstReachingUses) {
2711 MachineInstr *UserMI = RUOp->
getParent();
2713 if (TII->isMAI(*UserMI) && RewriteCandsSet.
contains(UserMI))
2717 if (
find(DstReachingUseCopies, RUOp) == DstReachingUseCopies.
end())
2721 if (TII->isMAI(*UserMI))
2725 findReachingDefs(*RUOp,
DAG.LIS, DstUsesReachingDefs);
2727 for (SlotIndex RDIndex : DstUsesReachingDefs) {
2728 MachineInstr *RD =
DAG.LIS->getInstructionFromIndex(RDIndex);
2729 if (TII->isMAI(*RD))
2734 if (
find(DstUseDefsReplace, RD) == DstUseDefsReplace.
end())
2739 if (!DstUseDefsReplace.
empty()) {
2740 auto RI = RedefMap.
find(DstReg);
2741 if (RI != RedefMap.
end()) {
2742 MappedReg = RI->second;
2749 MappedReg =
DAG.MRI.createVirtualRegister(VGPRRC);
2750 RedefMap[DstReg] = MappedReg;
2755 for (MachineInstr *RD : DstUseDefsReplace) {
2757 if (ReachingDefCopyMap[DstReg].insert(RD).second) {
2758 MachineInstrBuilder VGPRCopy =
2761 .
addDef(MappedReg, {}, 0)
2762 .addUse(DstReg, {}, 0);
2763 DAG.LIS->InsertMachineInstrInMaps(*VGPRCopy);
2767 auto LMI = LastMIToRegion.
find(RD);
2768 if (LMI != LastMIToRegion.
end()) {
2769 unsigned UpdateRegion = LMI->second;
2770 DAG.Regions[UpdateRegion].second = VGPRCopy;
2771 LastMIToRegion.
erase(RD);
2777 DenseSet<MachineOperand *> &DstRegSet =
ReplaceMap[DstReg];
2780 MachineInstr *EarliestSameBlockUse =
nullptr;
2781 for (MachineOperand *RU : DstReachingUseCopies) {
2782 MachineBasicBlock *RUBlock = RU->getParent()->getParent();
2785 if (RUBlock !=
MI->getParent()) {
2791 if (!SameBlockCopyReg.
isValid()) {
2794 SameBlockCopyReg =
DAG.MRI.createVirtualRegister(VGPRRC);
2798 MachineInstr *UseInst = RU->getParent();
2799 if (!EarliestSameBlockUse ||
2801 DAG.LIS->getInstructionIndex(*UseInst),
2802 DAG.LIS->getInstructionIndex(*EarliestSameBlockUse)))
2803 EarliestSameBlockUse = UseInst;
2804 RU->setReg(SameBlockCopyReg);
2808 if (SameBlockCopyReg.
isValid()) {
2809 MachineInstrBuilder VGPRCopy =
2812 TII->get(TargetOpcode::COPY), SameBlockCopyReg)
2814 DAG.LIS->InsertMachineInstrInMaps(*VGPRCopy);
2819 RewriteRegs.
insert(DstReg);
2829 std::pair<unsigned, DenseMap<Register, SmallPtrSet<MachineOperand *, 8>>>;
2830 for (RUBType RUBlockEntry : ReachingUseTracker) {
2831 using RUDType = std::pair<Register, SmallPtrSet<MachineOperand *, 8>>;
2832 for (RUDType RUDst : RUBlockEntry.second) {
2833 MachineOperand *OpBegin = *RUDst.second.begin();
2834 SlotIndex InstPt =
DAG.LIS->getInstructionIndex(*OpBegin->
getParent());
2837 for (MachineOperand *User : RUDst.second) {
2838 SlotIndex NewInstPt =
DAG.LIS->getInstructionIndex(*
User->getParent());
2845 Register NewUseReg =
DAG.MRI.createVirtualRegister(VGPRRC);
2846 MachineInstr *UseInst =
DAG.LIS->getInstructionFromIndex(InstPt);
2848 MachineInstrBuilder VGPRCopy =
2851 .
addDef(NewUseReg, {}, 0)
2852 .addUse(RUDst.first, {}, 0);
2853 DAG.LIS->InsertMachineInstrInMaps(*VGPRCopy);
2857 auto FI = FirstMIToRegion.
find(UseInst);
2858 if (FI != FirstMIToRegion.
end()) {
2859 unsigned UpdateRegion = FI->second;
2860 DAG.Regions[UpdateRegion].first = VGPRCopy;
2861 FirstMIToRegion.
erase(UseInst);
2865 for (MachineOperand *User : RUDst.second) {
2866 User->setReg(NewUseReg);
2877 for (std::pair<Register, Register> NewDef : RedefMap) {
2882 for (MachineOperand *ReplaceOp :
ReplaceMap[OldReg])
2883 ReplaceOp->setReg(NewReg);
2887 for (
Register RewriteReg : RewriteRegs) {
2888 Register RegToRewrite = RewriteReg;
2891 auto RI = RedefMap.find(RewriteReg);
2892 if (RI != RedefMap.end())
2893 RegToRewrite = RI->second;
2898 DAG.MRI.setRegClass(RegToRewrite, AGPRRC);
2902 DAG.LIS->reanalyze(
DAG.MF);
2904 RegionPressureMap LiveInUpdater(&
DAG,
false);
2905 LiveInUpdater.buildLiveRegMap();
2908 DAG.LiveIns[Region] = LiveInUpdater.getLiveRegsForRegionIdx(Region);
2915unsigned PreRARematStage::getStageTargetOccupancy()
const {
2916 return TargetOcc ? *TargetOcc :
MFI.getMinWavesPerEU();
2928 if (
DAG.MinOccupancy >= *TargetOcc)
2932 for (
const auto &[
RegionIdx, OrigMIOrder, MaxPressure] : RegionReverts) {
2942 if (AchievedOcc >= *TargetOcc) {
2943 DAG.setTargetOccupancy(AchievedOcc);
2948 DAG.setTargetOccupancy(*TargetOcc - 1);
2949 Strategy->rollbackRecordedRemats();
2950 for (
unsigned RegionIdx : RescheduleRegions.set_bits()) {
2955#ifdef EXPENSIVE_CHECKS
2964void GCNScheduleDAGMILive::setTargetOccupancy(
unsigned TargetOccupancy) {
2965 MinOccupancy = TargetOccupancy;
2966 if (MFI.getOccupancy() < TargetOccupancy)
2967 MFI.increaseOccupancy(
MF, MinOccupancy);
2969 MFI.limitOccupancy(MinOccupancy);
2986 if (HasIGLPInstrs) {
2987 SavedMutations.clear();
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static SUnit * pickOnlyChoice(SchedBoundary &Zone)
This file implements the BitVector class.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the GCNRegPressure class, which tracks registry pressure by bookkeeping number of S...
Rematerialization strategy, based on the target-independent rematerializer.
static MachineInstr * getLastMIForRegion(MachineBasicBlock::iterator RegionBegin, MachineBasicBlock::iterator RegionEnd)
static void printScheduleModel(std::set< std::pair< MachineInstr *, unsigned >, EarlierIssuingCycle > &ReadyCycles)
static bool isReachingDefAGPRForm(MachineInstr *RD, const SmallPtrSetImpl< MachineInstr * > &RewriteSet, const DenseSet< Register > &CandSrc2Regs, const SIInstrInfo &TII)
Returns true if reaching def RD will be in AGPR form after the rewrite and so needs no bridge copy: a...
static bool hasIGLPInstrs(ScheduleDAGInstrs *DAG)
static void getRegisterPressures(bool AtTop, const RegPressureTracker &RPTracker, SUnit *SU, std::vector< unsigned > &Pressure, std::vector< unsigned > &MaxPressure)
Fills Pressure and MaxPressure, indexed by pressure set, with the generic RegPressureTracker's pressu...
static bool shouldCheckPending(unsigned PendingQueueLimit, SchedBoundary &Zone, const TargetSchedModel *SchedModel)
static bool canUsePressureDiffs(const SUnit &SU)
Checks whether SU can use the cached DAG pressure diffs to compute the current register pressure.
static Register UseReg(const MachineOperand &MO)
const HexagonInstrInfo * TII
static constexpr std::pair< StringLiteral, StringLiteral > ReplaceMap[]
Promote Memory to Register
MachineRegisterInfo & MRI
const AMDGPUOptions & getCLOpts() const
Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
Get the first element.
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
bool initGCNSchedStage() override
bool shouldRevertScheduling(unsigned WavesAfter) override
bool initGCNRegion() override
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
Downward RP tracker that relies on program order to advance down the instruction stream.
GCNMaxILPSchedStrategy(const MachineSchedContext *C)
bool tryCandidate(SchedCandidate &Cand, SchedCandidate &TryCand, SchedBoundary *Zone) const override
Apply a set of heuristics to a new candidate.
bool tryCandidate(SchedCandidate &Cand, SchedCandidate &TryCand, SchedBoundary *Zone) const override
GCNMaxMemoryClauseSchedStrategy tries best to clause memory instructions as much as possible.
GCNMaxMemoryClauseSchedStrategy(const MachineSchedContext *C)
GCNMaxOccupancySchedStrategy(const MachineSchedContext *C, bool IsLegacyScheduler=false)
void finalizeSchedule() override
Allow targets to perform final scheduling actions at the level of the whole MachineFunction.
void schedule() override
Orders nodes according to selected style.
GCNPostScheduleDAGMILive(MachineSchedContext *C, std::unique_ptr< MachineSchedStrategy > S, bool RemoveKillFlags)
Models a register pressure target, allowing to evaluate and track register savings against that targe...
GCNRegPressure getPressure() const
void reset(const MachineInstr &MI, bool After)
Resets tracker before or After the provided MI, which can be a debug instruction.
virtual bool initGCNRegion()
GCNRegPressure PressureBefore
bool isRegionWithExcessRP() const
void modifyRegionSchedule(unsigned RegionIdx, ArrayRef< MachineInstr * > MIOrder)
Sets the schedule of region RegionIdx to MIOrder.
bool mayCauseSpilling(unsigned WavesAfter)
ScheduleMetrics getScheduleMetrics(const std::vector< SUnit > &InputSchedule)
GCNScheduleDAGMILive & DAG
const GCNSchedStageID StageID
std::vector< MachineInstr * > Unsched
GCNRegPressure PressureAfter
bool shouldRevertInitialSchedule(unsigned WavesAfter)
virtual void finalizeGCNRegion()
SIMachineFunctionInfo & MFI
unsigned computeSUnitReadyCycle(const SUnit &SU, unsigned CurrCycle, DenseMap< unsigned, unsigned > &ReadyCycles, const TargetSchedModel &SM)
virtual void finalizeGCNSchedStage()
virtual bool initGCNSchedStage()
virtual bool shouldRevertScheduling(unsigned WavesAfter)
std::vector< std::unique_ptr< ScheduleDAGMutation > > SavedMutations
GCNSchedStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
MachineBasicBlock * CurrentMBB
This is a minimal scheduler strategy.
bool useGCNTrackers() const
GCNSchedStrategy(const MachineSchedContext *C)
SmallVector< GCNSchedStageID, 4 > SchedStages
unsigned SGPRCriticalLimit
unsigned VGPRThresholdPercent
std::vector< unsigned > MaxPressure
bool hasNextStage() const
SUnit * pickNodeBidirectional(bool &IsTopNode, bool &PickedPending)
GCNSchedStageID getCurrentStage()
bool tryPendingCandidate(SchedCandidate &Cand, SchedCandidate &TryCand, SchedBoundary *Zone) const
Evaluates instructions in the pending queue using a subset of scheduling heuristics.
SmallVectorImpl< GCNSchedStageID >::iterator CurrentStage
std::pair< unsigned, unsigned > getBankedPressure(const GCNRegPressure &RP) const
unsigned VGPRCriticalLimit
void schedNode(SUnit *SU, bool IsTopNode) override
Notify MachineSchedStrategy that ScheduleDAGMI has scheduled an instruction and updated scheduled/rem...
GCNRegPressure getGCNTrackerPressure(bool AtTop, SUnit *SU, const SIRegisterInfo *SRI) const
unsigned AGPRBankLimit
Capacity of the AGPR bank, captured before AGPRExcessLimit is cut down by ErrorMargin and VGPRLimitBi...
unsigned ArchVGPRBankLimit
Capacity of the ArchVGPR bank, captured before VGPRExcessLimit is cut down by ErrorMargin,...
std::optional< bool > GCNTrackersOverride
unsigned AGPRCriticalLimit
std::vector< unsigned > Pressure
unsigned UnifiedVGPRCriticalLimit
void initialize(ScheduleDAGMI *DAG) override
Initialize the strategy after building the DAG for a new region.
GCNUpwardRPTracker UpwardTracker
void printCandidateDecision(const SchedCandidate &Current, const SchedCandidate &Preferred)
void pickNodeFromQueue(SchedBoundary &Zone, const CandPolicy &ZonePolicy, const RegPressureTracker &RPTracker, SchedCandidate &Cand, bool &IsPending, bool IsBottomUp)
GCNManualDownwardRPTracker DownwardTracker
GCNUpwardRPTracker & getUpwardTracker()
const AMDGPUOptions & CLOpts
void initCandidate(SchedCandidate &Cand, SUnit *SU, bool AtTop, const RegPressureTracker &RPTracker, const SIRegisterInfo *SRI, unsigned SGPRPressure, unsigned VGPRPressure, unsigned AGPRPressure, bool IsBottomUp)
GCNDownwardRPTrackerBase & getDownwardTracker()
SUnit * pickNode(bool &IsTopNode) override
Pick the next node to schedule, or return NULL.
unsigned UnifiedVGPRExcessLimit
Budget for the combined ArchVGPR + AGPR file, or zero on targets without one.
void finalizeSchedule() override
Allow targets to perform final scheduling actions at the level of the whole MachineFunction.
void schedule() override
Orders nodes according to selected style.
GCNScheduleDAGMILive(MachineSchedContext *C, std::unique_ptr< MachineSchedStrategy > S)
void recede(const MachineInstr &MI)
Move to the state of RP just before the MI.
void reset(const MachineInstr &MI)
Resets tracker to the point just after MI (in program order), which can be a debug instruction.
void traceCandidate(const SchedCandidate &Cand)
LLVM_ABI void setPolicy(CandPolicy &Policy, bool IsPostRA, SchedBoundary &CurrZone, SchedBoundary *OtherZone)
Set the CandPolicy given a scheduling zone given the current resources and latencies inside and outsi...
MachineSchedPolicy RegionPolicy
const TargetSchedModel * SchedModel
const MachineSchedContext * Context
const TargetRegisterInfo * TRI
SchedCandidate BotCand
Candidate last picked from Bot boundary.
SchedCandidate TopCand
Candidate last picked from Top boundary.
virtual bool tryCandidate(SchedCandidate &Cand, SchedCandidate &TryCand, SchedBoundary *Zone) const
Apply a set of heuristics to a new candidate.
void initialize(ScheduleDAGMI *dag) override
Initialize the strategy after building the DAG for a new region.
void schedNode(SUnit *SU, bool IsTopNode) override
Update the scheduler's state after scheduling a node.
GenericScheduler(const MachineSchedContext *C)
bool shouldRevertScheduling(unsigned WavesAfter) override
void finalizeGCNRegion() override
bool initGCNRegion() override
bool initGCNSchedStage() override
LiveInterval - This class represents the liveness of a register, or stack slot.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const
Return the last index in the given basic block.
LiveInterval & getInterval(Register Reg)
LLVM_ABI void dump() const
MachineBasicBlock * getMBBFromIndex(SlotIndex index) const
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
uint8_t getCopyCost() const
getCopyCost - Return the cost of copying a value between two registers in this class.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
succ_iterator succ_begin()
unsigned succ_size() const
iterator_range< pred_iterator > predecessors()
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
LLVM_ABI BlockFrequency getEntryFreq() const
Divide a block's BlockFrequency::getFrequency() value by this value to obtain the entry block - relat...
const MachineInstrBuilder & addUse(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Register getReg() const
getReg - Returns the register number.
bool shouldRevertScheduling(unsigned WavesAfter) override
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
bool shouldRevertScheduling(unsigned WavesAfter) override
bool shouldRevertScheduling(unsigned WavesAfter) override
void finalizeGCNRegion() override
bool initGCNRegion() override
bool initGCNSchedStage() override
Capture a change in pressure for a single pressure set.
Helpers for implementing custom MachineSchedStrategy classes.
Track the current register pressure at some position in the instruction stream, and remember the high...
RegisterPressure & getPressure()
Get the resulting register pressure over the traversed region.
LLVM_ABI void getDownwardPressure(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
Get the pressure of each PSet after traversing this instruction top-down.
const std::vector< unsigned > & getRegSetPressureAtPos() const
Get the register set pressure at the current position, which may be less than the pressure across the...
LLVM_ABI void getUpwardPressure(const MachineInstr *MI, std::vector< unsigned > &PressureResult, std::vector< unsigned > &MaxPressureResult)
Get the pressure of each PSet after traversing this instruction bottom-up.
static LLVM_ABI void restoreLivenessFlags(MachineInstr &MI, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, LiveIntervals &LIS, bool TrackLaneMasks=true, ArrayRef< Register > OnlyRegs={})
Clear potentially-stale read-undef flags on the defs of MI, then recompute them from LIS.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
bool isIGLPMutationOnly(unsigned Opcode) const
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
unsigned getOccupancy() const
unsigned getDynamicVGPRBlockSize() const
unsigned getMinAllowedOccupancy() const
Scheduling unit. This is a node in the scheduling DAG.
bool isInstr() const
Returns true if this SUnit refers to a machine instruction as opposed to an SDNode.
unsigned TopReadyCycle
Cycle relative to start when node is ready.
unsigned NodeNum
Entry # of node in the node vector.
unsigned short Latency
Node latency.
bool isScheduled
True once scheduled.
unsigned ParentClusterIdx
The parent cluster id.
unsigned BotReadyCycle
Cycle relative to end when node is ready.
bool isBottomReady() const
SmallVector< SDep, 4 > Preds
All sunit predecessors.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
Each Scheduling boundary is associated with ready queues.
LLVM_ABI void releasePending()
Release pending ready nodes in to the available queue.
LLVM_ABI unsigned getLatencyStallCycles(SUnit *SU)
Get the difference between the given SUnit's ready time and the current cycle.
LLVM_ABI SUnit * pickOnlyChoice()
Call this before applying any other heuristics to the Available queue.
LLVM_ABI void bumpCycle(unsigned NextCycle)
Move the boundary of scheduled code by one cycle.
unsigned getCurrMOps() const
Micro-ops issued in the current cycle.
unsigned getCurrCycle() const
Number of cycles to issue the instructions scheduled in this zone.
LLVM_ABI bool checkHazard(SUnit *SU)
Does this SU have a hazard within the current instruction group.
A ScheduleDAG for scheduling lists of MachineInstr.
bool ScheduleSingleMIRegions
True if regions with a single MI should be scheduled.
MachineBasicBlock::iterator RegionEnd
The end of the range to be scheduled.
virtual void finalizeSchedule()
Allow targets to perform final scheduling actions at the level of the whole MachineFunction.
const MachineLoopInfo * MLI
bool RemoveKillFlags
True if the DAG builder should remove kill flags (in preparation for rescheduling).
MachineBasicBlock::iterator RegionBegin
The beginning of the range to be scheduled.
void schedule() override
Implement ScheduleDAGInstrs interface for scheduling a sequence of reorderable instructions.
ScheduleDAGMILive(MachineSchedContext *C, std::unique_ptr< MachineSchedStrategy > S)
RegPressureTracker RPTracker
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
void exitRegion() override
Called when the scheduler has finished scheduling the current region.
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
Add a postprocessing step to the DAG builder.
void schedule() override
Implement ScheduleDAGInstrs interface for scheduling a sequence of reorderable instructions.
ScheduleDAGMI(MachineSchedContext *C, std::unique_ptr< MachineSchedStrategy > S, bool RemoveKillFlags)
std::vector< std::unique_ptr< ScheduleDAGMutation > > Mutations
Ordered list of DAG postprocessing steps.
MachineRegisterInfo & MRI
Virtual/real register map.
const TargetInstrInfo * TII
Target instruction information.
MachineFunction & MF
Machine function.
static const unsigned ScaleFactor
unsigned getMetric() const
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
SlotIndex - An opaque wrapper around machine indexes.
static bool isSameInstr(SlotIndex A, SlotIndex B)
isSameInstr - Return true if A and B refer to the same instruction.
static bool isEarlierInstr(SlotIndex A, SlotIndex B)
isEarlierInstr - Return true if A refers to an instruction earlier than B.
SlotIndex getPrevSlot() const
Returns the previous slot in the index list.
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const
Returns the first index in the given basic block.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Provide an instruction scheduling machine model to CodeGen passes.
LLVM_ABI bool hasInstrSchedModel() const
Return true if this machine model includes an instruction-level scheduling model.
unsigned getMicroOpBufferSize() const
Number of micro-ops that may be buffered for OOO execution.
bool initGCNSchedStage() override
bool initGCNRegion() override
void finalizeGCNSchedStage() override
bool shouldRevertScheduling(unsigned WavesAfter) override
VNInfo - Value Number Information.
SlotIndex def
The index of the defining instruction.
bool isPHIDef() const
Returns true if this value is defined by a PHI instruction (or was, PHI instructions may have been el...
LLVM Value Representation.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
self_iterator getIterator()
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize)
unsigned getAllocatedNumVGPRBlocks(const MCSubtargetInfo &STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
LLVM_READONLY int32_t getAGPRFormOp(uint32_t Opcode)
initializer< Ty > init(const Ty &Val)
@ User
could "use" a pointer
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI int biasPhysReg(const SUnit *SU, bool isTop, bool BiasPRegsExtra=false)
Minimize physical register live ranges.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI unsigned getWeakLeft(const SUnit *SU, bool isTop)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
GCNRegPressure getRegPressure(const MachineRegisterInfo &MRI, Range &&LiveRegs)
LLVM_ABI bool shouldVerifyScheduling(const MachineFunction &MF)
Returns whether -verify-misched is set.
std::unique_ptr< ScheduleDAGMutation > createIGroupLPDAGMutation(AMDGPU::SchedulingPhase Phase)
Phase specifes whether or not this is a reentry into the IGroupLPDAGMutation.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
std::pair< MachineBasicBlock::iterator, MachineBasicBlock::iterator > RegionBoundaries
A region's boundaries i.e.
IterT skipDebugInstructionsForward(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool tryPressure(const PressureChange &TryP, const PressureChange &CandP, GenericSchedulerBase::SchedCandidate &TryCand, GenericSchedulerBase::SchedCandidate &Cand, GenericSchedulerBase::CandReason Reason, const TargetRegisterInfo *TRI, const MachineFunction &MF)
@ UnclusteredHighRPReschedule
@ MemoryClauseInitialSchedule
@ LiveIntervalRPReschedule
@ ClusteredLowOccupancyReschedule
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
cl::opt< unsigned, false, VGPRThresholdParser > VGPRThresholdPercentOpt
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
iterator_range< ConstMIBundleOperands > const_mi_bundle_ops(const MachineInstr &MI)
LLVM_ABI bool tryLatency(GenericSchedulerBase::SchedCandidate &TryCand, GenericSchedulerBase::SchedCandidate &Cand, SchedBoundary &Zone)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
IterT skipDebugInstructionsBackward(IterT It, IterT Begin, bool SkipPseudoOp=true)
Decrement It until it points to a non-debug instruction or to Begin and return the resulting iterator...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool isTheSameCluster(unsigned A, unsigned B)
Return whether the input cluster ID's are the same and valid.
DWARFExpression::Operation Op
LLVM_ABI bool tryGreater(int TryVal, int CandVal, GenericSchedulerBase::SchedCandidate &TryCand, GenericSchedulerBase::SchedCandidate &Cand, GenericSchedulerBase::CandReason Reason)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
DenseMap< MachineInstr *, GCNRPTracker::LiveRegSet > getLiveRegMap(Range &&R, bool After, LiveIntervals &LIS)
creates a map MachineInstr -> LiveRegSet R - range of iterators on instructions After - upon entry or...
GCNRPTracker::LiveRegSet getLiveRegsBefore(const MachineInstr &MI, const LiveIntervals &LIS)
LLVM_ABI bool tryLess(int TryVal, int CandVal, GenericSchedulerBase::SchedCandidate &TryCand, GenericSchedulerBase::SchedCandidate &Cand, GenericSchedulerBase::CandReason Reason)
Return true if this heuristic determines order.
LLVM_ABI void dumpMaxRegPressure(MachineFunction &MF, GCNRegPressure::RegKind Kind, LiveIntervals &LIS, const MachineLoopInfo *MLI)
unsigned estimateGreedyVGPRPressure(MachineBasicBlock::const_iterator RegionBegin, MachineBasicBlock::const_iterator RegionEnd, const GCNRPTracker::LiveRegSet &LiveIns, const LiveIntervals &LIS, const MachineRegisterInfo &MRI, const SIRegisterInfo &TRI)
Estimate VGPR pressure using greedy, non-splitting register allocation simulation,...
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
MCRegisterClass TargetRegisterClass
Implement std::hash so that hash_code can be used in STL containers.
bool operator()(std::pair< MachineInstr *, unsigned > A, std::pair< MachineInstr *, unsigned > B) const
static unsigned getBankedUnifiedVGPRNum(unsigned NumArchVGPRs, unsigned NumAGPRs)
Returns the aggregated VGPR pressure for NumArchVGPRs ArchVGPRs and NumAGPRs AGPRs,...
unsigned getSGPRNum() const
static unsigned getUnifiedVGPRNum(unsigned NumArchVGPRs, unsigned NumAGPRs, unsigned NumAVGPRs)
Returns the aggregated VGPR pressure, assuming NumArchVGPRs ArchVGPRs NumAGPRs AGPRS,...
Policy for scheduling the next instruction in the candidate's zone.
Store the state used by GenericScheduler heuristics, required for the lifetime of one invocation of p...
void setBest(SchedCandidate &Best)
void reset(const CandPolicy &NewPolicy)
LLVM_ABI void initResourceDelta(const ScheduleDAGMI *DAG, const TargetSchedModel *SchedModel)
SchedResourceDelta ResDelta
Status of an instruction's critical resource consumption.
unsigned DemandedResources
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
PressureChange CriticalMax
PressureChange CurrentMax
bool parse(cl::Option &O, StringRef ArgName, StringRef Arg, unsigned &Value)