@@ -2168,7 +2168,8 @@ Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
21682168
21692169 addPass (GCNPreRALongBranchRegPass ());
21702170
2171- addPass (RAGreedyPass ({onlyAllocateSGPRs, " sgpr" }));
2171+ addRegAllocPassOrOpt (
2172+ addPass, []() { return RAGreedyPass ({onlyAllocateSGPRs, " sgpr" }); });
21722173
21732174 // Commit allocated register changes. This is mostly necessary because too
21742175 // many things rely on the use lists of the physical registers, such as the
@@ -2188,21 +2189,20 @@ Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
21882189 addPass (SIPreAllocateWWMRegsPass ());
21892190
21902191 // For allocating other wwm register operands.
2191- // addRegAlloc<RAGreedyPass>(addPass, RegAllocPhase::WWM);
2192- addPass ( RAGreedyPass ({onlyAllocateWWMRegs, " wwm" }));
2192+ addRegAllocPassOrOpt (
2193+ addPass, []() { return RAGreedyPass ({onlyAllocateWWMRegs, " wwm" }); } );
21932194 addPass (SILowerWWMCopiesPass ());
21942195 addPass (VirtRegRewriterPass (false ));
21952196 addPass (AMDGPUReserveWWMRegsPass ());
21962197
21972198 // For allocating per-thread VGPRs.
2198- // addRegAlloc<RAGreedyPass>(addPass, RegAllocPhase::VGPR);
2199- addPass (RAGreedyPass ({onlyAllocateVGPRs, " vgpr" }));
2200-
2199+ addRegAllocPassOrOpt (
2200+ addPass, []() { return RAGreedyPass ({onlyAllocateVGPRs, " vgpr" }); });
22012201
22022202 addPreRewrite (addPass);
22032203 addPass (VirtRegRewriterPass (true ));
22042204
2205- // TODO: addPass(AMDGPUMarkLastScratchLoadPass());
2205+ addPass (AMDGPUMarkLastScratchLoadPass ());
22062206 return Error::success ();
22072207}
22082208
@@ -2252,47 +2252,6 @@ void AMDGPUCodeGenPassBuilder::addPreEmitPass(AddMachinePass &addPass) const {
22522252
22532253 addPass (BranchRelaxationPass ());
22542254}
2255- Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized (
2256- AddMachinePass &addPass) const {
2257- addPass (GCNPreRALongBranchRegPass ());
2258-
2259- addRegAllocPassOrOpt (
2260- addPass, []() { return RAGreedyPass ({onlyAllocateSGPRs, " sgpr" }); });
2261-
2262- // Commit allocated register changes. This is mostly necessary because too
2263- // many things rely on the use lists of the physical registers, such as the
2264- // verifier. This is only necessary with allocators which use LiveIntervals,
2265- // since FastRegAlloc does the replacements itself.
2266- // TODO: addPass(VirtRegRewriterPass(false));
2267-
2268- // At this point, the sgpr-regalloc has been done and it is good to have the
2269- // stack slot coloring to try to optimize the SGPR spill stack indices before
2270- // attempting the custom SGPR spill lowering.
2271- addPass (StackSlotColoringPass ());
2272-
2273- // Equivalent of PEI for SGPRs.
2274- addPass (SILowerSGPRSpillsPass ());
2275-
2276- // To Allocate wwm registers used in whole quad mode operations (for shaders).
2277- addPass (SIPreAllocateWWMRegsPass ());
2278-
2279- // For allocating other wwm register operands.
2280- addRegAllocPassOrOpt (
2281- addPass, []() { return RAGreedyPass ({onlyAllocateWWMRegs, " wwm" }); });
2282- addPass (SILowerWWMCopiesPass ());
2283- addPass (VirtRegRewriterPass (false ));
2284- addPass (AMDGPUReserveWWMRegsPass ());
2285-
2286- // For allocating per-thread VGPRs.
2287- addRegAllocPassOrOpt (
2288- addPass, []() { return RAGreedyPass ({onlyAllocateVGPRs, " vgpr" }); });
2289-
2290- // TODO: addPreRewrite();
2291- addPass (VirtRegRewriterPass (false ));
2292-
2293- // TODO: addPass(AMDGPUMarkLastScratchLoadPass());
2294- return Error::success ();
2295- }
22962255
22972256bool AMDGPUCodeGenPassBuilder::isPassEnabled (const cl::opt<bool > &Opt,
22982257 CodeGenOptLevel Level) const {
0 commit comments