[llvm] [CodeGen][NPM] Support generic regalloc-npm option (PR #135149)
Christudasan Devadasan via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 28 23:00:41 PDT 2025
================
@@ -2206,6 +2206,47 @@ void AMDGPUCodeGenPassBuilder::addPreEmitPass(AddMachinePass &addPass) const {
addPass(BranchRelaxationPass());
}
+Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
+ AddMachinePass &addPass) const {
+ addPass(GCNPreRALongBranchRegPass());
+
+ addRegAllocPassOrOpt(
+ addPass, []() { return RAGreedyPass({onlyAllocateSGPRs, "sgpr"}); });
+
+ // Commit allocated register changes. This is mostly necessary because too
+ // many things rely on the use lists of the physical registers, such as the
+ // verifier. This is only necessary with allocators which use LiveIntervals,
+ // since FastRegAlloc does the replacements itself.
+ // TODO: addPass(VirtRegRewriterPass(false));
+
+ // At this point, the sgpr-regalloc has been done and it is good to have the
+ // stack slot coloring to try to optimize the SGPR spill stack indices before
+ // attempting the custom SGPR spill lowering.
+ addPass(StackSlotColoringPass());
+
+ // Equivalent of PEI for SGPRs.
+ addPass(SILowerSGPRSpillsPass());
+
+ // To Allocate wwm registers used in whole quad mode operations (for shaders).
+ addPass(SIPreAllocateWWMRegsPass());
+
+ // For allocating other wwm register operands.
+ addRegAllocPassOrOpt(
+ addPass, []() { return RAGreedyPass({onlyAllocateWWMRegs, "wwm"}); });
+ addPass(SILowerWWMCopiesPass());
+ addPass(VirtRegRewriterPass(false));
+ addPass(AMDGPUReserveWWMRegsPass());
+
+ // For allocating per-thread VGPRs.
+ addRegAllocPassOrOpt(
+ addPass, []() { return RAGreedyPass({onlyAllocateVGPRs, "vgpr"}); });
+
+ // TODO: addPreRewrite();
----------------
cdevadas wrote:
Enable this.
https://github.com/llvm/llvm-project/pull/135149
More information about the llvm-commits
mailing list