Skip to content

Commit 72d3867

Browse files
committed
Change to builder callback
1 parent adabf4e commit 72d3867

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,14 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
506506
/// regalloc pass.
507507
void addRegAllocPass(AddMachinePass &, bool Optimized) const;
508508
/// Read the --regalloc-npm option to add the next pass in line.
509+
/// Returns false if no pass is left in the option.
509510
bool addRegAllocPassFromOpt(AddMachinePass &,
510511
StringRef MatchPassTo = StringRef{}) const;
511-
/// Add the next pass in the cli option, or return false if there is no pass
512+
/// Add the next pass in the cli option or the pass specified if no pass is
512513
/// left in the option.
513-
template <typename RegAllocPassT>
514-
void addRegAllocPassOrOpt(AddMachinePass &, RegAllocPassT Pass) const;
514+
template <typename RegAllocPassBuilderT>
515+
void addRegAllocPassOrOpt(AddMachinePass &,
516+
RegAllocPassBuilderT PassBuilder) const;
515517

516518
/// Add core register alloator passes which do the actual register assignment
517519
/// and rewriting. \returns true if any passes were added.
@@ -1111,11 +1113,11 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addTargetRegisterAllocator(
11111113
}
11121114

11131115
template <typename Derived, typename TargetMachineT>
1114-
template <typename RegAllocPassT>
1116+
template <typename RegAllocPassBuilderT>
11151117
void CodeGenPassBuilder<Derived, TargetMachineT>::addRegAllocPassOrOpt(
1116-
AddMachinePass &addPass, RegAllocPassT Pass) const {
1118+
AddMachinePass &addPass, RegAllocPassBuilderT PassBuilder) const {
11171119
if (!addRegAllocPassFromOpt(addPass))
1118-
addPass(std::move(Pass));
1120+
addPass(std::move(PassBuilder()));
11191121
}
11201122

11211123
template <typename Derived, typename TargetMachineT>

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,8 @@ Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
22122212
AddMachinePass &addPass) const {
22132213
addPass(GCNPreRALongBranchRegPass());
22142214

2215-
addRegAllocPassOrOpt(addPass, RAGreedyPass({onlyAllocateSGPRs, "sgpr"}));
2215+
addRegAllocPassOrOpt(
2216+
addPass, []() { return RAGreedyPass({onlyAllocateSGPRs, "sgpr"}); });
22162217

22172218
// Commit allocated register changes. This is mostly necessary because too
22182219
// many things rely on the use lists of the physical registers, such as the
@@ -2232,13 +2233,15 @@ Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
22322233
addPass(SIPreAllocateWWMRegsPass());
22332234

22342235
// For allocating other wwm register operands.
2235-
addRegAllocPassOrOpt(addPass, RAGreedyPass({onlyAllocateWWMRegs, "wwm"}));
2236+
addRegAllocPassOrOpt(
2237+
addPass, []() { return RAGreedyPass({onlyAllocateWWMRegs, "wwm"}); });
22362238
addPass(SILowerWWMCopiesPass());
22372239
addPass(VirtRegRewriterPass(false));
22382240
addPass(AMDGPUReserveWWMRegsPass());
22392241

22402242
// For allocating per-thread VGPRs.
2241-
addRegAllocPassOrOpt(addPass, RAGreedyPass({onlyAllocateVGPRs, "vgpr"}));
2243+
addRegAllocPassOrOpt(
2244+
addPass, []() { return RAGreedyPass({onlyAllocateVGPRs, "vgpr"}); });
22422245

22432246
// TODO: addPreRewrite();
22442247
addPass(VirtRegRewriterPass(false));

llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ class X86CodeGenPassBuilder
3939
Error X86CodeGenPassBuilder::addRegAssignmentOptimized(
4040
AddMachinePass &addPass) const {
4141
if (EnableTileRAPass) {
42-
addRegAllocPassOrOpt(addPass,
43-
RAGreedyPass({onlyAllocateTileRegisters, "tile-reg"}));
42+
addRegAllocPassOrOpt(addPass, []() {
43+
return RAGreedyPass({onlyAllocateTileRegisters, "tile-reg"});
44+
});
4445
// TODO: addPass(X86TileConfigPass());
4546
}
4647
return Base::addRegAssignmentOptimized(addPass);

0 commit comments

Comments
 (0)