1414// distrance threshold tuning of what is considered "long" is handled through
1515// amdgpu-long-branch-factor cl argument which sets LongBranchFactor.
1616// ===----------------------------------------------------------------------===//
17+ #include " GCNPreRALongBranchReg.h"
1718#include " AMDGPU.h"
1819#include " GCNSubtarget.h"
1920#include " SIMachineFunctionInfo.h"
@@ -36,7 +37,7 @@ static cl::opt<double> LongBranchFactor(
3637 " reserved. We lean towards always reserving a register for "
3738 " long jumps" ));
3839
39- class GCNPreRALongBranchReg : public MachineFunctionPass {
40+ class GCNPreRALongBranchReg {
4041
4142 struct BasicBlockInfo {
4243 // Offset - Distance from the beginning of the function to the beginning
@@ -48,27 +49,39 @@ class GCNPreRALongBranchReg : public MachineFunctionPass {
4849 void generateBlockInfo (MachineFunction &MF,
4950 SmallVectorImpl<BasicBlockInfo> &BlockInfo);
5051
52+ public:
53+ GCNPreRALongBranchReg () = default ;
54+ bool run (MachineFunction &MF);
55+ };
56+
57+ class GCNPreRALongBranchRegLegacy : public MachineFunctionPass {
5158public:
5259 static char ID;
53- GCNPreRALongBranchReg () : MachineFunctionPass(ID) {
54- initializeGCNPreRALongBranchRegPass (*PassRegistry::getPassRegistry ());
60+ GCNPreRALongBranchRegLegacy () : MachineFunctionPass(ID) {
61+ initializeGCNPreRALongBranchRegLegacyPass (*PassRegistry::getPassRegistry ());
5562 }
56- bool runOnMachineFunction (MachineFunction &MF) override ;
63+
64+ bool runOnMachineFunction (MachineFunction &MF) override {
65+ return GCNPreRALongBranchReg ().run (MF);
66+ }
67+
5768 StringRef getPassName () const override {
5869 return " AMDGPU Pre-RA Long Branch Reg" ;
5970 }
71+
6072 void getAnalysisUsage (AnalysisUsage &AU) const override {
6173 AU.setPreservesAll ();
6274 MachineFunctionPass::getAnalysisUsage (AU);
6375 }
6476};
6577} // End anonymous namespace.
66- char GCNPreRALongBranchReg::ID = 0 ;
6778
68- INITIALIZE_PASS (GCNPreRALongBranchReg, DEBUG_TYPE,
79+ char GCNPreRALongBranchRegLegacy::ID = 0 ;
80+
81+ INITIALIZE_PASS (GCNPreRALongBranchRegLegacy, DEBUG_TYPE,
6982 " AMDGPU Pre-RA Long Branch Reg" , false , false )
7083
71- char &llvm::GCNPreRALongBranchRegID = GCNPreRALongBranchReg ::ID;
84+ char &llvm::GCNPreRALongBranchRegID = GCNPreRALongBranchRegLegacy ::ID;
7285void GCNPreRALongBranchReg::generateBlockInfo (
7386 MachineFunction &MF, SmallVectorImpl<BasicBlockInfo> &BlockInfo) {
7487
@@ -99,7 +112,8 @@ void GCNPreRALongBranchReg::generateBlockInfo(
99112 PrevNum = Num;
100113 }
101114}
102- bool GCNPreRALongBranchReg::runOnMachineFunction (MachineFunction &MF) {
115+
116+ bool GCNPreRALongBranchReg::run (MachineFunction &MF) {
103117 const GCNSubtarget &STM = MF.getSubtarget <GCNSubtarget>();
104118 const SIInstrInfo *TII = STM.getInstrInfo ();
105119 const SIRegisterInfo *TRI = STM.getRegisterInfo ();
@@ -136,3 +150,10 @@ bool GCNPreRALongBranchReg::runOnMachineFunction(MachineFunction &MF) {
136150 }
137151 return false ;
138152}
153+
154+ PreservedAnalyses
155+ GCNPreRALongBranchRegPass::run (MachineFunction &MF,
156+ MachineFunctionAnalysisManager &MFAM) {
157+ GCNPreRALongBranchReg ().run (MF);
158+ return PreservedAnalyses::all ();
159+ }
0 commit comments