@@ -25,18 +25,26 @@ using namespace llvm;
25
25
26
26
namespace {
27
27
28
- class AMDGPUMarkLastScratchLoad : public MachineFunctionPass {
28
+ class AMDGPUMarkLastScratchLoad {
29
29
private:
30
30
LiveStacks *LS = nullptr ;
31
31
LiveIntervals *LIS = nullptr ;
32
32
SlotIndexes *SI = nullptr ;
33
33
const SIInstrInfo *SII = nullptr ;
34
34
35
+ public:
36
+ AMDGPUMarkLastScratchLoad (LiveStacks *LS, LiveIntervals *LIS, SlotIndexes *SI)
37
+ : LS(LS), LIS(LIS), SI(SI) {}
38
+ bool run (MachineFunction &MF);
39
+ };
40
+
41
+ class AMDGPUMarkLastScratchLoadLegacy : public MachineFunctionPass {
35
42
public:
36
43
static char ID;
37
44
38
- AMDGPUMarkLastScratchLoad () : MachineFunctionPass(ID) {
39
- initializeAMDGPUMarkLastScratchLoadPass (*PassRegistry::getPassRegistry ());
45
+ AMDGPUMarkLastScratchLoadLegacy () : MachineFunctionPass(ID) {
46
+ initializeAMDGPUMarkLastScratchLoadLegacyPass (
47
+ *PassRegistry::getPassRegistry ());
40
48
}
41
49
42
50
bool runOnMachineFunction (MachineFunction &MF) override ;
@@ -56,17 +64,34 @@ class AMDGPUMarkLastScratchLoad : public MachineFunctionPass {
56
64
57
65
} // end anonymous namespace
58
66
59
- bool AMDGPUMarkLastScratchLoad::runOnMachineFunction (MachineFunction &MF) {
67
+ bool AMDGPUMarkLastScratchLoadLegacy::runOnMachineFunction (
68
+ MachineFunction &MF) {
60
69
if (skipFunction (MF.getFunction ()))
61
70
return false ;
62
71
72
+ auto &LS = getAnalysis<LiveStacksWrapperLegacy>().getLS ();
73
+ auto &LIS = getAnalysis<LiveIntervalsWrapperPass>().getLIS ();
74
+ auto &SI = getAnalysis<SlotIndexesWrapperPass>().getSI ();
75
+
76
+ return AMDGPUMarkLastScratchLoad (&LS, &LIS, &SI).run (MF);
77
+ }
78
+
79
+ PreservedAnalyses
80
+ AMDGPUMarkLastScratchLoadPass::run (MachineFunction &MF,
81
+ MachineFunctionAnalysisManager &MFAM) {
82
+ auto &LS = MFAM.getResult <LiveStacksAnalysis>(MF);
83
+ auto &LIS = MFAM.getResult <LiveIntervalsAnalysis>(MF);
84
+ auto &SI = MFAM.getResult <SlotIndexesAnalysis>(MF);
85
+
86
+ AMDGPUMarkLastScratchLoad (&LS, &LIS, &SI).run (MF);
87
+ return PreservedAnalyses::all ();
88
+ }
89
+
90
+ bool AMDGPUMarkLastScratchLoad::run (MachineFunction &MF) {
63
91
const GCNSubtarget &ST = MF.getSubtarget <GCNSubtarget>();
64
92
if (ST.getGeneration () < AMDGPUSubtarget::GFX12)
65
93
return false ;
66
94
67
- LS = &getAnalysis<LiveStacksWrapperLegacy>().getLS ();
68
- LIS = &getAnalysis<LiveIntervalsWrapperPass>().getLIS ();
69
- SI = &getAnalysis<SlotIndexesWrapperPass>().getSI ();
70
95
SII = ST.getInstrInfo ();
71
96
SlotIndexes &Slots = *LIS->getSlotIndexes ();
72
97
@@ -130,13 +155,13 @@ bool AMDGPUMarkLastScratchLoad::runOnMachineFunction(MachineFunction &MF) {
130
155
return Changed;
131
156
}
132
157
133
- char AMDGPUMarkLastScratchLoad ::ID = 0 ;
158
+ char AMDGPUMarkLastScratchLoadLegacy ::ID = 0 ;
134
159
135
- char &llvm::AMDGPUMarkLastScratchLoadID = AMDGPUMarkLastScratchLoad ::ID;
160
+ char &llvm::AMDGPUMarkLastScratchLoadID = AMDGPUMarkLastScratchLoadLegacy ::ID;
136
161
137
- INITIALIZE_PASS_BEGIN (AMDGPUMarkLastScratchLoad , DEBUG_TYPE,
162
+ INITIALIZE_PASS_BEGIN (AMDGPUMarkLastScratchLoadLegacy , DEBUG_TYPE,
138
163
" AMDGPU Mark last scratch load" , false , false )
139
164
INITIALIZE_PASS_DEPENDENCY(SlotIndexesWrapperPass)
140
165
INITIALIZE_PASS_DEPENDENCY(LiveStacksWrapperLegacy)
141
- INITIALIZE_PASS_END(AMDGPUMarkLastScratchLoad , DEBUG_TYPE,
166
+ INITIALIZE_PASS_END(AMDGPUMarkLastScratchLoadLegacy , DEBUG_TYPE,
142
167
" AMDGPU Mark last scratch load" , false , false )
0 commit comments