-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
optimisan
merged 2 commits into
llvm:main
from
optimisan:users/Akshat-Oke/fast-ra-options
Feb 21, 2025
Merged
[RegAllocFast][NPM] Make RegAllocFastPassOptions a nested class #127984
optimisan
merged 2 commits into
llvm:main
from
optimisan:users/Akshat-Oke/fast-ra-options
Feb 21, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arsenm
approved these changes
Feb 20, 2025
@llvm/pr-subscribers-llvm-regalloc Author: Akshat Oke (optimisan) ChangesMaking all reg alloc classes have an Full diff: https://github.com/llvm/llvm-project/pull/127984.diff 3 Files Affected:
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 bb1a59a9c4ed3..31f260c560dd6 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 4e21ef0704e5d..614cbe85ff2bd 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -1333,9 +1333,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(';');
|
Making all reg alloc classes have an `::Option` class makes things nicer to construct them.
fd718fa
to
254dabf
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Making all reg alloc classes have an
::Option
class makes things nicer to construct them.