[llvm] Reapply "[AMDGPU] Add HWUI pressure heuristics to coexec strategy (#184929)" (PR #189121)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 15:01:16 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Jeffrey Byrnes (jrbyrnes)
<details>
<summary>Changes</summary>
Reland https://github.com/llvm/llvm-project/pull/184929 after fixing some issues in the NDEBUG builds.
3a640ee is unchanged from the previously approved PR, the unreviewed portion of this PR is 9cabd8d
---
Patch is 74.70 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/189121.diff
4 Files Affected:
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.cpp (+414-23)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.h (+288-2)
- (modified) llvm/test/CodeGen/AMDGPU/coexec-sched-effective-stall.mir (+5-5)
- (added) llvm/test/CodeGen/AMDGPU/coexec-scheduler.ll (+606)
``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.cpp
index 977c6f56ad15d..bd9984a2fbc76 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.cpp
@@ -15,6 +15,7 @@
#include "llvm/Support/Debug.h"
using namespace llvm;
+using namespace llvm::AMDGPU;
#define DEBUG_TYPE "machine-scheduler"
@@ -41,6 +42,365 @@ static SUnit *pickOnlyChoice(SchedBoundary &Zone) {
return OnlyChoice;
}
+InstructionFlavor llvm::AMDGPU::classifyFlavor(const MachineInstr &MI,
+ const SIInstrInfo &SII) {
+ if (MI.isDebugInstr())
+ return InstructionFlavor::Other;
+
+ unsigned Opc = MI.getOpcode();
+
+ // Check for specific opcodes first.
+ if (Opc == AMDGPU::ATOMIC_FENCE || Opc == AMDGPU::S_WAIT_ASYNCCNT ||
+ Opc == AMDGPU::S_WAIT_TENSORCNT || Opc == AMDGPU::S_BARRIER_WAIT ||
+ Opc == AMDGPU::S_BARRIER_SIGNAL_IMM)
+ return InstructionFlavor::Fence;
+
+ if (SII.isLDSDMA(MI))
+ return InstructionFlavor::DMA;
+
+ if (SII.isMFMAorWMMA(MI))
+ return InstructionFlavor::WMMA;
+
+ if (SII.isTRANS(MI))
+ return InstructionFlavor::TRANS;
+
+ if (SII.isVALU(MI))
+ return InstructionFlavor::SingleCycleVALU;
+
+ if (SII.isDS(MI))
+ return InstructionFlavor::DS;
+
+ if (SII.isFLAT(MI) || SII.isFLATGlobal(MI) || SII.isFLATScratch(MI))
+ return InstructionFlavor::VMEM;
+
+ if (SII.isSALU(MI))
+ return InstructionFlavor::SALU;
+
+ return InstructionFlavor::Other;
+}
+
+SUnit *HardwareUnitInfo::getNextTargetSU(bool LookDeep) const {
+ for (auto *PrioritySU : PrioritySUs) {
+ if (!PrioritySU->isTopReady())
+ return PrioritySU;
+ }
+
+ if (!LookDeep)
+ return nullptr;
+
+ unsigned MinDepth = std::numeric_limits<unsigned int>::max();
+ SUnit *TargetSU = nullptr;
+ for (auto *SU : AllSUs) {
+ if (SU->isScheduled)
+ continue;
+
+ if (SU->isTopReady())
+ continue;
+
+ if (SU->getDepth() < MinDepth) {
+ MinDepth = SU->getDepth();
+ TargetSU = SU;
+ }
+ }
+ return TargetSU;
+}
+
+void HardwareUnitInfo::insert(SUnit *SU, unsigned BlockingCycles) {
+ [[maybe_unused]] bool Inserted = AllSUs.insert(SU);
+ TotalCycles += BlockingCycles;
+
+ assert(Inserted);
+ if (PrioritySUs.empty()) {
+ PrioritySUs.insert(SU);
+ return;
+ }
+ unsigned SUDepth = SU->getDepth();
+ unsigned CurrDepth = (*PrioritySUs.begin())->getDepth();
+ if (SUDepth > CurrDepth)
+ return;
+
+ if (SUDepth == CurrDepth) {
+ PrioritySUs.insert(SU);
+ return;
+ }
+
+ // SU is lower depth and should be prioritized.
+ PrioritySUs.clear();
+ PrioritySUs.insert(SU);
+}
+
+void HardwareUnitInfo::markScheduled(SUnit *SU, unsigned BlockingCycles) {
+ // We may want to ignore some HWUIs (e.g. InstructionFlavor::Other). To do so,
+ // we just clear the HWUI. However, we still have instructions which map to
+ // this HWUI. Don't bother managing the state for these HWUI.
+ if (TotalCycles == 0)
+ return;
+
+ AllSUs.remove(SU);
+ PrioritySUs.remove(SU);
+
+ TotalCycles -= BlockingCycles;
+
+ if (AllSUs.empty())
+ return;
+ if (PrioritySUs.empty()) {
+ for (auto SU : AllSUs) {
+ if (PrioritySUs.empty()) {
+ PrioritySUs.insert(SU);
+ continue;
+ }
+ unsigned SUDepth = SU->getDepth();
+ unsigned CurrDepth = (*PrioritySUs.begin())->getDepth();
+ if (SUDepth > CurrDepth)
+ continue;
+
+ if (SUDepth == CurrDepth) {
+ PrioritySUs.insert(SU);
+ continue;
+ }
+
+ // SU is lower depth and should be prioritized.
+ PrioritySUs.clear();
+ PrioritySUs.insert(SU);
+ }
+ }
+}
+
+HardwareUnitInfo *
+CandidateHeuristics::getHWUIFromFlavor(InstructionFlavor Flavor) {
+ for (auto &HWUICand : HWUInfo) {
+ if (HWUICand.getType() == Flavor) {
+ return &HWUICand;
+ }
+ }
+ return nullptr;
+}
+
+unsigned CandidateHeuristics::getHWUICyclesForInst(SUnit *SU) {
+ assert(SchedModel && SchedModel->hasInstrSchedModel());
+ unsigned ReleaseAtCycle = 0;
+ const MCSchedClassDesc *SC = DAG->getSchedClass(SU);
+ for (TargetSchedModel::ProcResIter PI = SchedModel->getWriteProcResBegin(SC),
+ PE = SchedModel->getWriteProcResEnd(SC);
+ PI != PE; ++PI) {
+ ReleaseAtCycle = std::max(ReleaseAtCycle, (unsigned)PI->ReleaseAtCycle);
+ }
+ return ReleaseAtCycle;
+}
+
+void CandidateHeuristics::updateForScheduling(SUnit *SU) {
+ HardwareUnitInfo *HWUI =
+ getHWUIFromFlavor(classifyFlavor(*SU->getInstr(), *SII));
+ assert(HWUI);
+ HWUI->markScheduled(SU, getHWUICyclesForInst(SU));
+}
+
+void CandidateHeuristics::initialize(ScheduleDAGMI *SchedDAG,
+ const TargetSchedModel *TargetSchedModel,
+ const TargetRegisterInfo *TRI) {
+ DAG = SchedDAG;
+ SchedModel = TargetSchedModel;
+ assert(SchedModel && SchedModel->hasInstrSchedModel());
+
+ SRI = static_cast<const SIRegisterInfo *>(TRI);
+ SII = static_cast<const SIInstrInfo *>(DAG->TII);
+
+ HWUInfo.resize((int)InstructionFlavor::NUM_FLAVORS);
+
+ for (unsigned I = 0; I < HWUInfo.size(); I++) {
+ HWUInfo[I].reset();
+ HWUInfo[I].setType(I);
+ }
+
+ HWUInfo[(int)InstructionFlavor::WMMA].setProducesCoexecWindow(true);
+ HWUInfo[(int)InstructionFlavor::MultiCycleVALU].setProducesCoexecWindow(true);
+ HWUInfo[(int)InstructionFlavor::TRANS].setProducesCoexecWindow(true);
+
+ collectHWUIPressure();
+}
+
+void CandidateHeuristics::collectHWUIPressure() {
+ if (!SchedModel || !SchedModel->hasInstrSchedModel())
+ return;
+
+ for (auto &SU : DAG->SUnits) {
+ const InstructionFlavor Flavor = classifyFlavor(*SU.getInstr(), *SII);
+ HWUInfo[(int)(Flavor)].insert(&SU, getHWUICyclesForInst(&SU));
+ }
+
+ LLVM_DEBUG(dumpRegionSummary());
+}
+
+void CandidateHeuristics::dumpRegionSummary() {
+ MachineBasicBlock *BB = DAG->begin()->getParent();
+ dbgs() << "\n=== Region: " << DAG->MF.getName() << " BB" << BB->getNumber()
+ << " (" << DAG->SUnits.size() << " SUs) ===\n";
+
+ dbgs() << "\nHWUI Resource Pressure:\n";
+ for (auto &HWUI : HWUInfo) {
+ if (HWUI.getTotalCycles() == 0)
+ continue;
+
+ StringRef Name = getFlavorName(HWUI.getType());
+ dbgs() << " " << Name << ": " << HWUI.getTotalCycles() << " cycles, "
+ << HWUI.size() << " instrs\n";
+ }
+ dbgs() << "\n";
+}
+
+void CandidateHeuristics::sortHWUIResources() {
+ // Highest priority should be first.
+ llvm::sort(HWUInfo, [](HardwareUnitInfo &A, HardwareUnitInfo &B) {
+ // Prefer CoexecWindow producers
+ if (A.producesCoexecWindow() != B.producesCoexecWindow())
+ return A.producesCoexecWindow();
+
+ // Prefer more demanded resources
+ if (A.getTotalCycles() != B.getTotalCycles())
+ return A.getTotalCycles() > B.getTotalCycles();
+
+ // In ties -- prefer the resource with more instructions
+ if (A.size() != B.size())
+ return A.size() < B.size();
+
+ // Default to Flavor order
+ return (unsigned)A.getType() < (unsigned)B.getType();
+ });
+}
+
+bool CandidateHeuristics::tryCriticalResourceDependency(
+ GenericSchedulerBase::SchedCandidate &TryCand,
+ GenericSchedulerBase::SchedCandidate &Cand, SchedBoundary *Zone) const {
+
+ auto HasPrioritySU = [this, &Cand, &TryCand](unsigned ResourceIdx) {
+ const HardwareUnitInfo &HWUI = HWUInfo[ResourceIdx];
+
+ auto CandFlavor = classifyFlavor(*Cand.SU->getInstr(), *SII);
+ auto TryCandFlavor = classifyFlavor(*TryCand.SU->getInstr(), *SII);
+ bool LookDeep = (CandFlavor == InstructionFlavor::DS ||
+ TryCandFlavor == InstructionFlavor::DS) &&
+ HWUI.getType() == InstructionFlavor::WMMA;
+ auto *TargetSU = HWUI.getNextTargetSU(LookDeep);
+
+ // If we do not have a TargetSU for this resource, then it is not critical.
+ if (!TargetSU)
+ return false;
+
+ return true;
+ };
+
+ auto TryEnablesResource = [&Cand, &TryCand, this](unsigned ResourceIdx) {
+ const HardwareUnitInfo &HWUI = HWUInfo[ResourceIdx];
+ auto CandFlavor = classifyFlavor(*Cand.SU->getInstr(), *SII);
+
+ // We want to ensure our DS order matches WMMA order.
+ bool LookDeep = CandFlavor == InstructionFlavor::DS &&
+ HWUI.getType() == InstructionFlavor::WMMA;
+ auto *TargetSU = HWUI.getNextTargetSU(LookDeep);
+
+ bool CandEnables =
+ TargetSU != Cand.SU && DAG->IsReachable(TargetSU, Cand.SU);
+ bool TryCandEnables =
+ TargetSU != TryCand.SU && DAG->IsReachable(TargetSU, TryCand.SU);
+
+ if (!CandEnables && !TryCandEnables)
+ return false;
+
+ if (CandEnables && !TryCandEnables) {
+ if (Cand.Reason > GenericSchedulerBase::RegCritical)
+ Cand.Reason = GenericSchedulerBase::RegCritical;
+
+ return true;
+ }
+
+ if (!CandEnables && TryCandEnables) {
+ TryCand.Reason = GenericSchedulerBase::RegCritical;
+ return true;
+ }
+
+ // Both enable, prefer the critical path.
+ unsigned CandHeight = Cand.SU->getHeight();
+ unsigned TryCandHeight = TryCand.SU->getHeight();
+
+ if (CandHeight > TryCandHeight) {
+ if (Cand.Reason > GenericSchedulerBase::RegCritical)
+ Cand.Reason = GenericSchedulerBase::RegCritical;
+
+ return true;
+ }
+
+ if (CandHeight < TryCandHeight) {
+ TryCand.Reason = GenericSchedulerBase::RegCritical;
+ return true;
+ }
+
+ // Same critical path, just prefer original candidate.
+ if (Cand.Reason > GenericSchedulerBase::RegCritical)
+ Cand.Reason = GenericSchedulerBase::RegCritical;
+
+ return true;
+ };
+
+ for (unsigned I = 0; I < HWUInfo.size(); I++) {
+ // If we have encountered a resource that is not critical, then neither
+ // candidate enables a critical resource
+ if (!HasPrioritySU(I))
+ continue;
+
+ bool Enabled = TryEnablesResource(I);
+ // If neither has enabled the resource, continue to the next resource
+ if (Enabled)
+ return true;
+ }
+ return false;
+}
+
+bool CandidateHeuristics::tryCriticalResource(
+ GenericSchedulerBase::SchedCandidate &TryCand,
+ GenericSchedulerBase::SchedCandidate &Cand, SchedBoundary *Zone) const {
+ for (unsigned I = 0; I < HWUInfo.size(); I++) {
+ const HardwareUnitInfo &HWUI = HWUInfo[I];
+
+ bool CandUsesCrit = HWUI.contains(Cand.SU);
+ bool TryCandUsesCrit = HWUI.contains(TryCand.SU);
+
+ if (!CandUsesCrit && !TryCandUsesCrit)
+ continue;
+
+ if (CandUsesCrit != TryCandUsesCrit) {
+ if (CandUsesCrit) {
+ if (Cand.Reason > GenericSchedulerBase::RegCritical)
+ Cand.Reason = GenericSchedulerBase::RegCritical;
+ return true;
+ }
+ TryCand.Reason = GenericSchedulerBase::RegCritical;
+ return true;
+ }
+
+ // Otherwise, both use the critical resource
+ // For longer latency InstructionFlavors, we should prioritize first by
+ // their enablement of critical resources
+ if (HWUI.getType() == InstructionFlavor::DS) {
+ if (tryCriticalResourceDependency(TryCand, Cand, Zone))
+ return true;
+ }
+
+ // Prioritize based on HWUI priorities.
+ SUnit *Match = HWUI.getHigherPriority(Cand.SU, TryCand.SU);
+ if (Match) {
+ if (Match == Cand.SU) {
+ if (Cand.Reason > GenericSchedulerBase::RegCritical)
+ Cand.Reason = GenericSchedulerBase::RegCritical;
+ return true;
+ }
+ TryCand.Reason = GenericSchedulerBase::RegCritical;
+ return true;
+ }
+ }
+
+ return false;
+}
+
AMDGPUCoExecSchedStrategy::AMDGPUCoExecSchedStrategy(
const MachineSchedContext *C)
: GCNSchedStrategy(C) {
@@ -68,6 +428,12 @@ void AMDGPUCoExecSchedStrategy::initialize(ScheduleDAGMI *DAG) {
RegionPolicy.OnlyBottomUp = false;
GCNSchedStrategy::initialize(DAG);
+ Heurs.initialize(DAG, SchedModel, TRI);
+}
+
+void AMDGPUCoExecSchedStrategy::schedNode(SUnit *SU, bool IsTopNode) {
+ Heurs.updateForScheduling(SU);
+ GCNSchedStrategy::schedNode(SU, IsTopNode);
}
SUnit *AMDGPUCoExecSchedStrategy::pickNode(bool &IsTopNode) {
@@ -82,6 +448,7 @@ SUnit *AMDGPUCoExecSchedStrategy::pickNode(bool &IsTopNode) {
bool PickedPending = false;
SUnit *SU = nullptr;
+ [[maybe_unused]] SchedCandidate *PickedCand = nullptr;
do {
PickedPending = false;
SU = pickOnlyChoice(Top);
@@ -92,10 +459,13 @@ SUnit *AMDGPUCoExecSchedStrategy::pickNode(bool &IsTopNode) {
PickedPending, /*IsBottomUp=*/false);
assert(TopCand.Reason != NoCand && "failed to find a candidate");
SU = TopCand.SU;
+ PickedCand = &TopCand;
}
IsTopNode = true;
} while (SU->isScheduled);
+ LLVM_DEBUG(if (PickedCand) dumpPickSummary(SU, IsTopNode, *PickedCand));
+
if (PickedPending) {
unsigned ReadyCycle = SU->TopReadyCycle;
unsigned CurrentCycle = Top.getCurrCycle();
@@ -149,7 +519,7 @@ void AMDGPUCoExecSchedStrategy::pickNodeFromQueue(
initCandidate(TryCand, SU, Zone.isTop(), RPTracker, SRI, SGPRPressure,
VGPRPressure, IsBottomUp);
SchedBoundary *ZoneArg = Cand.AtTop == TryCand.AtTop ? &Zone : nullptr;
- tryCandidate(Cand, TryCand, ZoneArg);
+ tryCandidateCoexec(Cand, TryCand, ZoneArg);
if (TryCand.Reason != NoCand) {
if (TryCand.ResDelta == SchedResourceDelta())
TryCand.initResourceDelta(Zone.DAG, SchedModel);
@@ -157,7 +527,7 @@ void AMDGPUCoExecSchedStrategy::pickNodeFromQueue(
PickedPending = FromPending;
Cand.setBest(TryCand);
} else {
- printCandidateDecision(TryCand, Cand);
+ LLVM_DEBUG(printCandidateDecision(TryCand, Cand));
}
}
};
@@ -169,9 +539,36 @@ void AMDGPUCoExecSchedStrategy::pickNodeFromQueue(
EvaluateQueue(Zone.Pending, /*FromPending=*/true);
}
-bool AMDGPUCoExecSchedStrategy::tryCandidate(SchedCandidate &Cand,
- SchedCandidate &TryCand,
- SchedBoundary *Zone) const {
+#ifndef NDEBUG
+void AMDGPUCoExecSchedStrategy::dumpPickSummary(SUnit *SU, bool IsTopNode,
+ SchedCandidate &Cand) {
+ const SIInstrInfo *SII = static_cast<const SIInstrInfo *>(DAG->TII);
+ unsigned Cycle = IsTopNode ? Top.getCurrCycle() : Bot.getCurrCycle();
+
+ dbgs() << "=== Pick @ Cycle " << Cycle << " ===\n";
+
+ const InstructionFlavor Flavor = classifyFlavor(*SU->getInstr(), *SII);
+ dbgs() << "Picked: SU(" << SU->NodeNum << ") ";
+ SU->getInstr()->print(dbgs(), /*IsStandalone=*/true, /*SkipOpers=*/false,
+ /*SkipDebugLoc=*/true);
+ dbgs() << " [" << getFlavorName(Flavor) << "]\n";
+
+ dbgs() << " Reason: ";
+ if (LastAMDGPUReason != AMDGPUSchedReason::None)
+ dbgs() << getReasonName(LastAMDGPUReason);
+ else if (Cand.Reason != NoCand)
+ dbgs() << GenericSchedulerBase::getReasonStr(Cand.Reason);
+ else
+ dbgs() << "Unknown";
+ dbgs() << "\n\n";
+
+ LastAMDGPUReason = AMDGPUSchedReason::None;
+}
+#endif
+
+bool AMDGPUCoExecSchedStrategy::tryCandidateCoexec(SchedCandidate &Cand,
+ SchedCandidate &TryCand,
+ SchedBoundary *Zone) {
// Initialize the candidate if needed.
if (!Cand.isValid()) {
TryCand.Reason = FirstValid;
@@ -196,17 +593,21 @@ bool AMDGPUCoExecSchedStrategy::tryCandidate(SchedCandidate &Cand,
// "tie-breaking" in nature.
bool SameBoundary = Zone != nullptr;
if (SameBoundary) {
- // For loops that are acyclic path limited, aggressively schedule for
- // latency. Within an single cycle, whenever CurrMOps > 0, allow normal
- // heuristics to take precedence.
- if (Rem.IsAcyclicLatencyLimited && !Zone->getCurrMOps() &&
- tryLatency(TryCand, Cand, *Zone))
- return TryCand.Reason != NoCand;
-
- // Otherwise compare candidates by the stall they would introduce if
+ // Compare candidates by the stall they would introduce if
// scheduled in the current cycle.
if (tryEffectiveStall(Cand, TryCand, *Zone))
return TryCand.Reason != NoCand;
+
+ Heurs.sortHWUIResources();
+ if (Heurs.tryCriticalResource(TryCand, Cand, Zone)) {
+ LastAMDGPUReason = AMDGPUSchedReason::CritResourceBalance;
+ return TryCand.Reason != NoCand;
+ }
+
+ if (Heurs.tryCriticalResourceDependency(TryCand, Cand, Zone)) {
+ LastAMDGPUReason = AMDGPUSchedReason::CritResourceDep;
+ return TryCand.Reason != NoCand;
+ }
}
// Keep clustered nodes together to encourage downstream peephole
@@ -240,16 +641,6 @@ bool AMDGPUCoExecSchedStrategy::tryCandidate(SchedCandidate &Cand,
return TryCand.Reason != NoCand;
if (SameBoundary) {
- // Avoid critical resource consumption and balance the schedule.
- TryCand.initResourceDelta(DAG, SchedModel);
- if (tryLess(TryCand.ResDelta.CritResources, Cand.ResDelta.CritResources,
- TryCand, Cand, ResourceReduce))
- return TryCand.Reason != NoCand;
- if (tryGreater(TryCand.ResDelta.DemandedResources,
- Cand.ResDelta.DemandedResources, TryCand, Cand,
- ResourceDemand))
- return TryCand.Reason != NoCand;
-
// Avoid serializing long latency dependence chains.
// For acyclic path limited loops, latency was already checked above.
if (!RegionPolicy.DisableLatencyHeuristic && TryCand.Policy.ReduceLatency &&
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.h b/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.h
index 07252c3fb45a7..1684690cd829e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCoExecSchedStrategy.h
@@ -19,12 +19,297 @@
namespace llvm {
+namespace AMDGPU {
+
+//===----------------------------------------------------------------------===//
+// Instruction Flavor Classification
+//===----------------------------------------------------------------------===//
+
+enum class InstructionFlavor : uint8_t {
+ WMMA, // WMMA/MFMA matrix operations
+ SingleCycleVALU, // Single-cycle VALU (not TRANS32, not multi-cycle CVT)
+ TRANS, // Transcendental ops (v_exp, v_log, etc.)
+ MultiCycleVALU, // VALU instructions with repeat rate > 1
+ VMEM, // FLAT/GLOBAL memory operations
+ DS, // LDS/GDS operations
+ SALU, // Scalar ALU
+ DMA, // Tensor DMA operations
+ Fence, // Fences and waits
+ Other, // Everything else
+ NUM_FLAVORS
+};
+
+inline StringRef getFlavorName(InstructionFlavor F) {
+ switch (F) {
+ case InstructionFlavor::WMMA:
+ return "WMMA";
+ case InstructionFlavor::SingleCycleVALU:
+ return "VALU(1c)";
+ case InstructionFlavor::TRANS:
+ return "TRANS";
+ case InstructionFlavor::MultiCycleVALU:
+ return "VALU(Nc)";
+ case InstructionFlavor::VMEM:
+ return "VMEM";
+ case InstructionFlavor::DS:
+ return "DS";
+ case InstructionFlavor::SALU:
+ return "SALU";
+ case InstructionFlavor::DMA:
+ return "DMA";
+ case InstructionFlavor::Fence:
+ return "Fence";
+ case InstructionFlavor::Other:
+ return "Other";
+ case InstructionFlavor::NUM_FLAVORS:
+ return "???";
+ }
+ llvm_unreachable("Unknown InstructionFlavor");
+}
+
+inline StringRef getFlavorShortName(InstructionFlavor F) {
+ switch (F) {
+ case InstructionFlavor::WMMA:
+ return "W";
+ case InstructionFlavor::SingleCycleVALU:
+ return "V";
+ case InstructionFlavor::TRANS:
+ return "T";
+ case InstructionFlavor::MultiCycleVALU:
+ return "C";
+ case InstructionFlavor::VMEM:
+ return "M";
+ case InstructionFlavor::DS:
+ return "D";
+ case InstructionFlavor::SALU:
+ return "S";
+ case InstructionFlavor::DMA:
+ return "X";
+ case InstructionFlavor::Fence:
+ return "F";
+ case InstructionFlavor::Other:
+ return "O";
+ case InstructionFlavor::NUM_FLAVORS:
+ return "?";
+ }
+ llvm_unreachable("Unknown InstructionFlavor");
+}
+
+InstructionFlavor classifyFlavor(const MachineInstr &MI,
+ const SIInstrInfo &SII);
+
+using FlavorGroup = SmallVector<InstructionFlavor, 4>;
+
+namespace FlavorGroups {
+inline FlavorGroup allVALU() {
+ return {InstructionFlavor::SingleCycleVALU, InstructionFlav...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/189121
More information about the llvm-commits
mailing list