63 std::list<MachineInstr*> EmittedInstrs;
68 std::list<MachineInstr *> EmittedVALUInstrs;
73 static constexpr unsigned MaxVALULookAhead = 18;
77 bool HasPendingWMMACoexecHazard =
false;
88 bool RunLdsBranchVmemWARHazardFixup;
99 std::optional<unsigned> CurrentCoExecStage;
102 unsigned CyclesUntilTRANS = 0;
105 unsigned CyclesUntilVALU = 0;
109 std::array<char, AMDGPU::MaxCoExecStages> CoExecWindowLog;
112 void dumpCoExecWindow()
const;
115 bool hasCoExecWindowModel()
const;
146 void schedulerAdvanceCycle();
149 void schedulerReset();
157 void resetClause()
const {
162 void addClauseInst(
const MachineInstr &
MI)
const;
166 unsigned getMFMAPipelineWaitStates(
const MachineInstr &
MI)
const;
170 void processBundle();
174 void runOnInstruction(MachineInstr *
MI);
178 using WindowForFn = function_ref<std::optional<int>(
const MachineInstr &)>;
184 int getMaxWindowDeficit(
int MaxWindow, WindowForFn WindowFor)
const;
185 int getMaxVALUWindowDeficit(
int MaxWindow, WindowForFn WindowFor)
const;
190 int getWaitStatesSinceDef(
unsigned Reg,
IsHazardFn IsHazardDef,
192 int getWaitStatesSinceSetReg(
IsHazardFn IsHazard,
int Limit)
const;
194 int checkSoftClauseHazards(MachineInstr *SMEM)
const;
195 int checkSMRDHazards(MachineInstr *SMRD)
const;
196 int checkVMEMHazards(MachineInstr *VMEM)
const;
197 int checkDPPHazards(MachineInstr *DPP)
const;
198 int checkDivFMasHazards(MachineInstr *DivFMas)
const;
199 int checkGetRegHazards(MachineInstr *GetRegInstr)
const;
200 int checkSetRegHazards(MachineInstr *SetRegInstr)
const;
201 int createsVALUHazard(
const MachineInstr &
MI)
const;
202 int checkVALUHazards(MachineInstr *VALU)
const;
203 int checkVALUHazardsHelper(
const MachineOperand &Def,
204 const MachineRegisterInfo &
MRI)
const;
205 int checkUniformWindowVALUHazardsHelper(
Register Reg)
const;
206 int checkSOFFSETWindowVALUHazardsHelper(
Register Reg)
const;
207 int checkRWLaneHazards(MachineInstr *RWLane)
const;
208 int checkRFEHazards(MachineInstr *RFE)
const;
209 int checkInlineAsmHazards(MachineInstr *IA)
const;
210 int checkReadM0Hazards(MachineInstr *SMovRel)
const;
211 int checkNSAtoVMEMHazard(MachineInstr *
MI)
const;
212 int checkFPAtomicToDenormModeHazard(MachineInstr *
MI)
const;
216 int WaitStatesNeeded,
bool IsHoisting =
false);
217 void fixHazards(MachineInstr *
MI);
218 bool fixVcmpxPermlaneHazards(MachineInstr *
MI);
219 bool fixVMEMtoScalarWriteHazards(MachineInstr *
MI);
220 bool fixSMEMtoVectorWriteHazards(MachineInstr *
MI);
221 bool fixVcmpxExecWARHazard(MachineInstr *
MI);
222 bool fixLdsBranchVmemWARHazard(MachineInstr *
MI);
223 bool fixLdsDirectVALUHazard(MachineInstr *
MI);
224 bool fixLdsDirectVMEMHazard(MachineInstr *
MI);
225 bool fixVALUPartialForwardingHazard(MachineInstr *
MI);
226 bool fixVALUTransUseHazard(MachineInstr *
MI);
227 bool fixVALUTransCoexecutionHazards(MachineInstr *
MI);
228 bool fixWMMAHazards(MachineInstr *
MI);
229 int checkWMMACoexecutionHazards(MachineInstr *
MI)
const;
230 bool fixWMMACoexecutionHazards(MachineInstr *
MI);
231 bool tryHoistWMMAVnopsFromLoop(MachineInstr *
MI,
int WaitStatesNeeded);
232 bool hasWMMAHazardInLoop(MachineLoop *L, MachineInstr *
MI,
233 bool IncludeSubloops =
true);
234 bool hasWMMAToWMMARegOverlap(
const MachineInstr &WMMA,
235 const MachineInstr &
MI)
const;
236 bool hasWMMAToVALURegOverlap(
const MachineInstr &WMMA,
237 const MachineInstr &
MI)
const;
238 bool isCoexecutionHazardFor(
const MachineInstr &
I,
239 const MachineInstr &
MI)
const;
240 bool fixShift64HighRegBug(MachineInstr *
MI);
241 bool fixVPermPk16Hazard(MachineInstr *
MI);
242 bool fixVALUMaskWriteHazard(MachineInstr *
MI);
243 bool fixRequiredExportPriority(MachineInstr *
MI);
244 bool fixGetRegWaitIdle(MachineInstr *
MI);
245 bool fixDsAtomicAsyncBarrierArriveB64(MachineInstr *
MI);
246 bool fixScratchBaseForwardingHazard(MachineInstr *
MI);
247 bool fixSetRegMode(MachineInstr *
MI);
248 bool fixTDM(MachineInstr *
MI);
249 bool fixTransF16ToPartialVGPRWriteHazard(MachineInstr *
MI);
253 int getMFMAReadWaitStates(
const MachineInstr &Consumer,
257 int checkMAIHazards(MachineInstr *
MI)
const;
258 int checkMAIHazards908(MachineInstr *
MI)
const;
259 int checkMAIHazards90A(MachineInstr *
MI)
const;
263 int getMFMAOverlappedSrcCWaitStates(
const MachineInstr *Reader,
264 const MachineInstr *Writer)
const;
280 int checkMFMAPadding(MachineInstr *
MI)
const;
281 int checkMAIVALUHazards(MachineInstr *
MI)
const;
282 int checkMAILdStHazards(MachineInstr *
MI)
const;
283 int checkPermlaneHazards(MachineInstr *
MI)
const;
288 MachineLoopInfo *MLI =
nullptr);
292 MachineLoopInfo *MLI =
nullptr);
338 void Reset()
override;
static int getWaitStatesSince(GCNHazardRecognizer::IsHazardFn IsHazard, const MachineBasicBlock *MBB, MachineBasicBlock::const_reverse_instr_iterator I, int WaitStates, GCNHazardRecognizer::IsExpiredFn IsExpired, DenseSet< const MachineBasicBlock * > &Visited, GCNHazardRecognizer::GetNumWaitStatesFn GetNumWaitStates=SIInstrInfo::getNumWaitStates)
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))