Skip to content

Commit fd718fa

Browse files
committed
[RegAlloc][NPM] Make RegAllocFastPassOptions a nested class
Making all reg alloc classes have an `::Option` class makes things nicer to construct them.
1 parent e0ecd0f commit fd718fa

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

llvm/include/llvm/CodeGen/RegAllocFast.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99
#ifndef LLVM_CODEGEN_REGALLOCFAST_H
1010
#define LLVM_CODEGEN_REGALLOCFAST_H
1111

12+
#include "llvm/ADT/StringRef.h"
1213
#include "llvm/CodeGen/MachinePassManager.h"
1314
#include "llvm/CodeGen/RegAllocCommon.h"
1415

1516
namespace llvm {
1617

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

3031
MachineFunctionProperties getRequiredProperties() const {
3132
return MachineFunctionProperties().set(
@@ -52,6 +53,9 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
5253
function_ref<StringRef(StringRef)> MapClassName2PassName);
5354

5455
static bool isRequired() { return true; }
56+
57+
private:
58+
Options Opts;
5559
};
5660

5761
} // 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
@@ -1333,9 +1333,9 @@ Expected<SmallVector<std::string, 0>> parseInternalizeGVs(StringRef Params) {
13331333
return Expected<SmallVector<std::string, 0>>(std::move(PreservedGVs));
13341334
}
13351335

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

0 commit comments

Comments
 (0)