Skip to content

Commit 93d1bf7

Browse files
committed
add test
1 parent 4f727bc commit 93d1bf7

File tree

3 files changed

+7
-108
lines changed

3 files changed

+7
-108
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 2 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,97 +2165,6 @@ static const char NPMRegAllocOptNotSupportedMessage[] =
21652165
"-wwm-regalloc-npm, "
21662166
"and -vgpr-regalloc-npm";
21672167

2168-
// void AMDGPUCodeGenPassBuilder::addSGPRRegAlloc(AddMachinePass &addPass,
2169-
// RegAllocType RAType, RegAllocFilterFunc FilterFunc, bool Optimized) const {
2170-
// RegAllocType RAType = RegAllocTypeNPM;
2171-
// if (RAType == RegAllocType::Default) {
2172-
// RAType = Optimized ? RegAllocType::Greedy : RegAllocType::Fast;
2173-
// }
2174-
2175-
// if (RAType == RegAllocType::Greedy) {
2176-
// addPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}));
2177-
// return;
2178-
// }
2179-
2180-
// if (RAType == RegAllocType::Fast) {
2181-
// addPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}));
2182-
// return;
2183-
// }
2184-
// report_fatal_error("Unsupported SGPR regalloc type", false);
2185-
// }
2186-
2187-
// template<typename RegAllocPass>
2188-
// void AMDGPUCodeGenPassBuilder::addRegAllocOfType(AddMachinePass &addPass,
2189-
// RegAllocPass::Options Options) {
2190-
// addPass(RegAllocPass(Options));
2191-
// }
2192-
2193-
// this is the final method
2194-
// template<typename RegAllocPass>
2195-
// void AMDGPUCodeGenPassBuilder::addRegAllocOfType(AddMachinePass &addPass,
2196-
// RegAllocPhase Phase) {
2197-
// #define RA_OPTIONS(FilterFunc, Name, ClearVirtRegs) \
2198-
// [&]() { \
2199-
// if constexpr (std::is_same_v<RegAllocPass, RegAllocFastPass>) { \
2200-
// return RegAllocFastPass::Options{FilterFunc, Name, ClearVirtRegs}; \
2201-
// } else { \
2202-
// return typename RegAllocPass::Options{FilterFunc, Name}; \
2203-
// } \
2204-
// }()
2205-
2206-
// typename RegAllocPass::Options Options;
2207-
// RegAllocType RAType;
2208-
2209-
// switch (Phase) {
2210-
// case RegAllocPhase::SGPR:
2211-
// Options = RA_OPTIONS(onlyAllocateSGPRs, "sgpr", false);
2212-
// RAType = SGPRRegAllocTypeNPM;
2213-
// break;
2214-
// case RegAllocPhase::WWM:
2215-
// Options = RA_OPTIONS(onlyAllocateWWMRegs, "wwm", false);
2216-
// RAType = WWMRegAllocTypeNPM;
2217-
// break;
2218-
// case RegAllocPhase::VGPR:
2219-
// Options = RA_OPTIONS(onlyAllocateVGPRs, "vgpr", true);
2220-
// RAType = VGPRRegAllocTypeNPM;
2221-
// break;
2222-
// };
2223-
2224-
// switch(RAType) {
2225-
// case RegAllocType::Greedy:
2226-
// addPass(RAGreedyPass(Options));
2227-
// return;
2228-
// case RegAllocType::Fast:
2229-
// addPass(RegAllocFastPass(Options));
2230-
// return;
2231-
// case RegAllocType::Unset:
2232-
// addPass(RegAllocPass(Options));
2233-
// }
2234-
// #undef RA_OPTIONS
2235-
// }
2236-
2237-
// template<typename RegAllocPass>
2238-
// void AMDGPUCodeGenPassBuilder::addRegAlloc(AddMachinePass &addPass,
2239-
// RegAllocPhase Phase) {
2240-
// RegAllocType RAType;
2241-
// switch(Phase) {
2242-
// case RegAllocPhase::SGPR:
2243-
// RAType = SGPRRegAllocTypeNPM;
2244-
// break;
2245-
// case RegAllocPhase::WWM:
2246-
// RAType = WWMRegAllocTypeNPM;
2247-
// break;
2248-
// case RegAllocPhase::VGPR:
2249-
// RAType = VGPRRegAllocTypeNPM;
2250-
// break;
2251-
// }
2252-
// switch (RAType) {
2253-
// case RegAllocType::Greedy:
2254-
// addRegAllocOfType(addPass, Phase);
2255-
// }
2256-
// addRegAllocOfType<RegAllocPass>(addPass, Phase);
2257-
// }
2258-
22592168
template <typename RegAllocPassT>
22602169
typename RegAllocPassT::Options
22612170
AMDGPUCodeGenPassBuilder::getRAOptionsForPhase(RegAllocPhase Phase) const {
@@ -2276,18 +2185,6 @@ AMDGPUCodeGenPassBuilder::getRAOptionsForPhase(RegAllocPhase Phase) const {
22762185
case RegAllocPhase::VGPR:
22772186
return RA_OPTIONS(onlyAllocateVGPRs, "vgpr", true);
22782187
}
2279-
// static_assert(std::is_same_v<PhaseT, SGPRPhase> ||
2280-
// std::is_same_v<PhaseT, WWMPhase> ||
2281-
// std::is_same_v<PhaseT, VGPRPhase>,
2282-
// "Unsupported phase type");
2283-
2284-
// if constexpr(std::is_same_v<PhaseT, SGPRPhase>) {
2285-
// return RA_OPTIONS(onlyAllocateSGPRs, "sgpr", false);
2286-
// } else if constexpr(std::is_same_v<PhaseT, WWMPhase>) {
2287-
// return RA_OPTIONS(onlyAllocateWWMRegs, "wwm", false);
2288-
// } else if constexpr(std::is_same_v<PhaseT, VGPRPhase>) {
2289-
// return RA_OPTIONS(onlyAllocateVGPRs, "vgpr", true);
2290-
// }
22912188

22922189
#undef RA_OPTIONS
22932190
}
@@ -2318,10 +2215,11 @@ void AMDGPUCodeGenPassBuilder::addRegAlloc(AddMachinePass &addPass,
23182215
addPass(RegAllocFastPass(getRAOptionsForPhase<RegAllocFastPass>(Phase)));
23192216
return;
23202217
case RegAllocType::Unset:
2218+
case RegAllocType::Default:
23212219
addPass(RegAllocPassT(getRAOptionsForPhase<RegAllocPassT>(Phase)));
23222220
return;
23232221
default:
2324-
report_fatal_error("Unsupported regalloc type", false);
2222+
report_fatal_error("Unsupported regalloc type for AMDGPU", false);
23252223
}
23262224
}
23272225

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ class AMDGPUCodeGenPassBuilder
194194
void addStraightLineScalarOptimizationPasses(AddIRPass &) const;
195195

196196
private:
197-
// /// Dummy structs to represent different phases of register allocation.
198-
// struct SGPRPhase{};
199-
// struct VGPRPhase{};
200-
// struct WWMPhase{};
201197
enum class RegAllocPhase { SGPR, VGPR, WWM };
202198

203199
template <typename RegAllocPassT>

llvm/test/tools/llc/new-pm/regalloc-amdgpu.mir

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
# RUN: llc -mtriple=amdgcn --passes='regallocfast<filter=sgpr>,regallocfast<filter=wwm>,regallocfast<filter=vgpr>' --print-pipeline-passes --filetype=null %s | FileCheck %s --check-prefix=PASS
33
# RUN: not llc -mtriple=amdgcn --passes='regallocfast<filter=bad-filter>' --print-pipeline-passes --filetype=null %s 2>&1 | FileCheck %s --check-prefix=BAD-FILTER
44

5+
# RUN: llc -mtriple=amdgcn -enable-new-pm -sgpr-regalloc-npm=greedy -vgpr-regalloc-npm=fast -print-pipeline-passes %s | FileCheck %s --check-prefix=NPM-PASS
6+
7+
58
# PASS: regallocfast<filter=sgpr>
69
# PASS: regallocfast<filter=wwm>
710
# PASS: regallocfast<filter=vgpr>
811
# BAD-FILTER: invalid regallocfast register filter 'bad-filter'
912

13+
# NPM-PASS: greedy<sgpr>
14+
# NPM-PASS: regallocfast<filter=vgpr>
1015
---
1116
name: f
1217
...

0 commit comments

Comments
 (0)