Skip to content

[RegAllocFast][NPM] Make RegAllocFastPassOptions a nested class #127984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions llvm/include/llvm/CodeGen/RegAllocFast.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@

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(
Expand All @@ -52,6 +52,9 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
function_ref<StringRef(StringRef)> MapClassName2PassName);

static bool isRequired() { return true; }

private:
Options Opts;
};

} // namespace llvm
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Passes/MachinePassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(';');
Expand Down
Loading