14
14
// distrance threshold tuning of what is considered "long" is handled through
15
15
// amdgpu-long-branch-factor cl argument which sets LongBranchFactor.
16
16
// ===----------------------------------------------------------------------===//
17
+ #include " GCNPreRALongBranchReg.h"
17
18
#include " AMDGPU.h"
18
19
#include " GCNSubtarget.h"
19
20
#include " SIMachineFunctionInfo.h"
@@ -36,7 +37,7 @@ static cl::opt<double> LongBranchFactor(
36
37
" reserved. We lean towards always reserving a register for "
37
38
" long jumps" ));
38
39
39
- class GCNPreRALongBranchReg : public MachineFunctionPass {
40
+ class GCNPreRALongBranchReg {
40
41
41
42
struct BasicBlockInfo {
42
43
// Offset - Distance from the beginning of the function to the beginning
@@ -48,27 +49,39 @@ class GCNPreRALongBranchReg : public MachineFunctionPass {
48
49
void generateBlockInfo (MachineFunction &MF,
49
50
SmallVectorImpl<BasicBlockInfo> &BlockInfo);
50
51
52
+ public:
53
+ GCNPreRALongBranchReg () = default ;
54
+ bool run (MachineFunction &MF);
55
+ };
56
+
57
+ class GCNPreRALongBranchRegLegacy : public MachineFunctionPass {
51
58
public:
52
59
static char ID;
53
- GCNPreRALongBranchReg () : MachineFunctionPass(ID) {
54
- initializeGCNPreRALongBranchRegPass (*PassRegistry::getPassRegistry ());
60
+ GCNPreRALongBranchRegLegacy () : MachineFunctionPass(ID) {
61
+ initializeGCNPreRALongBranchRegLegacyPass (*PassRegistry::getPassRegistry ());
55
62
}
56
- bool runOnMachineFunction (MachineFunction &MF) override ;
63
+
64
+ bool runOnMachineFunction (MachineFunction &MF) override {
65
+ return GCNPreRALongBranchReg ().run (MF);
66
+ }
67
+
57
68
StringRef getPassName () const override {
58
69
return " AMDGPU Pre-RA Long Branch Reg" ;
59
70
}
71
+
60
72
void getAnalysisUsage (AnalysisUsage &AU) const override {
61
73
AU.setPreservesAll ();
62
74
MachineFunctionPass::getAnalysisUsage (AU);
63
75
}
64
76
};
65
77
} // End anonymous namespace.
66
- char GCNPreRALongBranchReg::ID = 0 ;
67
78
68
- INITIALIZE_PASS (GCNPreRALongBranchReg, DEBUG_TYPE,
79
+ char GCNPreRALongBranchRegLegacy::ID = 0 ;
80
+
81
+ INITIALIZE_PASS (GCNPreRALongBranchRegLegacy, DEBUG_TYPE,
69
82
" AMDGPU Pre-RA Long Branch Reg" , false , false )
70
83
71
- char &llvm::GCNPreRALongBranchRegID = GCNPreRALongBranchReg ::ID;
84
+ char &llvm::GCNPreRALongBranchRegID = GCNPreRALongBranchRegLegacy ::ID;
72
85
void GCNPreRALongBranchReg::generateBlockInfo (
73
86
MachineFunction &MF, SmallVectorImpl<BasicBlockInfo> &BlockInfo) {
74
87
@@ -99,7 +112,8 @@ void GCNPreRALongBranchReg::generateBlockInfo(
99
112
PrevNum = Num;
100
113
}
101
114
}
102
- bool GCNPreRALongBranchReg::runOnMachineFunction (MachineFunction &MF) {
115
+
116
+ bool GCNPreRALongBranchReg::run (MachineFunction &MF) {
103
117
const GCNSubtarget &STM = MF.getSubtarget <GCNSubtarget>();
104
118
const SIInstrInfo *TII = STM.getInstrInfo ();
105
119
const SIRegisterInfo *TRI = STM.getRegisterInfo ();
@@ -136,3 +150,10 @@ bool GCNPreRALongBranchReg::runOnMachineFunction(MachineFunction &MF) {
136
150
}
137
151
return false ;
138
152
}
153
+
154
+ PreservedAnalyses
155
+ GCNPreRALongBranchRegPass::run (MachineFunction &MF,
156
+ MachineFunctionAnalysisManager &MFAM) {
157
+ GCNPreRALongBranchReg ().run (MF);
158
+ return PreservedAnalyses::all ();
159
+ }
0 commit comments