@@ -345,13 +345,13 @@ class PipelineSolver {
345345 // return the number of edges missed.
346346 int addEdges (SmallVectorImpl<SchedGroup> &SyncPipeline, SUnit *SU, int SGID,
347347 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges);
348- // Link the pipeline as if \p SU was in the SchedGroup with ID \p SGID. It
349- // returns the cost (in terms of missed pipeline edges), and tracks the edges
350- // added in \p AddedEdges
348+ // / Link the pipeline as if \p SU was in the SchedGroup with ID \p SGID. It
349+ // / returns the cost (in terms of missed pipeline edges), and tracks the edges
350+ // / added in \p AddedEdges
351351 template <typename T>
352352 int linkSUnit (SUnit *SU, int SGID,
353353 std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges, T I, T E);
354- // Remove the edges passed via \p AddedEdges
354+ // / Remove the edges passed via \p AddedEdges
355355 void removeEdges (const std::vector<std::pair<SUnit *, SUnit *>> &AddedEdges);
356356 // Convert the passed in maps to arrays for bidirectional iterators
357357 void convertSyncMapsToArrays ();
@@ -851,11 +851,11 @@ class IGLPStrategy {
851851 const SIInstrInfo *TII;
852852
853853public:
854- // Add SchedGroups to \p Pipeline to implement this Strategy.
854+ // / Add SchedGroups to \p SyncedSchedGroups to implement this Strategy.
855855 virtual void applyIGLPStrategy (
856856 DenseMap<int , SUnitsToCandidateSGsMap> &SyncedInstrs,
857857 DenseMap<int , SmallVector<SchedGroup, 4 >> &SyncedSchedGroups,
858- bool IsPostRA ) = 0;
858+ bool IsReentry ) = 0;
859859
860860 // Returns true if this strategy should be applied to a ScheduleDAG.
861861 virtual bool shouldApplyStrategy (ScheduleDAGInstrs *DAG) = 0;
@@ -874,7 +874,7 @@ class MFMASmallGemmOpt final : public IGLPStrategy {
874874 void applyIGLPStrategy (
875875 DenseMap<int , SUnitsToCandidateSGsMap> &SyncedInstrs,
876876 DenseMap<int , SmallVector<SchedGroup, 4 >> &SyncedSchedGroups,
877- bool IsPostRA ) override ;
877+ bool IsReentry ) override ;
878878
879879 bool shouldApplyStrategy (ScheduleDAGInstrs *DAG) override { return true ; }
880880
@@ -887,7 +887,7 @@ class MFMASmallGemmOpt final : public IGLPStrategy {
887887void MFMASmallGemmOpt::applyIGLPStrategy (
888888 DenseMap<int , SUnitsToCandidateSGsMap> &SyncedInstrs,
889889 DenseMap<int , SmallVector<SchedGroup, 4 >> &SyncedSchedGroups,
890- bool IsPostRA ) {
890+ bool IsReentry ) {
891891 // Count the number of MFMA instructions.
892892 unsigned MFMACount = 0 ;
893893 for (const MachineInstr &I : *DAG)
@@ -1050,8 +1050,8 @@ class MFMASmallGemmSingleWaveOpt final : public IGLPStrategy {
10501050 : InstructionRule(TII, SGID, NeedsCache) {}
10511051 };
10521052
1053- // Whether the SU shares a V_PERM predecessor with any SU in the SchedGroup
1054- // that is / p Distance steps away
1053+ // / Whether the SU shares a V_PERM predecessor with any SU in the SchedGroup
1054+ // / that is \ p Distance steps away
10551055 class SharesPredWithPrevNthGroup final : public InstructionRule {
10561056 private:
10571057 unsigned Distance = 1 ;
@@ -1106,7 +1106,7 @@ class MFMASmallGemmSingleWaveOpt final : public IGLPStrategy {
11061106 void applyIGLPStrategy (
11071107 DenseMap<int , SUnitsToCandidateSGsMap> &SyncedInstrs,
11081108 DenseMap<int , SmallVector<SchedGroup, 4 >> &SyncedSchedGroups,
1109- bool IsPostRA ) override ;
1109+ bool IsReentry ) override ;
11101110
11111111 bool shouldApplyStrategy (ScheduleDAGInstrs *DAG) override { return true ; }
11121112
@@ -1123,12 +1123,12 @@ static unsigned DSWWithSharedVMEMCount = 0;
11231123void MFMASmallGemmSingleWaveOpt::applyIGLPStrategy (
11241124 DenseMap<int , SUnitsToCandidateSGsMap> &SyncedInstrs,
11251125 DenseMap<int , SmallVector<SchedGroup, 4 >> &SyncedSchedGroups,
1126- bool IsPostRA ) {
1126+ bool IsReentry ) {
11271127 unsigned MFMACount = 0 ;
11281128 unsigned DSRCount = 0 ;
11291129
1130- assert ((IsPostRA || (DSWCount == 0 && DSWWithPermCount == 0 &&
1131- DSWWithSharedVMEMCount == 0 )) &&
1130+ assert ((IsReentry || (DSWCount == 0 && DSWWithPermCount == 0 &&
1131+ DSWWithSharedVMEMCount == 0 )) &&
11321132 " DSWCounters should be zero in pre-RA scheduling!" );
11331133 SmallVector<SUnit *, 6 > DSWithPerms;
11341134 for (auto &SU : DAG->SUnits ) {
@@ -1138,7 +1138,7 @@ void MFMASmallGemmSingleWaveOpt::applyIGLPStrategy(
11381138 else if (TII->isDS (*I)) {
11391139 if (I->mayLoad ())
11401140 ++DSRCount;
1141- else if (I->mayStore () && !IsPostRA ) {
1141+ else if (I->mayStore () && !IsReentry ) {
11421142 ++DSWCount;
11431143 for (auto Pred : SU.Preds ) {
11441144 if (Pred.getSUnit ()->getInstr ()->getOpcode () ==
@@ -1151,7 +1151,7 @@ void MFMASmallGemmSingleWaveOpt::applyIGLPStrategy(
11511151 }
11521152 }
11531153
1154- if (!IsPostRA ) {
1154+ if (!IsReentry ) {
11551155 DSWWithPermCount = DSWithPerms.size ();
11561156 auto I = DSWithPerms.begin ();
11571157 auto E = DSWithPerms.end ();
@@ -1418,11 +1418,11 @@ class IGroupLPDAGMutation : public ScheduleDAGMutation {
14181418 // first created SchedGroup first.
14191419 bool IsBottomUp = 1 ;
14201420
1421- // Whether the mutation is being applied to post RA scheduling
1422- bool IsPostRA = false ;
1421+ // Whether or not this is a reentry into the IGroupLPDAGMutation.
1422+ bool IsReentry = false ;
14231423
14241424 IGroupLPDAGMutation () = default ;
1425- IGroupLPDAGMutation (bool IsPostRA ) : IsPostRA(IsPostRA ) {}
1425+ IGroupLPDAGMutation (bool IsReentry ) : IsReentry(IsReentry ) {}
14261426};
14271427
14281428unsigned SchedGroup::NumSchedGroups = 0 ;
@@ -1710,16 +1710,21 @@ void IGroupLPDAGMutation::initIGLPOpt(SUnit &SU) {
17101710 auto S = createIGLPStrategy (StrategyID, DAG, TII);
17111711 if (S->shouldApplyStrategy (DAG)) {
17121712 IsBottomUp = S->IsBottomUp ;
1713- S->applyIGLPStrategy (SyncedInstrs, SyncedSchedGroups, IsPostRA );
1713+ S->applyIGLPStrategy (SyncedInstrs, SyncedSchedGroups, IsReentry );
17141714 }
17151715}
17161716
17171717} // namespace
17181718
17191719namespace llvm {
17201720
1721- std::unique_ptr<ScheduleDAGMutation> createIGroupLPDAGMutation (bool IsPostRA) {
1722- return std::make_unique<IGroupLPDAGMutation>(IsPostRA);
1721+ // / \p IsReentry specifes whether or not this is a reentry into the
1722+ // / IGroupLPDAGMutation. Since there may be multiple scheduling passes on the
1723+ // / same scheduling region (e.g. pre and post-RA scheduling / multiple
1724+ // / scheduling "phases"), we can reenter this mutation framework more than once
1725+ // / for a given region.
1726+ std::unique_ptr<ScheduleDAGMutation> createIGroupLPDAGMutation (bool IsReentry) {
1727+ return std::make_unique<IGroupLPDAGMutation>(IsReentry);
17231728}
17241729
17251730} // end namespace llvm
0 commit comments