|
36 | 36 | #include "MCTargetDesc/AMDGPUMCTargetDesc.h" |
37 | 37 | #include "llvm/ADT/SmallVector.h" |
38 | 38 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 39 | +#include "llvm/CodeGen/MachinePassManager.h" |
39 | 40 |
|
40 | 41 | using namespace llvm; |
41 | 42 |
|
@@ -89,18 +90,10 @@ enum HardClauseType { |
89 | 90 | HARDCLAUSE_ILLEGAL, |
90 | 91 | }; |
91 | 92 |
|
92 | | -class SIInsertHardClauses : public MachineFunctionPass { |
| 93 | +class SIInsertHardClauses { |
93 | 94 | public: |
94 | | - static char ID; |
95 | 95 | const GCNSubtarget *ST = nullptr; |
96 | 96 |
|
97 | | - SIInsertHardClauses() : MachineFunctionPass(ID) {} |
98 | | - |
99 | | - void getAnalysisUsage(AnalysisUsage &AU) const override { |
100 | | - AU.setPreservesCFG(); |
101 | | - MachineFunctionPass::getAnalysisUsage(AU); |
102 | | - } |
103 | | - |
104 | 97 | HardClauseType getHardClauseType(const MachineInstr &MI) { |
105 | 98 | if (MI.mayLoad() || (MI.mayStore() && ST->shouldClusterStores())) { |
106 | 99 | if (ST->getGeneration() == AMDGPUSubtarget::GFX10) { |
@@ -189,9 +182,7 @@ class SIInsertHardClauses : public MachineFunctionPass { |
189 | 182 | return true; |
190 | 183 | } |
191 | 184 |
|
192 | | - bool runOnMachineFunction(MachineFunction &MF) override { |
193 | | - if (skipFunction(MF.getFunction())) |
194 | | - return false; |
| 185 | + bool run(MachineFunction &MF) { |
195 | 186 |
|
196 | 187 | ST = &MF.getSubtarget<GCNSubtarget>(); |
197 | 188 | if (!ST->hasHardClauses()) |
@@ -265,11 +256,40 @@ class SIInsertHardClauses : public MachineFunctionPass { |
265 | 256 | } |
266 | 257 | }; |
267 | 258 |
|
| 259 | +class SIInsertHardClausesLegacy : public MachineFunctionPass { |
| 260 | +public: |
| 261 | + static char ID; |
| 262 | + SIInsertHardClausesLegacy() : MachineFunctionPass(ID) {} |
| 263 | + |
| 264 | + bool runOnMachineFunction(MachineFunction &MF) override { |
| 265 | + if (skipFunction(MF.getFunction())) |
| 266 | + return false; |
| 267 | + |
| 268 | + return SIInsertHardClauses().run(MF); |
| 269 | + } |
| 270 | + |
| 271 | + void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 272 | + AU.setPreservesCFG(); |
| 273 | + MachineFunctionPass::getAnalysisUsage(AU); |
| 274 | + } |
| 275 | +}; |
| 276 | + |
268 | 277 | } // namespace |
269 | 278 |
|
270 | | -char SIInsertHardClauses::ID = 0; |
| 279 | +PreservedAnalyses |
| 280 | +llvm::SIInsertHardClausesPass::run(MachineFunction &MF, |
| 281 | + MachineFunctionAnalysisManager &MFAM) { |
| 282 | + if (!SIInsertHardClauses().run(MF)) |
| 283 | + return PreservedAnalyses::all(); |
| 284 | + |
| 285 | + auto PA = getMachineFunctionPassPreservedAnalyses(); |
| 286 | + PA.preserveSet<CFGAnalyses>(); |
| 287 | + return PA; |
| 288 | +} |
| 289 | + |
| 290 | +char SIInsertHardClausesLegacy::ID = 0; |
271 | 291 |
|
272 | | -char &llvm::SIInsertHardClausesID = SIInsertHardClauses::ID; |
| 292 | +char &llvm::SIInsertHardClausesID = SIInsertHardClausesLegacy::ID; |
273 | 293 |
|
274 | | -INITIALIZE_PASS(SIInsertHardClauses, DEBUG_TYPE, "SI Insert Hard Clauses", |
| 294 | +INITIALIZE_PASS(SIInsertHardClausesLegacy, DEBUG_TYPE, "SI Insert Hard Clauses", |
275 | 295 | false, false) |
0 commit comments