https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/127984
>From 254dabf793e4c6e7cc8a3aedbd8e093b88c583fa Mon Sep 17 00:00:00 2001 From: Akshat Oke <akshat....@amd.com> Date: Tue, 18 Feb 2025 04:55:35 +0000 Subject: [PATCH] [RegAlloc][NPM] Make RegAllocFastPassOptions a nested class Making all reg alloc classes have an `::Option` class makes things nicer to construct them. --- llvm/include/llvm/CodeGen/RegAllocFast.h | 24 +++++++++++-------- .../llvm/Passes/MachinePassRegistry.def | 2 +- llvm/lib/Passes/PassBuilder.cpp | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/CodeGen/RegAllocFast.h b/llvm/include/llvm/CodeGen/RegAllocFast.h index b2ca9e10bf464..015b666400e05 100644 --- a/llvm/include/llvm/CodeGen/RegAllocFast.h +++ b/llvm/include/llvm/CodeGen/RegAllocFast.h @@ -9,23 +9,24 @@ #ifndef LLVM_CODEGEN_REGALLOCFAST_H #define LLVM_CODEGEN_REGALLOCFAST_H +#include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/MachinePassManager.h" #include "llvm/CodeGen/RegAllocCommon.h" namespace llvm { -struct RegAllocFastPassOptions { - RegAllocFilterFunc Filter = nullptr; - StringRef FilterName = "all"; - bool ClearVRegs = true; -}; - class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> { - RegAllocFastPassOptions Opts; - public: - RegAllocFastPass(RegAllocFastPassOptions Opts = RegAllocFastPassOptions()) - : Opts(Opts) {} + struct Options { + RegAllocFilterFunc Filter; + StringRef FilterName; + bool ClearVRegs; + Options(RegAllocFilterFunc F = nullptr, StringRef FN = "all", + bool CV = true) + : Filter(F), FilterName(FN), ClearVRegs(CV) {} + }; + + RegAllocFastPass(Options Opts = Options()) : Opts(Opts) {} MachineFunctionProperties getRequiredProperties() const { return MachineFunctionProperties().set( @@ -52,6 +53,9 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> { function_ref<StringRef(StringRef)> MapClassName2PassName); static bool isRequired() { return true; } + +private: + Options Opts; }; } // namespace llvm diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def index 373bd047e2395..8de02e951ba52 100644 --- a/llvm/include/llvm/Passes/MachinePassRegistry.def +++ b/llvm/include/llvm/Passes/MachinePassRegistry.def @@ -189,7 +189,7 @@ MACHINE_FUNCTION_PASS("verify<machine-trace-metrics>", MachineTraceMetricsVerifi #endif MACHINE_FUNCTION_PASS_WITH_PARAMS( "regallocfast", "RegAllocFastPass", - [](RegAllocFastPassOptions Opts) { return RegAllocFastPass(Opts); }, + [](RegAllocFastPass::Options Opts) { return RegAllocFastPass(Opts); }, [PB = this](StringRef Params) { return parseRegAllocFastPassOptions(*PB, Params); }, diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 5bb2e7d0abdd9..3a078985c33e4 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1332,9 +1332,9 @@ Expected<SmallVector<std::string, 0>> parseInternalizeGVs(StringRef Params) { return Expected<SmallVector<std::string, 0>>(std::move(PreservedGVs)); } -Expected<RegAllocFastPassOptions> +Expected<RegAllocFastPass::Options> parseRegAllocFastPassOptions(PassBuilder &PB, StringRef Params) { - RegAllocFastPassOptions Opts; + RegAllocFastPass::Options Opts; while (!Params.empty()) { StringRef ParamName; std::tie(ParamName, Params) = Params.split(';'); _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits