Skip to content

Commit 592423d

Browse files
committed
add test
1 parent c518b0b commit 592423d

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
@@ -2164,97 +2164,6 @@ static const char NPMRegAllocOptNotSupportedMessage[] =
21642164
"-wwm-regalloc-npm, "
21652165
"and -vgpr-regalloc-npm";
21662166

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

22912188
#undef RA_OPTIONS
22922189
}
@@ -2317,10 +2214,11 @@ void AMDGPUCodeGenPassBuilder::addRegAlloc(AddMachinePass &addPass,
23172214
addPass(RegAllocFastPass(getRAOptionsForPhase<RegAllocFastPass>(Phase)));
23182215
return;
23192216
case RegAllocType::Unset:
2217+
case RegAllocType::Default:
23202218
addPass(RegAllocPassT(getRAOptionsForPhase<RegAllocPassT>(Phase)));
23212219
return;
23222220
default:
2323-
report_fatal_error("Unsupported regalloc type", false);
2221+
report_fatal_error("Unsupported regalloc type for AMDGPU", false);
23242222
}
23252223
}
23262224

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)