LLVM 24.0.0git
GCNSchedStrategy.h
Go to the documentation of this file.
1//===-- GCNSchedStrategy.h - GCN Scheduler Strategy -*- C++ -*-------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_AMDGPU_GCNSCHEDSTRATEGY_H
14#define LLVM_LIB_TARGET_AMDGPU_GCNSCHEDSTRATEGY_H
15
16#include "GCNRegPressure.h"
17#include "GCNRematStrategy.h"
18#include "llvm/ADT/DenseMap.h"
24
25namespace llvm {
26
27struct VGPRThresholdParser : public cl::parser<unsigned> {
29 bool parse(cl::Option &O, StringRef ArgName, StringRef Arg, unsigned &Value);
30};
31
32extern cl::opt<unsigned, false, VGPRThresholdParser> VGPRThresholdPercentOpt;
33
34class SIMachineFunctionInfo;
35class SIRegisterInfo;
36class GCNSubtarget;
37class GCNSchedStage;
38
49
50#ifndef NDEBUG
51raw_ostream &operator<<(raw_ostream &OS, const GCNSchedStageID &StageID);
52#endif
53
54/// This is a minimal scheduler strategy. The main difference between this
55/// and the GenericScheduler is that GCNSchedStrategy uses different
56/// heuristics to determine excess/critical pressure sets.
58protected:
59 SUnit *pickNodeBidirectional(bool &IsTopNode, bool &PickedPending);
60
61 void pickNodeFromQueue(SchedBoundary &Zone, const CandPolicy &ZonePolicy,
62 const RegPressureTracker &RPTracker,
63 SchedCandidate &Cand, bool &IsPending,
64 bool IsBottomUp);
65
66 void initCandidate(SchedCandidate &Cand, SUnit *SU, bool AtTop,
67 const RegPressureTracker &RPTracker,
68 const SIRegisterInfo *SRI, unsigned SGPRPressure,
69 unsigned VGPRPressure, unsigned AGPRPressure,
70 bool IsBottomUp);
71
72 /// Evaluates instructions in the pending queue using a subset of scheduling
73 /// heuristics.
74 ///
75 /// Instructions that cannot be issued due to hardware constraints are placed
76 /// in the pending queue rather than the available queue, making them normally
77 /// invisible to scheduling heuristics. However, in certain scenarios (such as
78 /// avoiding register spilling), it may be beneficial to consider scheduling
79 /// these not-yet-ready instructions.
81 SchedBoundary *Zone) const;
82
83 void printCandidateDecision(const SchedCandidate &Current,
84 const SchedCandidate &Preferred);
85
86 void getRegisterPressures(bool AtTop, const RegPressureTracker &RPTracker,
87 SUnit *SU, std::vector<unsigned> &Pressure,
88 std::vector<unsigned> &MaxPressure,
91 ScheduleDAGMI *DAG, const SIRegisterInfo *SRI);
92
93 /// \returns the ArchVGPR and AGPR pressure of \p RP after distributing
94 /// bank-agnostic AVGPR pressure across the two banks.
95 std::pair<unsigned, unsigned>
96 getBankedPressure(const GCNRegPressure &RP) const;
97
98 const AMDGPUOptions &CLOpts;
99
100 std::vector<unsigned> Pressure;
101
102 std::vector<unsigned> MaxPressure;
103
104 /// Capacity of the ArchVGPR bank, captured before VGPRExcessLimit is cut
105 /// down by ErrorMargin, VGPRLimitBias, or VGPRThresholdPercent.
106 unsigned ArchVGPRBankLimit = 0;
107
108 /// Capacity of the AGPR bank, captured before AGPRExcessLimit is cut down by
109 /// ErrorMargin and VGPRLimitBias. Zero when no AGPRs are allocatable.
110 unsigned AGPRBankLimit = 0;
111
112 /// Budget for the combined ArchVGPR + AGPR file, or zero on targets without
113 /// one.
115
116 /// Combined-file pressure of the candidate most recently passed to
117 /// getRegisterPressures(). Only maintained when the GCN trackers are in use.
119
121
123
124 // Scheduling stages for this strategy.
126
127 // Pointer to the current SchedStageID.
129
130 // GCN RP Tracker for top-down scheduling
132
133 // GCN RP Tracker for botttom-up scheduling
135
136 bool UseGCNTrackers = false;
137
138 std::optional<bool> GCNTrackersOverride;
139
140public:
141 // schedule() have seen register pressure over the critical limits and had to
142 // track register pressure for actual scheduling heuristics.
144
145 // Schedule known to have excess register pressure. Be more conservative in
146 // increasing ILP and preserving VGPRs.
147 bool KnownExcessRP = false;
148
149 // An error margin is necessary because of poor performance of the generic RP
150 // tracker and can be adjusted up for tuning heuristics to try and more
151 // aggressively reduce register pressure.
152 unsigned ErrorMargin = 3;
153
154 // Bias for SGPR limits under a high register pressure.
155 const unsigned HighRPSGPRBias = 7;
156
157 // Bias for VGPR limits under a high register pressure.
158 const unsigned HighRPVGPRBias = 7;
159
160 unsigned SGPRExcessLimit = 0;
161
162 unsigned VGPRExcessLimit = 0;
163
164 unsigned AGPRExcessLimit = 0;
165
166 /// \returns the allocatable ArchVGPR and AGPR counts.
167 std::pair<unsigned, unsigned> getBankLimits() const {
169 }
170
171 unsigned SGPRCriticalLimit = 0;
172
173 unsigned VGPRCriticalLimit = 0;
174
175 // Occupancy budget for the combined VGPR/AGPR allocation on unified targets.
176 // Unlike the per-bank limit, this is not clamped to allocatable VGPRs.
178
179 unsigned AGPRCriticalLimit = 0;
180
181 unsigned SGPRLimitBias = 0;
182
183 unsigned VGPRLimitBias = 0;
184
186
188
189 SUnit *pickNode(bool &IsTopNode) override;
190
191 void schedNode(SUnit *SU, bool IsTopNode) override;
192
193 void initialize(ScheduleDAGMI *DAG) override;
194
195 unsigned getTargetOccupancy() { return TargetOccupancy; }
196
197 void setTargetOccupancy(unsigned Occ) { TargetOccupancy = Occ; }
198
200
201 // Advances stage. Returns true if there are remaining stages.
202 bool advanceStage();
203
204 bool hasNextStage() const;
205
206 bool useGCNTrackers() const {
207 return GCNTrackersOverride.value_or(UseGCNTrackers);
208 }
209
211
213};
214
215/// The goal of this scheduling strategy is to maximize kernel occupancy (i.e.
216/// maximum number of waves per simd).
218public:
220 bool IsLegacyScheduler = false);
221};
222
223/// The goal of this scheduling strategy is to maximize ILP for a single wave
224/// (i.e. latency hiding).
226protected:
227 bool tryCandidate(SchedCandidate &Cand, SchedCandidate &TryCand,
228 SchedBoundary *Zone) const override;
229
230public:
232};
233
234/// The goal of this scheduling strategy is to maximize memory clause for a
235/// single wave.
237protected:
238 bool tryCandidate(SchedCandidate &Cand, SchedCandidate &TryCand,
239 SchedBoundary *Zone) const override;
240
241public:
243};
244
246 unsigned ScheduleLength;
247 unsigned BubbleCycles;
248
249public:
250 ScheduleMetrics() = default;
251 ScheduleMetrics(unsigned L, unsigned BC)
252 : ScheduleLength(L), BubbleCycles(BC) {}
253 unsigned getLength() const { return ScheduleLength; }
254 unsigned getBubbles() const { return BubbleCycles; }
255 unsigned getMetric() const {
256 unsigned Metric = (BubbleCycles * ScaleFactor) / ScheduleLength;
257 // Metric is zero if the amount of bubbles is less than 1% which is too
258 // small. So, return 1.
259 return Metric ? Metric : 1;
260 }
261 static const unsigned ScaleFactor;
262};
263
265 dbgs() << "\n Schedule Metric (scaled by " << ScheduleMetrics::ScaleFactor
266 << " ) is: " << Sm.getMetric() << " [ " << Sm.getBubbles() << "/"
267 << Sm.getLength() << " ]\n";
268 return OS;
269}
270
271class GCNScheduleDAGMILive;
274 // The live in/out pressure as indexed by the first or last MI in the region
275 // before scheduling.
277 // The mapping of RegionIDx to key instruction
278 DenseMap<unsigned, MachineInstr *> IdxToInstruction;
279 // Whether we are calculating LiveOuts or LiveIns
280 bool IsLiveOut;
281
282public:
283 RegionPressureMap() = default;
285 : DAG(GCNDAG), IsLiveOut(LiveOut) {}
286 // Build the Instr->LiveReg and RegionIdx->Instr maps
287 void buildLiveRegMap();
288
289 // Retrieve the LiveReg for a given RegionIdx
291 assert(IdxToInstruction.contains(RegionIdx));
292 MachineInstr *Key = IdxToInstruction[RegionIdx];
293 return RegionLiveRegMap[Key];
294 }
295};
296
297/// A region's boundaries i.e. a pair of instruction bundle iterators. The lower
298/// boundary is inclusive, the upper boundary is exclusive.
300 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>;
301
303 friend class GCNSchedStage;
308 friend class PreRARematStage;
311 friend class RegionPressureMap;
312
313 const GCNSubtarget &ST;
314
316
317 // Occupancy target at the beginning of function scheduling cycle.
318 unsigned StartingOccupancy;
319
320 // Minimal real occupancy recorder for the function.
321 unsigned MinOccupancy;
322
323 // Vector of regions recorder for later rescheduling
325
326 // Record regions with high register pressure.
327 BitVector RegionsWithHighRP;
328
329 // Record regions with excess register pressure over the physical register
330 // limit. Register pressure in these regions usually will result in spilling.
331 BitVector RegionsWithExcessRP;
332
333 // Regions that have IGLP instructions (SCHED_GROUP_BARRIER or IGLP_OPT).
334 BitVector RegionsWithIGLPInstrs;
335
336 // Region live-in cache.
338
339 // Region pressure cache.
341
342 // Temporary basic block live-in cache.
344
345 // The map of the initial first region instruction to region live in registers
347
348 // Calculate the map of the initial first region instruction to region live in
349 // registers
351
352 // Calculate the map of the initial last region instruction to region live out
353 // registers
355 getRegionLiveOutMap() const;
356
357 // The live out registers per region. These are internally stored as a map of
358 // the initial last region instruction to region live out registers, but can
359 // be retreived with the regionIdx by calls to getLiveRegsForRegionIdx.
360 RegionPressureMap RegionLiveOuts;
361
362 // Return current region pressure.
363 /// \returns the maximum pressure of region \p RegionIdx. If set, \p
364 /// PressureCallback is called with the pressure of every program point of
365 /// the region.
366 GCNRegPressure getRealRegPressure(unsigned RegionIdx,
367 std::function<void(const GCNRegPressure &)>
368 PressureCallback = nullptr) const;
369
370 // Compute and cache live-ins and pressure for all regions in block.
371 void computeBlockPressure(unsigned RegionIdx, const MachineBasicBlock *MBB);
372
373 /// Makes the scheduler try to achieve an occupancy of \p TargetOccupancy.
374 void setTargetOccupancy(unsigned TargetOccupancy);
375
376 void runSchedStages();
377
378 std::unique_ptr<GCNSchedStage> createSchedStage(GCNSchedStageID SchedStageID);
379
380public:
382 std::unique_ptr<MachineSchedStrategy> S);
383
384 void schedule() override;
385
386 void finalizeSchedule() override;
387};
388
389// GCNSchedStrategy applies multiple scheduling stages to a function.
391protected:
393
395
397
399
401
403
404 // The current block being scheduled.
406
407 // Current region index.
408 unsigned RegionIdx = 0;
409
410 // Record the original order of instructions before scheduling.
411 std::vector<MachineInstr *> Unsched;
412
413 // RP before scheduling the current region.
415
416 // RP after scheduling the current region.
418
419 std::vector<std::unique_ptr<ScheduleDAGMutation>> SavedMutations;
420
422
423public:
424 // Initialize state for a scheduling stage. Returns false if the current stage
425 // should be skipped.
426 virtual bool initGCNSchedStage();
427
428 // Finalize state after finishing a scheduling pass on the function.
429 virtual void finalizeGCNSchedStage();
430
431 // Setup for scheduling a region. Returns false if the current region should
432 // be skipped.
433 virtual bool initGCNRegion();
434
435 // Finalize state after scheduling a region.
436 virtual void finalizeGCNRegion();
437
438 // Track whether a new region is also a new MBB.
439 void setupNewBlock();
440
441 // Check result of scheduling.
442 void checkScheduling();
443
444 // computes the given schedule virtual execution time in clocks
445 ScheduleMetrics getScheduleMetrics(const std::vector<SUnit> &InputSchedule);
447 unsigned computeSUnitReadyCycle(const SUnit &SU, unsigned CurrCycle,
448 DenseMap<unsigned, unsigned> &ReadyCycles,
449 const TargetSchedModel &SM);
450
451 // Returns true if scheduling should be reverted.
452 virtual bool shouldRevertScheduling(unsigned WavesAfter);
453
454 // Returns true if current region has known excess pressure.
455 bool isRegionWithExcessRP() const {
456 return DAG.RegionsWithExcessRP[RegionIdx];
457 }
458
459 // The region number this stage is currently working on
460 unsigned getRegionIdx() { return RegionIdx; }
461
462 // Returns true if the new schedule may result in more spilling.
463 bool mayCauseSpilling(unsigned WavesAfter);
464
465 /// Sets the schedule of region \p RegionIdx to \p MIOrder. The MIs in \p
466 /// MIOrder must be exactly the same as the ones currently existing inside the
467 /// region, only in a different order that honors def-use chains.
468 void modifyRegionSchedule(unsigned RegionIdx,
470
472
473 virtual ~GCNSchedStage() = default;
474};
475
483
485private:
486 // Record regions with excess archvgpr register pressure over the physical
487 // register limit. Register pressure in these regions usually will result in
488 // spilling.
489 BitVector RegionsWithExcessArchVGPR;
490
491 const SIInstrInfo *TII;
492 const SIRegisterInfo *SRI;
493
494 /// Per-candidate cache of the src2 "needs VGPR" decision, computed once
495 /// and reused on-demand.
496 DenseMap<const MachineInstr *, bool> Src2NeedsVGPRCache;
497
498 /// Do a speculative rewrite and collect copy locations. The speculative
499 /// rewrite allows us to calculate the RP of the code after the rewrite, and
500 /// the copy locations allow us to calculate the total cost of copies required
501 /// for the rewrite. Stores the rewritten instructions in \p RewriteCands ,
502 /// the copy locations for uses (of the MFMA result) in \p CopyForUse and the
503 /// copy locations for defs (of the MFMA operands) in \p CopyForDef
504 bool
505 initHeuristics(std::vector<std::pair<MachineInstr *, unsigned>> &RewriteCands,
506 DenseMap<MachineBasicBlock *, std::set<Register>> &CopyForUse,
508
509 /// Calculate the rewrite cost and undo the state change (e.g. rewriting) done
510 /// in initHeuristics. Uses \p CopyForUse and \p CopyForDef to calculate copy
511 /// costs, and \p RewriteCands to undo rewriting.
512 int64_t getRewriteCost(
513 ArrayRef<std::pair<MachineInstr *, unsigned>> RewriteCands,
514 const DenseMap<MachineBasicBlock *, std::set<Register>> &CopyForUse,
515 const SmallPtrSetImpl<MachineInstr *> &CopyForDef);
516
517 /// Do the final rewrite on \p RewriteCands and insert any needed copies.
518 bool rewrite(ArrayRef<std::pair<MachineInstr *, unsigned>> RewriteCands);
519
520 /// \returns true if this MI is a rewrite candidate.
521 bool isRewriteCandidate(MachineInstr *MI) const;
522
523 /// Resets all candidates in \p RewriteCands back to VGPR form.
524 void resetRewriteCandsToVGPR(
525 ArrayRef<std::pair<MachineInstr *, unsigned>> RewriteCands);
526
527 /// Finds all the reaching defs of \p UseMO and stores the SlotIndexes into \p
528 /// DefIdxs
529 void findReachingDefs(MachineOperand &UseMO, LiveIntervals *LIS,
531
532 /// Finds all the reaching uses of \p DefMI and stores the use operands in \p
533 /// ReachingUses
534 void findReachingUses(const MachineInstr *DefMI, LiveIntervals *LIS,
536
537 /// Returns true if the src2 register with reaching defs \p Src2ReachingDefs
538 /// has a use other than a group MFMA (in \p RewriteSet) or a copy, which
539 /// would keep it in VGPR form rather than let it be reclassified to AGPR.
540 bool hasUseRequiringVGPR(ArrayRef<SlotIndex> Src2ReachingDefs,
541 const SmallPtrSetImpl<MachineInstr *> &RewriteSet);
542
543public:
544 bool initGCNSchedStage() override;
545
548};
549
551private:
552 // Save the initial occupancy before starting this stage.
553 unsigned InitialOccupancy;
554 // Save the temporary target occupancy before starting this stage.
555 unsigned TempTargetOccupancy;
556 // Track whether any region was scheduled by this stage.
557 bool IsAnyRegionScheduled;
558
559public:
560 bool initGCNSchedStage() override;
561
562 void finalizeGCNSchedStage() override;
563
564 bool initGCNRegion() override;
565
566 bool shouldRevertScheduling(unsigned WavesAfter) override;
567
570};
571
572// Retry function scheduling if we found resulting occupancy and it is
573// lower than used for other scheduling passes. This will give more freedom
574// to schedule low register pressure blocks.
576public:
577 bool initGCNSchedStage() override;
578
579 bool initGCNRegion() override;
580
581 bool shouldRevertScheduling(unsigned WavesAfter) override;
582
585};
586
587/// Attempts to reduce function spilling or, if there is no spilling, to
588/// increase function occupancy by one with respect to register usage by sinking
589/// rematerializable instructions to their use. When the stage estimates that
590/// reducing spilling or increasing occupancy is possible, it tries to
591/// rematerialize as few registers as possible to reduce potential negative
592/// effects on function latency. Uses `GCNRematStrategy` to drive
593/// rematerializations.
595private:
596 /// Live-outs are not maintained in a contiguous array so we have to have one
597 /// here to give to the strategy.
599 /// Rematerialization strategy.
600 std::unique_ptr<GCNRematStrategy> Strategy;
601 /// The target occupancy the stage is tring to achieve. Empty when the
602 /// objective is spill reduction.
603 std::optional<unsigned> TargetOcc;
604 /// Achieved occupancy *only* through rematerializations (pre-rescheduling).
605 unsigned AchievedOcc;
606 /// After successful stage initialization, indicates which regions should be
607 /// rescheduled.
608 BitVector RescheduleRegions;
609
610 /// State of a region pre-re-scheduling but post-rematerializations that we
611 /// must keep to be able to revert re-scheduling effects.
612 struct RegionSchedRevert {
613 /// Region number.
614 unsigned RegionIdx;
615 /// Original instruction order (both debug and non-debug MIs).
616 std::vector<MachineInstr *> OrigMIOrder;
617 /// Maximum pressure recorded in the region.
618 GCNRegPressure MaxPressure;
619
620 RegionSchedRevert(unsigned RegionIdx, ArrayRef<MachineInstr *> OrigMIOrder,
621 const GCNRegPressure &MaxPressure)
622 : RegionIdx(RegionIdx), OrigMIOrder(OrigMIOrder),
623 MaxPressure(MaxPressure) {}
624 };
625 /// After re-scheduling, contains pre-re-scheduling data for all re-scheduled
626 /// regions.
627 SmallVector<RegionSchedRevert> RegionReverts;
628 /// Whether we should revert all re-scheduled regions.
629 bool RevertAllRegions = false;
630
631 /// Returns the occupancy the stage is trying to achieve.
632 unsigned getStageTargetOccupancy() const;
633
634 /// If remat alone did not increase occupancy to the target one, rollbacks all
635 /// rematerializations and resets live-ins/RP in all regions impacted by the
636 /// stage to their pre-stage values.
637 void finalizeGCNSchedStage() override;
638
639public:
640 bool initGCNSchedStage() override;
641
642 bool initGCNRegion() override;
643
644 void finalizeGCNRegion() override;
645
646 bool shouldRevertScheduling(unsigned WavesAfter) override;
647
650};
651
659
668
669// Live interval register pressure stage:
670// estimates register pressure accounting for live interval interference,
671// optionally reschedules the region with tigher register bounds.
673public:
674 bool initGCNSchedStage() override;
675 bool initGCNRegion() override;
676 void finalizeGCNRegion() override;
677
680
681private:
682 unsigned SavedVGPRThresholdPercent = 0;
683 unsigned SavedVGPRExcessLimit = 0;
684 unsigned SavedVGPRCriticalLimit = 0;
685 unsigned SavedUnifiedVGPRCriticalLimit = 0;
686};
687
689private:
690 std::vector<std::unique_ptr<ScheduleDAGMutation>> SavedMutations;
691
692 bool HasIGLPInstrs = false;
693
694public:
695 void schedule() override;
696
697 void finalizeSchedule() override;
698
700 std::unique_ptr<MachineSchedStrategy> S,
701 bool RemoveKillFlags);
702};
703
704} // End namespace llvm
705
706#endif // LLVM_LIB_TARGET_AMDGPU_GCNSCHEDSTRATEGY_H
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the DenseMap class.
This file defines the GCNRegPressure class, which tracks registry pressure by bookkeeping number of S...
Rematerialization strategy, based on the target-independent rematerializer.
IRTranslator LLVM IR MI
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
bool shouldRevertScheduling(unsigned WavesAfter) override
ClusteredLowOccStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
Common behavior for downward RP trackers. Unconstructible directly.
Downward RP tracker that relies on the user to provide the next instruction down the instruction stre...
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)
DenseMap< unsigned, LaneBitmask > LiveRegSet
GCNSchedStrategy & S
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
MachineFunction & MF
virtual void finalizeGCNRegion()
SIMachineFunctionInfo & MFI
unsigned computeSUnitReadyCycle(const SUnit &SU, unsigned CurrCycle, DenseMap< unsigned, unsigned > &ReadyCycles, const TargetSchedModel &SM)
virtual ~GCNSchedStage()=default
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
const GCNSubtarget & ST
This is a minimal scheduler strategy.
const unsigned HighRPSGPRBias
GCNSchedStrategy(const MachineSchedContext *C)
SmallVector< GCNSchedStageID, 4 > SchedStages
std::vector< unsigned > MaxPressure
unsigned CandUnifiedVGPRPressure
Combined-file pressure of the candidate most recently passed to getRegisterPressures().
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
void schedNode(SUnit *SU, bool IsTopNode) override
Notify MachineSchedStrategy that ScheduleDAGMI has scheduled an instruction and updated scheduled/rem...
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
void getRegisterPressures(bool AtTop, const RegPressureTracker &RPTracker, SUnit *SU, std::vector< unsigned > &Pressure, std::vector< unsigned > &MaxPressure, const GCNDownwardRPTrackerBase &DownwardTracker, const GCNUpwardRPTracker &UpwardTracker, ScheduleDAGMI *DAG, const SIRegisterInfo *SRI)
std::vector< unsigned > Pressure
std::pair< unsigned, unsigned > getBankLimits() const
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)
const unsigned HighRPVGPRBias
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)
void setTargetOccupancy(unsigned Occ)
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)
ScheduleDAGMILive * DAG
GenericScheduler(const MachineSchedContext *C)
bool shouldRevertScheduling(unsigned WavesAfter) override
ILPInitialScheduleStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
LiveIntervalRPStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
bool shouldRevertScheduling(unsigned WavesAfter) override
MemoryClauseInitialScheduleStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
bool shouldRevertScheduling(unsigned WavesAfter) override
OccInitialScheduleStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
PreRARematStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
bool shouldRevertScheduling(unsigned WavesAfter) override
void finalizeGCNRegion() override
bool initGCNSchedStage() override
Track the current register pressure at some position in the instruction stream, and remember the high...
GCNRPTracker::LiveRegSet & getLiveRegsForRegionIdx(unsigned RegionIdx)
RegionPressureMap(GCNScheduleDAGMILive *GCNDAG, bool LiveOut)
RewriteMFMAFormStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Scheduling unit. This is a node in the scheduling DAG.
Each Scheduling boundary is associated with ready queues.
bool RemoveKillFlags
True if the DAG builder should remove kill flags (in preparation for rescheduling).
ScheduleDAGMILive(MachineSchedContext *C, std::unique_ptr< MachineSchedStrategy > S)
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
ScheduleDAGMI(MachineSchedContext *C, std::unique_ptr< MachineSchedStrategy > S, bool RemoveKillFlags)
unsigned getBubbles() const
ScheduleMetrics(unsigned L, unsigned BC)
unsigned getLength() const
static const unsigned ScaleFactor
unsigned getMetric() const
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::iterator iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Provide an instruction scheduling machine model to CodeGen passes.
UnclusteredHighRPStage(GCNSchedStageID StageID, GCNScheduleDAGMILive &DAG)
bool shouldRevertScheduling(unsigned WavesAfter) override
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This namespace contains all of the command line option processing machinery.
This is an optimization pass for GlobalISel generic memory operations.
std::pair< MachineBasicBlock::iterator, MachineBasicBlock::iterator > RegionBoundaries
A region's boundaries i.e.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
cl::opt< unsigned, false, VGPRThresholdParser > VGPRThresholdPercentOpt
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
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...
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
bool parse(cl::Option &O, StringRef ArgName, StringRef Arg, unsigned &Value)
VGPRThresholdParser(cl::Option &O)