Skip to content

Commit 36d304d

Browse files
authored
[RegAllocFast][NPM] Make RegAllocFastPassOptions a nested class (#127984)
Making all reg alloc classes have an `::Option` class makes things nicer to construct them.
1 parent 6c90f87 commit 36d304d

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

llvm/include/llvm/CodeGen/RegAllocFast.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414

1515
namespace llvm {
1616

17-
struct RegAllocFastPassOptions {
18-
RegAllocFilterFunc Filter = nullptr;
19-
StringRef FilterName = "all";
20-
bool ClearVRegs = true;
21-
};
22-
2317
class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
24-
RegAllocFastPassOptions Opts;
25-
2618
public:
27-
RegAllocFastPass(RegAllocFastPassOptions Opts = RegAllocFastPassOptions())
28-
: Opts(Opts) {}
19+
struct Options {
20+
RegAllocFilterFunc Filter;
21+
StringRef FilterName;
22+
bool ClearVRegs;
23+
Options(RegAllocFilterFunc F = nullptr, StringRef FN = "all",
24+
bool CV = true)
25+
: Filter(F), FilterName(FN), ClearVRegs(CV) {}
26+
};
27+
28+
RegAllocFastPass(Options Opts = Options()) : Opts(Opts) {}
2929

3030
MachineFunctionProperties getRequiredProperties() const {
3131
return MachineFunctionProperties().set(
@@ -52,6 +52,9 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
5252
function_ref<StringRef(StringRef)> MapClassName2PassName);
5353

5454
static bool isRequired() { return true; }
55+
56+
private:
57+
Options Opts;
5558
};
5659

5760
} // namespace llvm

llvm/include/llvm/Passes/MachinePassRegistry.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ MACHINE_FUNCTION_PASS("verify<machine-trace-metrics>", MachineTraceMetricsVerifi
189189
#endif
190190
MACHINE_FUNCTION_PASS_WITH_PARAMS(
191191
"regallocfast", "RegAllocFastPass",
192-
[](RegAllocFastPassOptions Opts) { return RegAllocFastPass(Opts); },
192+
[](RegAllocFastPass::Options Opts) { return RegAllocFastPass(Opts); },
193193
[PB = this](StringRef Params) {
194194
return parseRegAllocFastPassOptions(*PB, Params);
195195
},

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,9 @@ Expected<SmallVector<std::string, 0>> parseInternalizeGVs(StringRef Params) {
13321332
return Expected<SmallVector<std::string, 0>>(std::move(PreservedGVs));
13331333
}
13341334

1335-
Expected<RegAllocFastPassOptions>
1335+
Expected<RegAllocFastPass::Options>
13361336
parseRegAllocFastPassOptions(PassBuilder &PB, StringRef Params) {
1337-
RegAllocFastPassOptions Opts;
1337+
RegAllocFastPass::Options Opts;
13381338
while (!Params.empty()) {
13391339
StringRef ParamName;
13401340
std::tie(ParamName, Params) = Params.split(';');

0 commit comments

Comments
 (0)