Skip to content

Commit 3ead04f

Browse files
committed
Change to builder callback
1 parent b50f3c6 commit 3ead04f

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
@@ -510,12 +510,14 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
510510
/// regalloc pass.
511511
void addRegAllocPass(AddMachinePass &, bool Optimized) const;
512512
/// Read the --regalloc-npm option to add the next pass in line.
513+
/// Returns false if no pass is left in the option.
513514
bool addRegAllocPassFromOpt(AddMachinePass &,
514515
StringRef MatchPassTo = StringRef{}) const;
515-
/// Add the next pass in the cli option, or return false if there is no pass
516+
/// Add the next pass in the cli option or the pass specified if no pass is
516517
/// left in the option.
517-
template <typename RegAllocPassT>
518-
void addRegAllocPassOrOpt(AddMachinePass &, RegAllocPassT Pass) const;
518+
template <typename RegAllocPassBuilderT>
519+
void addRegAllocPassOrOpt(AddMachinePass &,
520+
RegAllocPassBuilderT PassBuilder) const;
519521

520522
/// Add core register alloator passes which do the actual register assignment
521523
/// and rewriting. \returns true if any passes were added.
@@ -1115,11 +1117,11 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addTargetRegisterAllocator(
11151117
}
11161118

11171119
template <typename Derived, typename TargetMachineT>
1118-
template <typename RegAllocPassT>
1120+
template <typename RegAllocPassBuilderT>
11191121
void CodeGenPassBuilder<Derived, TargetMachineT>::addRegAllocPassOrOpt(
1120-
AddMachinePass &addPass, RegAllocPassT Pass) const {
1122+
AddMachinePass &addPass, RegAllocPassBuilderT PassBuilder) const {
11211123
if (!addRegAllocPassFromOpt(addPass))
1122-
addPass(std::move(Pass));
1124+
addPass(std::move(PassBuilder()));
11231125
}
11241126

11251127
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
@@ -2256,7 +2256,8 @@ Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
22562256
AddMachinePass &addPass) const {
22572257
addPass(GCNPreRALongBranchRegPass());
22582258

2259-
addRegAllocPassOrOpt(addPass, RAGreedyPass({onlyAllocateSGPRs, "sgpr"}));
2259+
addRegAllocPassOrOpt(
2260+
addPass, []() { return RAGreedyPass({onlyAllocateSGPRs, "sgpr"}); });
22602261

22612262
// Commit allocated register changes. This is mostly necessary because too
22622263
// many things rely on the use lists of the physical registers, such as the
@@ -2276,13 +2277,15 @@ Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
22762277
addPass(SIPreAllocateWWMRegsPass());
22772278

22782279
// For allocating other wwm register operands.
2279-
addRegAllocPassOrOpt(addPass, RAGreedyPass({onlyAllocateWWMRegs, "wwm"}));
2280+
addRegAllocPassOrOpt(
2281+
addPass, []() { return RAGreedyPass({onlyAllocateWWMRegs, "wwm"}); });
22802282
addPass(SILowerWWMCopiesPass());
22812283
addPass(VirtRegRewriterPass(false));
22822284
addPass(AMDGPUReserveWWMRegsPass());
22832285

22842286
// For allocating per-thread VGPRs.
2285-
addRegAllocPassOrOpt(addPass, RAGreedyPass({onlyAllocateVGPRs, "vgpr"}));
2287+
addRegAllocPassOrOpt(
2288+
addPass, []() { return RAGreedyPass({onlyAllocateVGPRs, "vgpr"}); });
22862289

22872290
// TODO: addPreRewrite();
22882291
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)