1 | //===-- TargetParser - Parser for target features ---------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file implements a target parser to recognise hardware features such as |
10 | // FPU/CPU/ARCH names as well as specific support such as HDIV, etc. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #include "llvm/TargetParser/TargetParser.h" |
15 | #include "llvm/ADT/ArrayRef.h" |
16 | #include "llvm/TargetParser/Triple.h" |
17 | |
18 | using namespace llvm; |
19 | using namespace AMDGPU; |
20 | |
21 | /// Find KV in array using binary search. |
22 | static const BasicSubtargetSubTypeKV * |
23 | find(StringRef S, ArrayRef<BasicSubtargetSubTypeKV> A) { |
24 | // Binary search the array |
25 | auto F = llvm::lower_bound(Range&: A, Value&: S); |
26 | // If not found then return NULL |
27 | if (F == A.end() || StringRef(F->Key) != S) |
28 | return nullptr; |
29 | // Return the found array item |
30 | return F; |
31 | } |
32 | |
33 | /// For each feature that is (transitively) implied by this feature, set it. |
34 | static void setImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies, |
35 | ArrayRef<BasicSubtargetFeatureKV> FeatureTable) { |
36 | // OR the Implies bits in outside the loop. This allows the Implies for CPUs |
37 | // which might imply features not in FeatureTable to use this. |
38 | Bits |= Implies; |
39 | for (const auto &FE : FeatureTable) |
40 | if (Implies.test(I: FE.Value)) |
41 | setImpliedBits(Bits, Implies: FE.Implies.getAsBitset(), FeatureTable); |
42 | } |
43 | |
44 | std::optional<llvm::StringMap<bool>> llvm::getCPUDefaultTargetFeatures( |
45 | StringRef CPU, ArrayRef<BasicSubtargetSubTypeKV> ProcDesc, |
46 | ArrayRef<BasicSubtargetFeatureKV> ProcFeatures) { |
47 | if (CPU.empty()) |
48 | return std::nullopt; |
49 | |
50 | const BasicSubtargetSubTypeKV *CPUEntry = ::find(S: CPU, A: ProcDesc); |
51 | if (!CPUEntry) |
52 | return std::nullopt; |
53 | |
54 | // Set the features implied by this CPU feature if there is a match. |
55 | FeatureBitset Bits; |
56 | llvm::StringMap<bool> DefaultFeatures; |
57 | setImpliedBits(Bits, Implies: CPUEntry->Implies.getAsBitset(), FeatureTable: ProcFeatures); |
58 | |
59 | [[maybe_unused]] unsigned BitSize = Bits.size(); |
60 | for (const BasicSubtargetFeatureKV &FE : ProcFeatures) { |
61 | assert(FE.Value < BitSize && "Target Feature is out of range" ); |
62 | if (Bits[FE.Value]) |
63 | DefaultFeatures[FE.Key] = true; |
64 | } |
65 | return DefaultFeatures; |
66 | } |
67 | |
68 | namespace { |
69 | |
70 | struct GPUInfo { |
71 | StringLiteral Name; |
72 | StringLiteral CanonicalName; |
73 | AMDGPU::GPUKind Kind; |
74 | unsigned Features; |
75 | }; |
76 | |
77 | constexpr GPUInfo R600GPUs[] = { |
78 | // Name Canonical Kind Features |
79 | // Name |
80 | {.Name: {"r600" }, .CanonicalName: {"r600" }, .Kind: GK_R600, .Features: FEATURE_NONE }, |
81 | {.Name: {"rv630" }, .CanonicalName: {"r600" }, .Kind: GK_R600, .Features: FEATURE_NONE }, |
82 | {.Name: {"rv635" }, .CanonicalName: {"r600" }, .Kind: GK_R600, .Features: FEATURE_NONE }, |
83 | {.Name: {"r630" }, .CanonicalName: {"r630" }, .Kind: GK_R630, .Features: FEATURE_NONE }, |
84 | {.Name: {"rs780" }, .CanonicalName: {"rs880" }, .Kind: GK_RS880, .Features: FEATURE_NONE }, |
85 | {.Name: {"rs880" }, .CanonicalName: {"rs880" }, .Kind: GK_RS880, .Features: FEATURE_NONE }, |
86 | {.Name: {"rv610" }, .CanonicalName: {"rs880" }, .Kind: GK_RS880, .Features: FEATURE_NONE }, |
87 | {.Name: {"rv620" }, .CanonicalName: {"rs880" }, .Kind: GK_RS880, .Features: FEATURE_NONE }, |
88 | {.Name: {"rv670" }, .CanonicalName: {"rv670" }, .Kind: GK_RV670, .Features: FEATURE_NONE }, |
89 | {.Name: {"rv710" }, .CanonicalName: {"rv710" }, .Kind: GK_RV710, .Features: FEATURE_NONE }, |
90 | {.Name: {"rv730" }, .CanonicalName: {"rv730" }, .Kind: GK_RV730, .Features: FEATURE_NONE }, |
91 | {.Name: {"rv740" }, .CanonicalName: {"rv770" }, .Kind: GK_RV770, .Features: FEATURE_NONE }, |
92 | {.Name: {"rv770" }, .CanonicalName: {"rv770" }, .Kind: GK_RV770, .Features: FEATURE_NONE }, |
93 | {.Name: {"cedar" }, .CanonicalName: {"cedar" }, .Kind: GK_CEDAR, .Features: FEATURE_NONE }, |
94 | {.Name: {"palm" }, .CanonicalName: {"cedar" }, .Kind: GK_CEDAR, .Features: FEATURE_NONE }, |
95 | {.Name: {"cypress" }, .CanonicalName: {"cypress" }, .Kind: GK_CYPRESS, .Features: FEATURE_FMA }, |
96 | {.Name: {"hemlock" }, .CanonicalName: {"cypress" }, .Kind: GK_CYPRESS, .Features: FEATURE_FMA }, |
97 | {.Name: {"juniper" }, .CanonicalName: {"juniper" }, .Kind: GK_JUNIPER, .Features: FEATURE_NONE }, |
98 | {.Name: {"redwood" }, .CanonicalName: {"redwood" }, .Kind: GK_REDWOOD, .Features: FEATURE_NONE }, |
99 | {.Name: {"sumo" }, .CanonicalName: {"sumo" }, .Kind: GK_SUMO, .Features: FEATURE_NONE }, |
100 | {.Name: {"sumo2" }, .CanonicalName: {"sumo" }, .Kind: GK_SUMO, .Features: FEATURE_NONE }, |
101 | {.Name: {"barts" }, .CanonicalName: {"barts" }, .Kind: GK_BARTS, .Features: FEATURE_NONE }, |
102 | {.Name: {"caicos" }, .CanonicalName: {"caicos" }, .Kind: GK_CAICOS, .Features: FEATURE_NONE }, |
103 | {.Name: {"aruba" }, .CanonicalName: {"cayman" }, .Kind: GK_CAYMAN, .Features: FEATURE_FMA }, |
104 | {.Name: {"cayman" }, .CanonicalName: {"cayman" }, .Kind: GK_CAYMAN, .Features: FEATURE_FMA }, |
105 | {.Name: {"turks" }, .CanonicalName: {"turks" }, .Kind: GK_TURKS, .Features: FEATURE_NONE } |
106 | }; |
107 | |
108 | // This table should be sorted by the value of GPUKind |
109 | // Don't bother listing the implicitly true features |
110 | constexpr GPUInfo AMDGCNGPUs[] = { |
111 | // clang-format off |
112 | // Name Canonical Kind Features |
113 | // Name |
114 | {.Name: {"gfx600" }, .CanonicalName: {"gfx600" }, .Kind: GK_GFX600, .Features: FEATURE_FAST_FMA_F32}, |
115 | {.Name: {"tahiti" }, .CanonicalName: {"gfx600" }, .Kind: GK_GFX600, .Features: FEATURE_FAST_FMA_F32}, |
116 | {.Name: {"gfx601" }, .CanonicalName: {"gfx601" }, .Kind: GK_GFX601, .Features: FEATURE_NONE}, |
117 | {.Name: {"pitcairn" }, .CanonicalName: {"gfx601" }, .Kind: GK_GFX601, .Features: FEATURE_NONE}, |
118 | {.Name: {"verde" }, .CanonicalName: {"gfx601" }, .Kind: GK_GFX601, .Features: FEATURE_NONE}, |
119 | {.Name: {"gfx602" }, .CanonicalName: {"gfx602" }, .Kind: GK_GFX602, .Features: FEATURE_NONE}, |
120 | {.Name: {"hainan" }, .CanonicalName: {"gfx602" }, .Kind: GK_GFX602, .Features: FEATURE_NONE}, |
121 | {.Name: {"oland" }, .CanonicalName: {"gfx602" }, .Kind: GK_GFX602, .Features: FEATURE_NONE}, |
122 | {.Name: {"gfx700" }, .CanonicalName: {"gfx700" }, .Kind: GK_GFX700, .Features: FEATURE_NONE}, |
123 | {.Name: {"kaveri" }, .CanonicalName: {"gfx700" }, .Kind: GK_GFX700, .Features: FEATURE_NONE}, |
124 | {.Name: {"gfx701" }, .CanonicalName: {"gfx701" }, .Kind: GK_GFX701, .Features: FEATURE_FAST_FMA_F32}, |
125 | {.Name: {"hawaii" }, .CanonicalName: {"gfx701" }, .Kind: GK_GFX701, .Features: FEATURE_FAST_FMA_F32}, |
126 | {.Name: {"gfx702" }, .CanonicalName: {"gfx702" }, .Kind: GK_GFX702, .Features: FEATURE_FAST_FMA_F32}, |
127 | {.Name: {"gfx703" }, .CanonicalName: {"gfx703" }, .Kind: GK_GFX703, .Features: FEATURE_NONE}, |
128 | {.Name: {"kabini" }, .CanonicalName: {"gfx703" }, .Kind: GK_GFX703, .Features: FEATURE_NONE}, |
129 | {.Name: {"mullins" }, .CanonicalName: {"gfx703" }, .Kind: GK_GFX703, .Features: FEATURE_NONE}, |
130 | {.Name: {"gfx704" }, .CanonicalName: {"gfx704" }, .Kind: GK_GFX704, .Features: FEATURE_NONE}, |
131 | {.Name: {"bonaire" }, .CanonicalName: {"gfx704" }, .Kind: GK_GFX704, .Features: FEATURE_NONE}, |
132 | {.Name: {"gfx705" }, .CanonicalName: {"gfx705" }, .Kind: GK_GFX705, .Features: FEATURE_NONE}, |
133 | {.Name: {"gfx801" }, .CanonicalName: {"gfx801" }, .Kind: GK_GFX801, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
134 | {.Name: {"carrizo" }, .CanonicalName: {"gfx801" }, .Kind: GK_GFX801, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
135 | {.Name: {"gfx802" }, .CanonicalName: {"gfx802" }, .Kind: GK_GFX802, .Features: FEATURE_FAST_DENORMAL_F32}, |
136 | {.Name: {"iceland" }, .CanonicalName: {"gfx802" }, .Kind: GK_GFX802, .Features: FEATURE_FAST_DENORMAL_F32}, |
137 | {.Name: {"tonga" }, .CanonicalName: {"gfx802" }, .Kind: GK_GFX802, .Features: FEATURE_FAST_DENORMAL_F32}, |
138 | {.Name: {"gfx803" }, .CanonicalName: {"gfx803" }, .Kind: GK_GFX803, .Features: FEATURE_FAST_DENORMAL_F32}, |
139 | {.Name: {"fiji" }, .CanonicalName: {"gfx803" }, .Kind: GK_GFX803, .Features: FEATURE_FAST_DENORMAL_F32}, |
140 | {.Name: {"polaris10" }, .CanonicalName: {"gfx803" }, .Kind: GK_GFX803, .Features: FEATURE_FAST_DENORMAL_F32}, |
141 | {.Name: {"polaris11" }, .CanonicalName: {"gfx803" }, .Kind: GK_GFX803, .Features: FEATURE_FAST_DENORMAL_F32}, |
142 | {.Name: {"gfx805" }, .CanonicalName: {"gfx805" }, .Kind: GK_GFX805, .Features: FEATURE_FAST_DENORMAL_F32}, |
143 | {.Name: {"tongapro" }, .CanonicalName: {"gfx805" }, .Kind: GK_GFX805, .Features: FEATURE_FAST_DENORMAL_F32}, |
144 | {.Name: {"gfx810" }, .CanonicalName: {"gfx810" }, .Kind: GK_GFX810, .Features: FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
145 | {.Name: {"stoney" }, .CanonicalName: {"gfx810" }, .Kind: GK_GFX810, .Features: FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
146 | {.Name: {"gfx900" }, .CanonicalName: {"gfx900" }, .Kind: GK_GFX900, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
147 | {.Name: {"gfx902" }, .CanonicalName: {"gfx902" }, .Kind: GK_GFX902, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
148 | {.Name: {"gfx904" }, .CanonicalName: {"gfx904" }, .Kind: GK_GFX904, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
149 | {.Name: {"gfx906" }, .CanonicalName: {"gfx906" }, .Kind: GK_GFX906, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, |
150 | {.Name: {"gfx908" }, .CanonicalName: {"gfx908" }, .Kind: GK_GFX908, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, |
151 | {.Name: {"gfx909" }, .CanonicalName: {"gfx909" }, .Kind: GK_GFX909, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
152 | {.Name: {"gfx90a" }, .CanonicalName: {"gfx90a" }, .Kind: GK_GFX90A, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, |
153 | {.Name: {"gfx90c" }, .CanonicalName: {"gfx90c" }, .Kind: GK_GFX90C, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
154 | {.Name: {"gfx942" }, .CanonicalName: {"gfx942" }, .Kind: GK_GFX942, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, |
155 | {.Name: {"gfx950" }, .CanonicalName: {"gfx950" }, .Kind: GK_GFX950, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, |
156 | {.Name: {"gfx1010" }, .CanonicalName: {"gfx1010" }, .Kind: GK_GFX1010, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, |
157 | {.Name: {"gfx1011" }, .CanonicalName: {"gfx1011" }, .Kind: GK_GFX1011, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, |
158 | {.Name: {"gfx1012" }, .CanonicalName: {"gfx1012" }, .Kind: GK_GFX1012, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, |
159 | {.Name: {"gfx1013" }, .CanonicalName: {"gfx1013" }, .Kind: GK_GFX1013, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, |
160 | {.Name: {"gfx1030" }, .CanonicalName: {"gfx1030" }, .Kind: GK_GFX1030, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
161 | {.Name: {"gfx1031" }, .CanonicalName: {"gfx1031" }, .Kind: GK_GFX1031, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
162 | {.Name: {"gfx1032" }, .CanonicalName: {"gfx1032" }, .Kind: GK_GFX1032, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
163 | {.Name: {"gfx1033" }, .CanonicalName: {"gfx1033" }, .Kind: GK_GFX1033, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
164 | {.Name: {"gfx1034" }, .CanonicalName: {"gfx1034" }, .Kind: GK_GFX1034, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
165 | {.Name: {"gfx1035" }, .CanonicalName: {"gfx1035" }, .Kind: GK_GFX1035, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
166 | {.Name: {"gfx1036" }, .CanonicalName: {"gfx1036" }, .Kind: GK_GFX1036, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
167 | {.Name: {"gfx1100" }, .CanonicalName: {"gfx1100" }, .Kind: GK_GFX1100, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
168 | {.Name: {"gfx1101" }, .CanonicalName: {"gfx1101" }, .Kind: GK_GFX1101, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
169 | {.Name: {"gfx1102" }, .CanonicalName: {"gfx1102" }, .Kind: GK_GFX1102, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
170 | {.Name: {"gfx1103" }, .CanonicalName: {"gfx1103" }, .Kind: GK_GFX1103, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
171 | {.Name: {"gfx1150" }, .CanonicalName: {"gfx1150" }, .Kind: GK_GFX1150, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
172 | {.Name: {"gfx1151" }, .CanonicalName: {"gfx1151" }, .Kind: GK_GFX1151, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
173 | {.Name: {"gfx1152" }, .CanonicalName: {"gfx1152" }, .Kind: GK_GFX1152, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
174 | {.Name: {"gfx1153" }, .CanonicalName: {"gfx1153" }, .Kind: GK_GFX1153, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
175 | {.Name: {"gfx1200" }, .CanonicalName: {"gfx1200" }, .Kind: GK_GFX1200, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
176 | {.Name: {"gfx1201" }, .CanonicalName: {"gfx1201" }, .Kind: GK_GFX1201, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
177 | {.Name: {"gfx1250" }, .CanonicalName: {"gfx1250" }, .Kind: GK_GFX1250, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32}, |
178 | |
179 | {.Name: {"gfx9-generic" }, .CanonicalName: {"gfx9-generic" }, .Kind: GK_GFX9_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
180 | {.Name: {"gfx10-1-generic" }, .CanonicalName: {"gfx10-1-generic" }, .Kind: GK_GFX10_1_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, |
181 | {.Name: {"gfx10-3-generic" }, .CanonicalName: {"gfx10-3-generic" }, .Kind: GK_GFX10_3_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
182 | {.Name: {"gfx11-generic" }, .CanonicalName: {"gfx11-generic" }, .Kind: GK_GFX11_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
183 | {.Name: {"gfx12-generic" }, .CanonicalName: {"gfx12-generic" }, .Kind: GK_GFX12_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
184 | {.Name: {"gfx9-4-generic" }, .CanonicalName: {"gfx9-4-generic" }, .Kind: GK_GFX9_4_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, |
185 | // clang-format on |
186 | }; |
187 | |
188 | const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef<GPUInfo> Table) { |
189 | GPUInfo Search = { .Name: {"" }, .CanonicalName: {"" }, .Kind: AK, .Features: AMDGPU::FEATURE_NONE }; |
190 | |
191 | auto I = |
192 | llvm::lower_bound(Range&: Table, Value&: Search, C: [](const GPUInfo &A, const GPUInfo &B) { |
193 | return A.Kind < B.Kind; |
194 | }); |
195 | |
196 | if (I == Table.end() || I->Kind != Search.Kind) |
197 | return nullptr; |
198 | return I; |
199 | } |
200 | |
201 | } // namespace |
202 | |
203 | StringRef llvm::AMDGPU::getArchFamilyNameAMDGCN(GPUKind AK) { |
204 | switch (AK) { |
205 | case AMDGPU::GK_GFX9_GENERIC: |
206 | case AMDGPU::GK_GFX9_4_GENERIC: |
207 | return "gfx9" ; |
208 | case AMDGPU::GK_GFX10_1_GENERIC: |
209 | case AMDGPU::GK_GFX10_3_GENERIC: |
210 | return "gfx10" ; |
211 | case AMDGPU::GK_GFX11_GENERIC: |
212 | return "gfx11" ; |
213 | case AMDGPU::GK_GFX12_GENERIC: |
214 | return "gfx12" ; |
215 | default: { |
216 | StringRef ArchName = getArchNameAMDGCN(AK); |
217 | return ArchName.empty() ? "" : ArchName.drop_back(N: 2); |
218 | } |
219 | } |
220 | } |
221 | |
222 | StringRef llvm::AMDGPU::getArchNameAMDGCN(GPUKind AK) { |
223 | if (const auto *Entry = getArchEntry(AK, Table: AMDGCNGPUs)) |
224 | return Entry->CanonicalName; |
225 | return "" ; |
226 | } |
227 | |
228 | StringRef llvm::AMDGPU::getArchNameR600(GPUKind AK) { |
229 | if (const auto *Entry = getArchEntry(AK, Table: R600GPUs)) |
230 | return Entry->CanonicalName; |
231 | return "" ; |
232 | } |
233 | |
234 | AMDGPU::GPUKind llvm::AMDGPU::parseArchAMDGCN(StringRef CPU) { |
235 | for (const auto &C : AMDGCNGPUs) { |
236 | if (CPU == C.Name) |
237 | return C.Kind; |
238 | } |
239 | |
240 | return AMDGPU::GPUKind::GK_NONE; |
241 | } |
242 | |
243 | AMDGPU::GPUKind llvm::AMDGPU::parseArchR600(StringRef CPU) { |
244 | for (const auto &C : R600GPUs) { |
245 | if (CPU == C.Name) |
246 | return C.Kind; |
247 | } |
248 | |
249 | return AMDGPU::GPUKind::GK_NONE; |
250 | } |
251 | |
252 | unsigned AMDGPU::getArchAttrAMDGCN(GPUKind AK) { |
253 | if (const auto *Entry = getArchEntry(AK, Table: AMDGCNGPUs)) |
254 | return Entry->Features; |
255 | return FEATURE_NONE; |
256 | } |
257 | |
258 | unsigned AMDGPU::getArchAttrR600(GPUKind AK) { |
259 | if (const auto *Entry = getArchEntry(AK, Table: R600GPUs)) |
260 | return Entry->Features; |
261 | return FEATURE_NONE; |
262 | } |
263 | |
264 | void AMDGPU::fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values) { |
265 | // XXX: Should this only report unique canonical names? |
266 | for (const auto &C : AMDGCNGPUs) |
267 | Values.push_back(Elt: C.Name); |
268 | } |
269 | |
270 | void AMDGPU::fillValidArchListR600(SmallVectorImpl<StringRef> &Values) { |
271 | for (const auto &C : R600GPUs) |
272 | Values.push_back(Elt: C.Name); |
273 | } |
274 | |
275 | AMDGPU::IsaVersion AMDGPU::getIsaVersion(StringRef GPU) { |
276 | AMDGPU::GPUKind AK = parseArchAMDGCN(CPU: GPU); |
277 | if (AK == AMDGPU::GPUKind::GK_NONE) { |
278 | if (GPU == "generic-hsa" ) |
279 | return {.Major: 7, .Minor: 0, .Stepping: 0}; |
280 | if (GPU == "generic" ) |
281 | return {.Major: 6, .Minor: 0, .Stepping: 0}; |
282 | return {.Major: 0, .Minor: 0, .Stepping: 0}; |
283 | } |
284 | |
285 | // clang-format off |
286 | switch (AK) { |
287 | case GK_GFX600: return {.Major: 6, .Minor: 0, .Stepping: 0}; |
288 | case GK_GFX601: return {.Major: 6, .Minor: 0, .Stepping: 1}; |
289 | case GK_GFX602: return {.Major: 6, .Minor: 0, .Stepping: 2}; |
290 | case GK_GFX700: return {.Major: 7, .Minor: 0, .Stepping: 0}; |
291 | case GK_GFX701: return {.Major: 7, .Minor: 0, .Stepping: 1}; |
292 | case GK_GFX702: return {.Major: 7, .Minor: 0, .Stepping: 2}; |
293 | case GK_GFX703: return {.Major: 7, .Minor: 0, .Stepping: 3}; |
294 | case GK_GFX704: return {.Major: 7, .Minor: 0, .Stepping: 4}; |
295 | case GK_GFX705: return {.Major: 7, .Minor: 0, .Stepping: 5}; |
296 | case GK_GFX801: return {.Major: 8, .Minor: 0, .Stepping: 1}; |
297 | case GK_GFX802: return {.Major: 8, .Minor: 0, .Stepping: 2}; |
298 | case GK_GFX803: return {.Major: 8, .Minor: 0, .Stepping: 3}; |
299 | case GK_GFX805: return {.Major: 8, .Minor: 0, .Stepping: 5}; |
300 | case GK_GFX810: return {.Major: 8, .Minor: 1, .Stepping: 0}; |
301 | case GK_GFX900: return {.Major: 9, .Minor: 0, .Stepping: 0}; |
302 | case GK_GFX902: return {.Major: 9, .Minor: 0, .Stepping: 2}; |
303 | case GK_GFX904: return {.Major: 9, .Minor: 0, .Stepping: 4}; |
304 | case GK_GFX906: return {.Major: 9, .Minor: 0, .Stepping: 6}; |
305 | case GK_GFX908: return {.Major: 9, .Minor: 0, .Stepping: 8}; |
306 | case GK_GFX909: return {.Major: 9, .Minor: 0, .Stepping: 9}; |
307 | case GK_GFX90A: return {.Major: 9, .Minor: 0, .Stepping: 10}; |
308 | case GK_GFX90C: return {.Major: 9, .Minor: 0, .Stepping: 12}; |
309 | case GK_GFX942: return {.Major: 9, .Minor: 4, .Stepping: 2}; |
310 | case GK_GFX950: return {.Major: 9, .Minor: 5, .Stepping: 0}; |
311 | case GK_GFX1010: return {.Major: 10, .Minor: 1, .Stepping: 0}; |
312 | case GK_GFX1011: return {.Major: 10, .Minor: 1, .Stepping: 1}; |
313 | case GK_GFX1012: return {.Major: 10, .Minor: 1, .Stepping: 2}; |
314 | case GK_GFX1013: return {.Major: 10, .Minor: 1, .Stepping: 3}; |
315 | case GK_GFX1030: return {.Major: 10, .Minor: 3, .Stepping: 0}; |
316 | case GK_GFX1031: return {.Major: 10, .Minor: 3, .Stepping: 1}; |
317 | case GK_GFX1032: return {.Major: 10, .Minor: 3, .Stepping: 2}; |
318 | case GK_GFX1033: return {.Major: 10, .Minor: 3, .Stepping: 3}; |
319 | case GK_GFX1034: return {.Major: 10, .Minor: 3, .Stepping: 4}; |
320 | case GK_GFX1035: return {.Major: 10, .Minor: 3, .Stepping: 5}; |
321 | case GK_GFX1036: return {.Major: 10, .Minor: 3, .Stepping: 6}; |
322 | case GK_GFX1100: return {.Major: 11, .Minor: 0, .Stepping: 0}; |
323 | case GK_GFX1101: return {.Major: 11, .Minor: 0, .Stepping: 1}; |
324 | case GK_GFX1102: return {.Major: 11, .Minor: 0, .Stepping: 2}; |
325 | case GK_GFX1103: return {.Major: 11, .Minor: 0, .Stepping: 3}; |
326 | case GK_GFX1150: return {.Major: 11, .Minor: 5, .Stepping: 0}; |
327 | case GK_GFX1151: return {.Major: 11, .Minor: 5, .Stepping: 1}; |
328 | case GK_GFX1152: return {.Major: 11, .Minor: 5, .Stepping: 2}; |
329 | case GK_GFX1153: return {.Major: 11, .Minor: 5, .Stepping: 3}; |
330 | case GK_GFX1200: return {.Major: 12, .Minor: 0, .Stepping: 0}; |
331 | case GK_GFX1201: return {.Major: 12, .Minor: 0, .Stepping: 1}; |
332 | case GK_GFX1250: return {.Major: 12, .Minor: 5, .Stepping: 0}; |
333 | |
334 | // Generic targets return the lowest common denominator |
335 | // within their family. That is, the ISA that is the most |
336 | // restricted in terms of features. |
337 | // |
338 | // gfx9-generic is tricky because there is no lowest |
339 | // common denominator, so we return gfx900 which has mad-mix |
340 | // but this family doesn't have it. |
341 | // |
342 | // This API should never be used to check for a particular |
343 | // feature anyway. |
344 | // |
345 | // TODO: Split up this API depending on its caller so |
346 | // generic target handling is more obvious and less risky. |
347 | case GK_GFX9_GENERIC: return {.Major: 9, .Minor: 0, .Stepping: 0}; |
348 | case GK_GFX9_4_GENERIC: return {.Major: 9, .Minor: 4, .Stepping: 0}; |
349 | case GK_GFX10_1_GENERIC: return {.Major: 10, .Minor: 1, .Stepping: 0}; |
350 | case GK_GFX10_3_GENERIC: return {.Major: 10, .Minor: 3, .Stepping: 0}; |
351 | case GK_GFX11_GENERIC: return {.Major: 11, .Minor: 0, .Stepping: 3}; |
352 | case GK_GFX12_GENERIC: return {.Major: 12, .Minor: 0, .Stepping: 0}; |
353 | default: return {.Major: 0, .Minor: 0, .Stepping: 0}; |
354 | } |
355 | // clang-format on |
356 | } |
357 | |
358 | StringRef AMDGPU::getCanonicalArchName(const Triple &T, StringRef Arch) { |
359 | assert(T.isAMDGPU()); |
360 | auto ProcKind = T.isAMDGCN() ? parseArchAMDGCN(CPU: Arch) : parseArchR600(CPU: Arch); |
361 | if (ProcKind == GK_NONE) |
362 | return StringRef(); |
363 | |
364 | return T.isAMDGCN() ? getArchNameAMDGCN(AK: ProcKind) : getArchNameR600(AK: ProcKind); |
365 | } |
366 | |
367 | void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, |
368 | StringMap<bool> &Features) { |
369 | // XXX - What does the member GPU mean if device name string passed here? |
370 | if (T.isSPIRV() && T.getOS() == Triple::OSType::AMDHSA) { |
371 | // AMDGCN SPIRV must support the union of all AMDGCN features. This list |
372 | // should be kept in sorted order and updated whenever new features are |
373 | // added. |
374 | Features["16-bit-insts" ] = true; |
375 | Features["ashr-pk-insts" ] = true; |
376 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
377 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
378 | Features["atomic-ds-pk-add-16-insts" ] = true; |
379 | Features["atomic-fadd-rtn-insts" ] = true; |
380 | Features["atomic-flat-pk-add-16-insts" ] = true; |
381 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
382 | Features["bf8-cvt-scale-insts" ] = true; |
383 | Features["bitop3-insts" ] = true; |
384 | Features["ci-insts" ] = true; |
385 | Features["dl-insts" ] = true; |
386 | Features["dot1-insts" ] = true; |
387 | Features["dot2-insts" ] = true; |
388 | Features["dot3-insts" ] = true; |
389 | Features["dot4-insts" ] = true; |
390 | Features["dot5-insts" ] = true; |
391 | Features["dot6-insts" ] = true; |
392 | Features["dot7-insts" ] = true; |
393 | Features["dot8-insts" ] = true; |
394 | Features["dot9-insts" ] = true; |
395 | Features["dot10-insts" ] = true; |
396 | Features["dot11-insts" ] = true; |
397 | Features["dot12-insts" ] = true; |
398 | Features["dot13-insts" ] = true; |
399 | Features["dpp" ] = true; |
400 | Features["f16bf16-to-fp6bf6-cvt-scale-insts" ] = true; |
401 | Features["f32-to-f16bf16-cvt-sr-insts" ] = true; |
402 | Features["fp4-cvt-scale-insts" ] = true; |
403 | Features["fp6bf6-cvt-scale-insts" ] = true; |
404 | Features["fp8-insts" ] = true; |
405 | Features["fp8-conversion-insts" ] = true; |
406 | Features["fp8-cvt-scale-insts" ] = true; |
407 | Features["gfx8-insts" ] = true; |
408 | Features["gfx9-insts" ] = true; |
409 | Features["gfx90a-insts" ] = true; |
410 | Features["gfx940-insts" ] = true; |
411 | Features["gfx950-insts" ] = true; |
412 | Features["gfx10-insts" ] = true; |
413 | Features["gfx10-3-insts" ] = true; |
414 | Features["gfx11-insts" ] = true; |
415 | Features["gfx12-insts" ] = true; |
416 | Features["gws" ] = true; |
417 | Features["image-insts" ] = true; |
418 | Features["s-memrealtime" ] = true; |
419 | Features["s-memtime-inst" ] = true; |
420 | Features["mai-insts" ] = true; |
421 | Features["permlane16-swap" ] = true; |
422 | Features["permlane32-swap" ] = true; |
423 | Features["prng-inst" ] = true; |
424 | Features["wavefrontsize32" ] = true; |
425 | Features["wavefrontsize64" ] = true; |
426 | Features["vmem-to-lds-load-insts" ] = true; |
427 | } else if (T.isAMDGCN()) { |
428 | AMDGPU::GPUKind Kind = parseArchAMDGCN(CPU: GPU); |
429 | switch (Kind) { |
430 | case GK_GFX1250: |
431 | Features["ci-insts" ] = true; |
432 | Features["dot7-insts" ] = true; |
433 | Features["dot8-insts" ] = true; |
434 | Features["dl-insts" ] = true; |
435 | Features["16-bit-insts" ] = true; |
436 | Features["dpp" ] = true; |
437 | Features["gfx8-insts" ] = true; |
438 | Features["gfx9-insts" ] = true; |
439 | Features["gfx10-insts" ] = true; |
440 | Features["gfx10-3-insts" ] = true; |
441 | Features["gfx11-insts" ] = true; |
442 | Features["gfx12-insts" ] = true; |
443 | Features["gfx1250-insts" ] = true; |
444 | Features["bitop3-insts" ] = true; |
445 | Features["prng-inst" ] = true; |
446 | Features["transpose-load-f4f6-insts" ] = true; |
447 | Features["fp8-conversion-insts" ] = true; |
448 | Features["permlane16-swap" ] = true; |
449 | Features["ashr-pk-insts" ] = true; |
450 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
451 | Features["atomic-fadd-rtn-insts" ] = true; |
452 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
453 | Features["atomic-flat-pk-add-16-insts" ] = true; |
454 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
455 | Features["atomic-ds-pk-add-16-insts" ] = true; |
456 | Features["setprio-inc-wg-inst" ] = true; |
457 | break; |
458 | case GK_GFX1201: |
459 | case GK_GFX1200: |
460 | case GK_GFX12_GENERIC: |
461 | Features["ci-insts" ] = true; |
462 | Features["dot7-insts" ] = true; |
463 | Features["dot8-insts" ] = true; |
464 | Features["dot9-insts" ] = true; |
465 | Features["dot10-insts" ] = true; |
466 | Features["dot11-insts" ] = true; |
467 | Features["dot12-insts" ] = true; |
468 | Features["dl-insts" ] = true; |
469 | Features["atomic-ds-pk-add-16-insts" ] = true; |
470 | Features["atomic-flat-pk-add-16-insts" ] = true; |
471 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
472 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
473 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
474 | Features["16-bit-insts" ] = true; |
475 | Features["dpp" ] = true; |
476 | Features["gfx8-insts" ] = true; |
477 | Features["gfx9-insts" ] = true; |
478 | Features["gfx10-insts" ] = true; |
479 | Features["gfx10-3-insts" ] = true; |
480 | Features["gfx11-insts" ] = true; |
481 | Features["gfx12-insts" ] = true; |
482 | Features["atomic-fadd-rtn-insts" ] = true; |
483 | Features["image-insts" ] = true; |
484 | Features["fp8-conversion-insts" ] = true; |
485 | break; |
486 | case GK_GFX1153: |
487 | case GK_GFX1152: |
488 | case GK_GFX1151: |
489 | case GK_GFX1150: |
490 | case GK_GFX1103: |
491 | case GK_GFX1102: |
492 | case GK_GFX1101: |
493 | case GK_GFX1100: |
494 | case GK_GFX11_GENERIC: |
495 | Features["ci-insts" ] = true; |
496 | Features["dot5-insts" ] = true; |
497 | Features["dot7-insts" ] = true; |
498 | Features["dot8-insts" ] = true; |
499 | Features["dot9-insts" ] = true; |
500 | Features["dot10-insts" ] = true; |
501 | Features["dot12-insts" ] = true; |
502 | Features["dl-insts" ] = true; |
503 | Features["16-bit-insts" ] = true; |
504 | Features["dpp" ] = true; |
505 | Features["gfx8-insts" ] = true; |
506 | Features["gfx9-insts" ] = true; |
507 | Features["gfx10-insts" ] = true; |
508 | Features["gfx10-3-insts" ] = true; |
509 | Features["gfx11-insts" ] = true; |
510 | Features["atomic-fadd-rtn-insts" ] = true; |
511 | Features["image-insts" ] = true; |
512 | Features["gws" ] = true; |
513 | break; |
514 | case GK_GFX1036: |
515 | case GK_GFX1035: |
516 | case GK_GFX1034: |
517 | case GK_GFX1033: |
518 | case GK_GFX1032: |
519 | case GK_GFX1031: |
520 | case GK_GFX1030: |
521 | case GK_GFX10_3_GENERIC: |
522 | Features["ci-insts" ] = true; |
523 | Features["dot1-insts" ] = true; |
524 | Features["dot2-insts" ] = true; |
525 | Features["dot5-insts" ] = true; |
526 | Features["dot6-insts" ] = true; |
527 | Features["dot7-insts" ] = true; |
528 | Features["dot10-insts" ] = true; |
529 | Features["dl-insts" ] = true; |
530 | Features["16-bit-insts" ] = true; |
531 | Features["dpp" ] = true; |
532 | Features["gfx8-insts" ] = true; |
533 | Features["gfx9-insts" ] = true; |
534 | Features["gfx10-insts" ] = true; |
535 | Features["gfx10-3-insts" ] = true; |
536 | Features["image-insts" ] = true; |
537 | Features["s-memrealtime" ] = true; |
538 | Features["s-memtime-inst" ] = true; |
539 | Features["gws" ] = true; |
540 | Features["vmem-to-lds-load-insts" ] = true; |
541 | break; |
542 | case GK_GFX1012: |
543 | case GK_GFX1011: |
544 | Features["dot1-insts" ] = true; |
545 | Features["dot2-insts" ] = true; |
546 | Features["dot5-insts" ] = true; |
547 | Features["dot6-insts" ] = true; |
548 | Features["dot7-insts" ] = true; |
549 | Features["dot10-insts" ] = true; |
550 | [[fallthrough]]; |
551 | case GK_GFX1013: |
552 | case GK_GFX1010: |
553 | case GK_GFX10_1_GENERIC: |
554 | Features["dl-insts" ] = true; |
555 | Features["ci-insts" ] = true; |
556 | Features["16-bit-insts" ] = true; |
557 | Features["dpp" ] = true; |
558 | Features["gfx8-insts" ] = true; |
559 | Features["gfx9-insts" ] = true; |
560 | Features["gfx10-insts" ] = true; |
561 | Features["image-insts" ] = true; |
562 | Features["s-memrealtime" ] = true; |
563 | Features["s-memtime-inst" ] = true; |
564 | Features["gws" ] = true; |
565 | Features["vmem-to-lds-load-insts" ] = true; |
566 | break; |
567 | case GK_GFX950: |
568 | Features["bitop3-insts" ] = true; |
569 | Features["fp6bf6-cvt-scale-insts" ] = true; |
570 | Features["fp4-cvt-scale-insts" ] = true; |
571 | Features["bf8-cvt-scale-insts" ] = true; |
572 | Features["fp8-cvt-scale-insts" ] = true; |
573 | Features["f16bf16-to-fp6bf6-cvt-scale-insts" ] = true; |
574 | Features["f32-to-f16bf16-cvt-sr-insts" ] = true; |
575 | Features["prng-inst" ] = true; |
576 | Features["permlane16-swap" ] = true; |
577 | Features["permlane32-swap" ] = true; |
578 | Features["ashr-pk-insts" ] = true; |
579 | Features["dot12-insts" ] = true; |
580 | Features["dot13-insts" ] = true; |
581 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
582 | Features["gfx950-insts" ] = true; |
583 | [[fallthrough]]; |
584 | case GK_GFX942: |
585 | Features["fp8-insts" ] = true; |
586 | Features["fp8-conversion-insts" ] = true; |
587 | if (Kind != GK_GFX950) |
588 | Features["xf32-insts" ] = true; |
589 | [[fallthrough]]; |
590 | case GK_GFX9_4_GENERIC: |
591 | Features["gfx940-insts" ] = true; |
592 | Features["atomic-ds-pk-add-16-insts" ] = true; |
593 | Features["atomic-flat-pk-add-16-insts" ] = true; |
594 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
595 | Features["gfx90a-insts" ] = true; |
596 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
597 | Features["atomic-fadd-rtn-insts" ] = true; |
598 | Features["dot3-insts" ] = true; |
599 | Features["dot4-insts" ] = true; |
600 | Features["dot5-insts" ] = true; |
601 | Features["dot6-insts" ] = true; |
602 | Features["mai-insts" ] = true; |
603 | Features["dl-insts" ] = true; |
604 | Features["dot1-insts" ] = true; |
605 | Features["dot2-insts" ] = true; |
606 | Features["dot7-insts" ] = true; |
607 | Features["dot10-insts" ] = true; |
608 | Features["gfx9-insts" ] = true; |
609 | Features["gfx8-insts" ] = true; |
610 | Features["16-bit-insts" ] = true; |
611 | Features["dpp" ] = true; |
612 | Features["s-memrealtime" ] = true; |
613 | Features["ci-insts" ] = true; |
614 | Features["s-memtime-inst" ] = true; |
615 | Features["gws" ] = true; |
616 | Features["vmem-to-lds-load-insts" ] = true; |
617 | break; |
618 | case GK_GFX90A: |
619 | Features["gfx90a-insts" ] = true; |
620 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
621 | Features["atomic-fadd-rtn-insts" ] = true; |
622 | [[fallthrough]]; |
623 | case GK_GFX908: |
624 | Features["dot3-insts" ] = true; |
625 | Features["dot4-insts" ] = true; |
626 | Features["dot5-insts" ] = true; |
627 | Features["dot6-insts" ] = true; |
628 | Features["mai-insts" ] = true; |
629 | [[fallthrough]]; |
630 | case GK_GFX906: |
631 | Features["dl-insts" ] = true; |
632 | Features["dot1-insts" ] = true; |
633 | Features["dot2-insts" ] = true; |
634 | Features["dot7-insts" ] = true; |
635 | Features["dot10-insts" ] = true; |
636 | [[fallthrough]]; |
637 | case GK_GFX90C: |
638 | case GK_GFX909: |
639 | case GK_GFX904: |
640 | case GK_GFX902: |
641 | case GK_GFX900: |
642 | case GK_GFX9_GENERIC: |
643 | Features["gfx9-insts" ] = true; |
644 | Features["vmem-to-lds-load-insts" ] = true; |
645 | [[fallthrough]]; |
646 | case GK_GFX810: |
647 | case GK_GFX805: |
648 | case GK_GFX803: |
649 | case GK_GFX802: |
650 | case GK_GFX801: |
651 | Features["gfx8-insts" ] = true; |
652 | Features["16-bit-insts" ] = true; |
653 | Features["dpp" ] = true; |
654 | Features["s-memrealtime" ] = true; |
655 | [[fallthrough]]; |
656 | case GK_GFX705: |
657 | case GK_GFX704: |
658 | case GK_GFX703: |
659 | case GK_GFX702: |
660 | case GK_GFX701: |
661 | case GK_GFX700: |
662 | Features["ci-insts" ] = true; |
663 | [[fallthrough]]; |
664 | case GK_GFX602: |
665 | case GK_GFX601: |
666 | case GK_GFX600: |
667 | Features["image-insts" ] = true; |
668 | Features["s-memtime-inst" ] = true; |
669 | Features["gws" ] = true; |
670 | break; |
671 | case GK_NONE: |
672 | break; |
673 | default: |
674 | llvm_unreachable("Unhandled GPU!" ); |
675 | } |
676 | } else { |
677 | if (GPU.empty()) |
678 | GPU = "r600" ; |
679 | |
680 | switch (llvm::AMDGPU::parseArchR600(CPU: GPU)) { |
681 | case GK_CAYMAN: |
682 | case GK_CYPRESS: |
683 | case GK_RV770: |
684 | case GK_RV670: |
685 | // TODO: Add fp64 when implemented. |
686 | break; |
687 | case GK_TURKS: |
688 | case GK_CAICOS: |
689 | case GK_BARTS: |
690 | case GK_SUMO: |
691 | case GK_REDWOOD: |
692 | case GK_JUNIPER: |
693 | case GK_CEDAR: |
694 | case GK_RV730: |
695 | case GK_RV710: |
696 | case GK_RS880: |
697 | case GK_R630: |
698 | case GK_R600: |
699 | break; |
700 | default: |
701 | llvm_unreachable("Unhandled GPU!" ); |
702 | } |
703 | } |
704 | } |
705 | |
706 | static bool isWave32Capable(StringRef GPU, const Triple &T) { |
707 | bool IsWave32Capable = false; |
708 | // XXX - What does the member GPU mean if device name string passed here? |
709 | if (T.isAMDGCN()) { |
710 | switch (parseArchAMDGCN(CPU: GPU)) { |
711 | case GK_GFX1250: |
712 | case GK_GFX1201: |
713 | case GK_GFX1200: |
714 | case GK_GFX1153: |
715 | case GK_GFX1152: |
716 | case GK_GFX1151: |
717 | case GK_GFX1150: |
718 | case GK_GFX1103: |
719 | case GK_GFX1102: |
720 | case GK_GFX1101: |
721 | case GK_GFX1100: |
722 | case GK_GFX1036: |
723 | case GK_GFX1035: |
724 | case GK_GFX1034: |
725 | case GK_GFX1033: |
726 | case GK_GFX1032: |
727 | case GK_GFX1031: |
728 | case GK_GFX1030: |
729 | case GK_GFX1012: |
730 | case GK_GFX1011: |
731 | case GK_GFX1013: |
732 | case GK_GFX1010: |
733 | case GK_GFX12_GENERIC: |
734 | case GK_GFX11_GENERIC: |
735 | case GK_GFX10_3_GENERIC: |
736 | case GK_GFX10_1_GENERIC: |
737 | IsWave32Capable = true; |
738 | break; |
739 | default: |
740 | break; |
741 | } |
742 | } |
743 | return IsWave32Capable; |
744 | } |
745 | |
746 | std::pair<FeatureError, StringRef> |
747 | AMDGPU::insertWaveSizeFeature(StringRef GPU, const Triple &T, |
748 | StringMap<bool> &Features) { |
749 | bool IsWave32Capable = isWave32Capable(GPU, T); |
750 | const bool IsNullGPU = GPU.empty(); |
751 | const bool HaveWave32 = Features.count(Key: "wavefrontsize32" ); |
752 | const bool HaveWave64 = Features.count(Key: "wavefrontsize64" ); |
753 | if (HaveWave32 && HaveWave64) { |
754 | return {AMDGPU::INVALID_FEATURE_COMBINATION, |
755 | "'wavefrontsize32' and 'wavefrontsize64' are mutually exclusive" }; |
756 | } |
757 | if (HaveWave32 && !IsNullGPU && !IsWave32Capable) { |
758 | return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "wavefrontsize32" }; |
759 | } |
760 | // Don't assume any wavesize with an unknown subtarget. |
761 | if (!IsNullGPU) { |
762 | // Default to wave32 if available, or wave64 if not |
763 | if (!HaveWave32 && !HaveWave64) { |
764 | StringRef DefaultWaveSizeFeature = |
765 | IsWave32Capable ? "wavefrontsize32" : "wavefrontsize64" ; |
766 | Features.insert(KV: std::make_pair(x&: DefaultWaveSizeFeature, y: true)); |
767 | } |
768 | } |
769 | return {NO_ERROR, StringRef()}; |
770 | } |
771 | |