LLVM 23.0.0git
TargetParser.cpp
Go to the documentation of this file.
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
15#include "llvm/ADT/ArrayRef.h"
18
19using namespace llvm;
20using namespace AMDGPU;
21
22/// Find KV in array using binary search.
23static const BasicSubtargetSubTypeKV *
25 // Binary search the array
26 auto F = llvm::lower_bound(A, S);
27 // If not found then return NULL
28 if (F == A.end() || StringRef(F->Key) != S)
29 return nullptr;
30 // Return the found array item
31 return F;
32}
33
34/// For each feature that is (transitively) implied by this feature, set it.
35static void setImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies,
37 // OR the Implies bits in outside the loop. This allows the Implies for CPUs
38 // which might imply features not in FeatureTable to use this.
39 Bits |= Implies;
40 for (const auto &FE : FeatureTable)
41 if (Implies.test(FE.Value))
42 setImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable);
43}
44
45std::optional<llvm::StringMap<bool>> llvm::getCPUDefaultTargetFeatures(
48 if (CPU.empty())
49 return std::nullopt;
50
51 const BasicSubtargetSubTypeKV *CPUEntry = ::find(CPU, ProcDesc);
52 if (!CPUEntry)
53 return std::nullopt;
54
55 // Set the features implied by this CPU feature if there is a match.
56 FeatureBitset Bits;
57 llvm::StringMap<bool> DefaultFeatures;
58 setImpliedBits(Bits, CPUEntry->Implies.getAsBitset(), ProcFeatures);
59
60 [[maybe_unused]] unsigned BitSize = Bits.size();
61 for (const BasicSubtargetFeatureKV &FE : ProcFeatures) {
62 assert(FE.Value < BitSize && "Target Feature is out of range");
63 if (Bits[FE.Value])
64 DefaultFeatures[FE.Key] = true;
65 }
66 return DefaultFeatures;
67}
68
70 StringRef ArchName = getArchNameAMDGCN(AK);
72 ArchName.ends_with("-generic") &&
73 "Generic AMDGCN arch not classified correctly!");
75 // Return the part before the first '-', e.g. "gfx9-4-generic" -> "gfx9".
76 return ArchName.take_front(ArchName.find('-'));
77 }
78 return ArchName.empty() ? "" : ArchName.drop_back(2);
79}
80
82 switch (AK) {
83#define AMDGCN_GPU(NAME, ENUM, ISAVERSION, FEATURES) \
84 case ENUM: \
85 return NAME;
86#include "llvm/TargetParser/AMDGPUTargetParser.def"
87 default:
88 return "";
89 }
90}
91
93 switch (AK) {
94#define R600_GPU(NAME, ENUM, FEATURES) \
95 case ENUM: \
96 return NAME;
97#include "llvm/TargetParser/AMDGPUTargetParser.def"
98 default:
99 return "";
100 }
101}
102
105#define AMDGCN_GPU(NAME, ENUM, ISAVERSION, FEATURES) .Case(NAME, ENUM)
106#define AMDGCN_GPU_ALIAS(NAME, ENUM) .Case(NAME, ENUM)
107#include "llvm/TargetParser/AMDGPUTargetParser.def"
109}
110
113#define R600_GPU(NAME, ENUM, FEATURES) .Case(NAME, ENUM)
114#define R600_GPU_ALIAS(NAME, ENUM) .Case(NAME, ENUM)
115#include "llvm/TargetParser/AMDGPUTargetParser.def"
117}
118
120 switch (AK) {
121#define AMDGCN_GPU(NAME, ENUM, ISAVERSION, FEATURES) \
122 case ENUM: \
123 return FEATURES;
124#include "llvm/TargetParser/AMDGPUTargetParser.def"
125 default:
126 return FEATURE_NONE;
127 }
128}
129
131 switch (AK) {
132#define R600_GPU(NAME, ENUM, FEATURES) \
133 case ENUM: \
134 return FEATURES;
135#include "llvm/TargetParser/AMDGPUTargetParser.def"
136 default:
137 return FEATURE_NONE;
138 }
139}
140
142 // XXX: Should this only report unique canonical names?
143 Values.append({
144#define AMDGCN_GPU(NAME, ENUM, ISAVERSION, FEATURES) NAME,
145#define AMDGCN_GPU_ALIAS(NAME, ENUM) NAME,
146#include "llvm/TargetParser/AMDGPUTargetParser.def"
147 });
148}
149
151 Values.append({
152#define R600_GPU(NAME, ENUM, FEATURES) NAME,
153#define R600_GPU_ALIAS(NAME, ENUM) NAME,
154#include "llvm/TargetParser/AMDGPUTargetParser.def"
155 });
156}
157
160 if (AK == AMDGPU::GPUKind::GK_NONE) {
161 if (GPU == "generic-hsa")
162 return {7, 0, 0};
163 if (GPU == "generic")
164 return {6, 0, 0};
165 return {0, 0, 0};
166 }
167
168 switch (AK) {
169#define MAKE_ISAVERSION(A, B, C) {A, B, C}
170#define AMDGCN_GPU(NAME, ENUM, ISAVERSION, FEATURES) \
171 case ENUM: \
172 return MAKE_ISAVERSION ISAVERSION;
173#include "llvm/TargetParser/AMDGPUTargetParser.def"
174#undef MAKE_ISAVERSION
175 default:
176 return {0, 0, 0};
177 }
178}
179
181 assert(T.isAMDGPU());
182 auto ProcKind = T.isAMDGCN() ? parseArchAMDGCN(Arch) : parseArchR600(Arch);
183 if (ProcKind == GK_NONE)
184 return StringRef();
185
186 return T.isAMDGCN() ? getArchNameAMDGCN(ProcKind) : getArchNameR600(ProcKind);
187}
188
189static std::pair<FeatureError, StringRef>
191 const StringMap<bool> &DefaultFeatures,
192 StringMap<bool> &Features) {
193 const bool IsNullGPU = GPU.empty();
194 const bool TargetHasWave32 = DefaultFeatures.count("wavefrontsize32");
195 const bool TargetHasWave64 = DefaultFeatures.count("wavefrontsize64");
196
197 auto Wave32Itr = Features.find("wavefrontsize32");
198 auto Wave64Itr = Features.find("wavefrontsize64");
199 const bool EnableWave32 =
200 Wave32Itr != Features.end() && Wave32Itr->getValue();
201 const bool EnableWave64 =
202 Wave64Itr != Features.end() && Wave64Itr->getValue();
203 const bool DisableWave32 =
204 Wave32Itr != Features.end() && !Wave32Itr->getValue();
205 const bool DisableWave64 =
206 Wave64Itr != Features.end() && !Wave64Itr->getValue();
207
208 if (EnableWave32 && EnableWave64)
210 "'+wavefrontsize32' and '+wavefrontsize64' are mutually exclusive"};
211 if (DisableWave32 && DisableWave64)
213 "'-wavefrontsize32' and '-wavefrontsize64' are mutually exclusive"};
214
215 if (!IsNullGPU) {
216 if (TargetHasWave64) {
217 if (EnableWave32)
218 return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "+wavefrontsize32"};
219 if (DisableWave64)
220 return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "-wavefrontsize64"};
221 }
222
223 if (TargetHasWave32) {
224 if (EnableWave64)
225 return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "+wavefrontsize64"};
226 if (DisableWave32)
227 return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "-wavefrontsize32"};
228 }
229 }
230
231 // Don't assume any wavesize with an unknown subtarget.
232 // Default to wave32 if target supports both.
233 if (!IsNullGPU && !EnableWave32 && !EnableWave64 && !TargetHasWave32 &&
234 !TargetHasWave64)
235 Features.insert(std::make_pair("wavefrontsize32", true));
236
237 for (const auto &Entry : DefaultFeatures) {
238 if (!Features.count(Entry.getKey()))
239 Features[Entry.getKey()] = Entry.getValue();
240 }
241
242 return {NO_ERROR, StringRef()};
243}
244
245/// Fills Features map with default values for given target GPU.
246/// \p Features contains overriding target features and this function returns
247/// default target features with entries overridden by \p Features.
248static void fillAMDGCNFeatureMap(StringRef GPU, const Triple &T,
249 StringMap<bool> &Features) {
251 switch (Kind) {
252 case GK_GFX1251:
253 case GK_GFX1250:
254 case GK_GFX12_5_GENERIC:
255 Features["swmmac-gfx1200-insts"] = true;
256 Features["swmmac-gfx1250-insts"] = true;
257 [[fallthrough]];
258 case GK_GFX1310:
259 Features["ci-insts"] = true;
260 Features["dot7-insts"] = true;
261 Features["dot8-insts"] = true;
262 Features["dl-insts"] = true;
263 Features["16-bit-insts"] = true;
264 Features["dpp"] = true;
265 Features["gfx8-insts"] = true;
266 Features["gfx9-insts"] = true;
267 Features["gfx10-insts"] = true;
268 Features["gfx10-3-insts"] = true;
269 Features["gfx11-insts"] = true;
270 Features["gfx12-insts"] = true;
271 Features["gfx1250-insts"] = true;
272 Features["bitop3-insts"] = true;
273 Features["prng-inst"] = true;
274 Features["tanh-insts"] = true;
275 Features["tensor-cvt-lut-insts"] = true;
276 Features["transpose-load-f4f6-insts"] = true;
277 Features["bf16-trans-insts"] = true;
278 Features["bf16-cvt-insts"] = true;
279 Features["bf16-pk-insts"] = true;
280 Features["fp8-conversion-insts"] = true;
281 Features["fp8e5m3-insts"] = true;
282 Features["permlane16-swap"] = true;
283 Features["ashr-pk-insts"] = true;
284 Features["add-min-max-insts"] = true;
285 Features["pk-add-min-max-insts"] = true;
286 Features["atomic-buffer-pk-add-bf16-inst"] = true;
287 Features["vmem-pref-insts"] = true;
288 Features["atomic-fadd-rtn-insts"] = true;
289 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
290 Features["atomic-flat-pk-add-16-insts"] = true;
291 Features["atomic-global-pk-add-bf16-inst"] = true;
292 Features["atomic-ds-pk-add-16-insts"] = true;
293 Features["setprio-inc-wg-inst"] = true;
294 Features["s-wakeup-barrier-inst"] = true;
295 Features["atomic-fmin-fmax-global-f32"] = true;
296 Features["atomic-fmin-fmax-global-f64"] = true;
297 Features["wavefrontsize32"] = true;
298 Features["clusters"] = true;
299 Features["mcast-load-insts"] = true;
300 Features["cube-insts"] = true;
301 Features["lerp-inst"] = true;
302 Features["sad-insts"] = true;
303 Features["qsad-insts"] = true;
304 Features["cvt-pknorm-vop2-insts"] = true;
305 break;
306 case GK_GFX1201:
307 case GK_GFX1200:
308 case GK_GFX12_GENERIC:
309 Features["ci-insts"] = true;
310 Features["dot7-insts"] = true;
311 Features["dot8-insts"] = true;
312 Features["dot9-insts"] = true;
313 Features["dot10-insts"] = true;
314 Features["dot11-insts"] = true;
315 Features["dot12-insts"] = true;
316 Features["dl-insts"] = true;
317 Features["atomic-ds-pk-add-16-insts"] = true;
318 Features["atomic-flat-pk-add-16-insts"] = true;
319 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
320 Features["atomic-buffer-pk-add-bf16-inst"] = true;
321 Features["atomic-global-pk-add-bf16-inst"] = true;
322 Features["16-bit-insts"] = true;
323 Features["dpp"] = true;
324 Features["gfx8-insts"] = true;
325 Features["gfx9-insts"] = true;
326 Features["gfx10-insts"] = true;
327 Features["gfx10-3-insts"] = true;
328 Features["gfx11-insts"] = true;
329 Features["gfx12-insts"] = true;
330 Features["atomic-fadd-rtn-insts"] = true;
331 Features["image-insts"] = true;
332 Features["cube-insts"] = true;
333 Features["lerp-inst"] = true;
334 Features["sad-insts"] = true;
335 Features["qsad-insts"] = true;
336 Features["cvt-pknorm-vop2-insts"] = true;
337 Features["fp8-conversion-insts"] = true;
338 Features["wmma-128b-insts"] = true;
339 Features["swmmac-gfx1200-insts"] = true;
340 Features["atomic-fmin-fmax-global-f32"] = true;
341 break;
342 case GK_GFX1170:
343 case GK_GFX1171:
344 case GK_GFX1172:
345 Features["ci-insts"] = true;
346 Features["dot7-insts"] = true;
347 Features["dot8-insts"] = true;
348 Features["dot9-insts"] = true;
349 Features["dot10-insts"] = true;
350 Features["dot12-insts"] = true;
351 Features["dl-insts"] = true;
352 Features["16-bit-insts"] = true;
353 Features["dpp"] = true;
354 Features["gfx8-insts"] = true;
355 Features["gfx9-insts"] = true;
356 Features["gfx10-insts"] = true;
357 Features["gfx10-3-insts"] = true;
358 Features["gfx11-insts"] = true;
359 Features["atomic-fadd-rtn-insts"] = true;
360 Features["image-insts"] = true;
361 Features["cube-insts"] = true;
362 Features["lerp-inst"] = true;
363 Features["sad-insts"] = true;
364 Features["qsad-insts"] = true;
365 Features["cvt-pknorm-vop2-insts"] = true;
366 Features["gws"] = true;
367 Features["dot11-insts"] = true;
368 Features["fp8-conversion-insts"] = true;
369 Features["wmma-128b-insts"] = true;
370 Features["swmmac-gfx1200-insts"] = true;
371 Features["atomic-fmin-fmax-global-f32"] = true;
372 break;
373 case GK_GFX1153:
374 case GK_GFX1152:
375 case GK_GFX1151:
376 case GK_GFX1150:
377 case GK_GFX1103:
378 case GK_GFX1102:
379 case GK_GFX1101:
380 case GK_GFX1100:
381 case GK_GFX11_GENERIC:
382 Features["ci-insts"] = true;
383 Features["dot5-insts"] = true;
384 Features["dot7-insts"] = true;
385 Features["dot8-insts"] = true;
386 Features["dot9-insts"] = true;
387 Features["dot10-insts"] = true;
388 Features["dot12-insts"] = true;
389 Features["dl-insts"] = true;
390 Features["16-bit-insts"] = true;
391 Features["dpp"] = true;
392 Features["gfx8-insts"] = true;
393 Features["gfx9-insts"] = true;
394 Features["gfx10-insts"] = true;
395 Features["gfx10-3-insts"] = true;
396 Features["gfx11-insts"] = true;
397 Features["atomic-fadd-rtn-insts"] = true;
398 Features["image-insts"] = true;
399 Features["cube-insts"] = true;
400 Features["lerp-inst"] = true;
401 Features["sad-insts"] = true;
402 Features["qsad-insts"] = true;
403 Features["cvt-pknorm-vop2-insts"] = true;
404 Features["gws"] = true;
405 Features["wmma-256b-insts"] = true;
406 Features["atomic-fmin-fmax-global-f32"] = true;
407 break;
408 case GK_GFX1036:
409 case GK_GFX1035:
410 case GK_GFX1034:
411 case GK_GFX1033:
412 case GK_GFX1032:
413 case GK_GFX1031:
414 case GK_GFX1030:
415 case GK_GFX10_3_GENERIC:
416 Features["ci-insts"] = true;
417 Features["dot1-insts"] = true;
418 Features["dot2-insts"] = true;
419 Features["dot5-insts"] = true;
420 Features["dot6-insts"] = true;
421 Features["dot7-insts"] = true;
422 Features["dot10-insts"] = true;
423 Features["dl-insts"] = true;
424 Features["16-bit-insts"] = true;
425 Features["dpp"] = true;
426 Features["gfx8-insts"] = true;
427 Features["gfx9-insts"] = true;
428 Features["gfx10-insts"] = true;
429 Features["gfx10-3-insts"] = true;
430 Features["image-insts"] = true;
431 Features["s-memrealtime"] = true;
432 Features["s-memtime-inst"] = true;
433 Features["gws"] = true;
434 Features["vmem-to-lds-load-insts"] = true;
435 Features["atomic-fmin-fmax-global-f32"] = true;
436 Features["atomic-fmin-fmax-global-f64"] = true;
437 Features["cube-insts"] = true;
438 Features["lerp-inst"] = true;
439 Features["sad-insts"] = true;
440 Features["qsad-insts"] = true;
441 Features["cvt-pknorm-vop2-insts"] = true;
442 break;
443 case GK_GFX1012:
444 case GK_GFX1011:
445 Features["dot1-insts"] = true;
446 Features["dot2-insts"] = true;
447 Features["dot5-insts"] = true;
448 Features["dot6-insts"] = true;
449 Features["dot7-insts"] = true;
450 Features["dot10-insts"] = true;
451 [[fallthrough]];
452 case GK_GFX1013:
453 case GK_GFX1010:
454 case GK_GFX10_1_GENERIC:
455 Features["dl-insts"] = true;
456 Features["ci-insts"] = true;
457 Features["16-bit-insts"] = true;
458 Features["dpp"] = true;
459 Features["gfx8-insts"] = true;
460 Features["gfx9-insts"] = true;
461 Features["gfx10-insts"] = true;
462 Features["image-insts"] = true;
463 Features["s-memrealtime"] = true;
464 Features["s-memtime-inst"] = true;
465 Features["gws"] = true;
466 Features["vmem-to-lds-load-insts"] = true;
467 Features["atomic-fmin-fmax-global-f32"] = true;
468 Features["atomic-fmin-fmax-global-f64"] = true;
469 Features["cube-insts"] = true;
470 Features["lerp-inst"] = true;
471 Features["sad-insts"] = true;
472 Features["qsad-insts"] = true;
473 Features["cvt-pknorm-vop2-insts"] = true;
474 break;
475 case GK_GFX950:
476 Features["bitop3-insts"] = true;
477 Features["fp6bf6-cvt-scale-insts"] = true;
478 Features["fp4-cvt-scale-insts"] = true;
479 Features["bf8-cvt-scale-insts"] = true;
480 Features["fp8-cvt-scale-insts"] = true;
481 Features["f16bf16-to-fp6bf6-cvt-scale-insts"] = true;
482 Features["f32-to-f16bf16-cvt-sr-insts"] = true;
483 Features["prng-inst"] = true;
484 Features["permlane16-swap"] = true;
485 Features["permlane32-swap"] = true;
486 Features["ashr-pk-insts"] = true;
487 Features["dot12-insts"] = true;
488 Features["dot13-insts"] = true;
489 Features["atomic-buffer-pk-add-bf16-inst"] = true;
490 Features["gfx950-insts"] = true;
491 [[fallthrough]];
492 case GK_GFX942:
493 Features["fp8-insts"] = true;
494 Features["fp8-conversion-insts"] = true;
495 if (Kind != GK_GFX950)
496 Features["xf32-insts"] = true;
497 [[fallthrough]];
498 case GK_GFX9_4_GENERIC:
499 Features["gfx940-insts"] = true;
500 Features["atomic-ds-pk-add-16-insts"] = true;
501 Features["atomic-flat-pk-add-16-insts"] = true;
502 Features["atomic-global-pk-add-bf16-inst"] = true;
503 Features["gfx90a-insts"] = true;
504 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
505 Features["atomic-fadd-rtn-insts"] = true;
506 Features["dot3-insts"] = true;
507 Features["dot4-insts"] = true;
508 Features["dot5-insts"] = true;
509 Features["dot6-insts"] = true;
510 Features["mai-insts"] = true;
511 Features["dl-insts"] = true;
512 Features["dot1-insts"] = true;
513 Features["dot2-insts"] = true;
514 Features["dot7-insts"] = true;
515 Features["dot10-insts"] = true;
516 Features["gfx9-insts"] = true;
517 Features["gfx8-insts"] = true;
518 Features["16-bit-insts"] = true;
519 Features["dpp"] = true;
520 Features["s-memrealtime"] = true;
521 Features["ci-insts"] = true;
522 Features["s-memtime-inst"] = true;
523 Features["gws"] = true;
524 Features["vmem-to-lds-load-insts"] = true;
525 Features["atomic-fmin-fmax-global-f64"] = true;
526 Features["wavefrontsize64"] = true;
527 Features["cube-insts"] = true;
528 Features["lerp-inst"] = true;
529 Features["sad-insts"] = true;
530 Features["qsad-insts"] = true;
531 Features["cvt-pknorm-vop2-insts"] = true;
532 break;
533 case GK_GFX90A:
534 Features["gfx90a-insts"] = true;
535 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
536 Features["atomic-fadd-rtn-insts"] = true;
537 Features["atomic-fmin-fmax-global-f64"] = true;
538 [[fallthrough]];
539 case GK_GFX908:
540 Features["dot3-insts"] = true;
541 Features["dot4-insts"] = true;
542 Features["dot5-insts"] = true;
543 Features["dot6-insts"] = true;
544 Features["mai-insts"] = true;
545 [[fallthrough]];
546 case GK_GFX906:
547 Features["dl-insts"] = true;
548 Features["dot1-insts"] = true;
549 Features["dot2-insts"] = true;
550 Features["dot7-insts"] = true;
551 Features["dot10-insts"] = true;
552 [[fallthrough]];
553 case GK_GFX90C:
554 case GK_GFX909:
555 case GK_GFX904:
556 case GK_GFX902:
557 case GK_GFX900:
558 case GK_GFX9_GENERIC:
559 Features["gfx9-insts"] = true;
560 Features["vmem-to-lds-load-insts"] = true;
561 [[fallthrough]];
562 case GK_GFX810:
563 case GK_GFX805:
564 case GK_GFX803:
565 case GK_GFX802:
566 case GK_GFX801:
567 Features["gfx8-insts"] = true;
568 Features["16-bit-insts"] = true;
569 Features["dpp"] = true;
570 Features["s-memrealtime"] = true;
571 Features["ci-insts"] = true;
572 Features["image-insts"] = true;
573 Features["s-memtime-inst"] = true;
574 Features["gws"] = true;
575 Features["wavefrontsize64"] = true;
576 Features["cube-insts"] = true;
577 Features["lerp-inst"] = true;
578 Features["sad-insts"] = true;
579 Features["qsad-insts"] = true;
580 Features["cvt-pknorm-vop2-insts"] = true;
581 break;
582 case GK_GFX705:
583 case GK_GFX704:
584 case GK_GFX703:
585 case GK_GFX702:
586 case GK_GFX701:
587 case GK_GFX700:
588 Features["ci-insts"] = true;
589 Features["cube-insts"] = true;
590 Features["lerp-inst"] = true;
591 Features["sad-insts"] = true;
592 Features["qsad-insts"] = true;
593 Features["cvt-pknorm-vop2-insts"] = true;
594 Features["image-insts"] = true;
595 Features["s-memtime-inst"] = true;
596 Features["gws"] = true;
597 Features["atomic-fmin-fmax-global-f32"] = true;
598 Features["atomic-fmin-fmax-global-f64"] = true;
599 Features["wavefrontsize64"] = true;
600 break;
601 case GK_GFX602:
602 case GK_GFX601:
603 case GK_GFX600:
604 Features["image-insts"] = true;
605 Features["s-memtime-inst"] = true;
606 Features["gws"] = true;
607 Features["atomic-fmin-fmax-global-f32"] = true;
608 Features["atomic-fmin-fmax-global-f64"] = true;
609 Features["wavefrontsize64"] = true;
610 Features["cube-insts"] = true;
611 Features["lerp-inst"] = true;
612 Features["sad-insts"] = true;
613 Features["cvt-pknorm-vop2-insts"] = true;
614 break;
615 case GK_NONE:
616 break;
617 default:
618 llvm_unreachable("Unhandled GPU!");
619 }
620}
621
622/// Fills Features map with default values for given target GPU.
623/// \p Features contains overriding target features and this function returns
624/// default target features with entries overridden by \p Features.
625std::pair<FeatureError, StringRef>
627 StringMap<bool> &Features) {
628 // XXX - What does the member GPU mean if device name string passed here?
629 if (T.isSPIRV() && T.getOS() == Triple::OSType::AMDHSA) {
630 // AMDGCN SPIRV must support the union of all AMDGCN features. This list
631 // should be kept in sorted order and updated whenever new features are
632 // added.
633 Features["16-bit-insts"] = true;
634 Features["ashr-pk-insts"] = true;
635 Features["atomic-buffer-pk-add-bf16-inst"] = true;
636 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
637 Features["atomic-ds-pk-add-16-insts"] = true;
638 Features["atomic-fadd-rtn-insts"] = true;
639 Features["atomic-flat-pk-add-16-insts"] = true;
640 Features["atomic-global-pk-add-bf16-inst"] = true;
641 Features["bf16-trans-insts"] = true;
642 Features["bf16-cvt-insts"] = true;
643 Features["bf8-cvt-scale-insts"] = true;
644 Features["bitop3-insts"] = true;
645 Features["ci-insts"] = true;
646 Features["dl-insts"] = true;
647 Features["dot1-insts"] = true;
648 Features["dot2-insts"] = true;
649 Features["dot3-insts"] = true;
650 Features["dot4-insts"] = true;
651 Features["dot5-insts"] = true;
652 Features["dot6-insts"] = true;
653 Features["dot7-insts"] = true;
654 Features["dot8-insts"] = true;
655 Features["dot9-insts"] = true;
656 Features["dot10-insts"] = true;
657 Features["dot11-insts"] = true;
658 Features["dot12-insts"] = true;
659 Features["dot13-insts"] = true;
660 Features["dpp"] = true;
661 Features["f16bf16-to-fp6bf6-cvt-scale-insts"] = true;
662 Features["f32-to-f16bf16-cvt-sr-insts"] = true;
663 Features["fp4-cvt-scale-insts"] = true;
664 Features["fp6bf6-cvt-scale-insts"] = true;
665 Features["fp8e5m3-insts"] = true;
666 Features["fp8-conversion-insts"] = true;
667 Features["fp8-cvt-scale-insts"] = true;
668 Features["fp8-insts"] = true;
669 Features["gfx8-insts"] = true;
670 Features["gfx9-insts"] = true;
671 Features["gfx90a-insts"] = true;
672 Features["gfx940-insts"] = true;
673 Features["gfx950-insts"] = true;
674 Features["gfx10-insts"] = true;
675 Features["gfx10-3-insts"] = true;
676 Features["gfx11-insts"] = true;
677 Features["gfx12-insts"] = true;
678 Features["gfx1250-insts"] = true;
679 Features["gws"] = true;
680 Features["image-insts"] = true;
681 Features["mai-insts"] = true;
682 Features["permlane16-swap"] = true;
683 Features["permlane32-swap"] = true;
684 Features["prng-inst"] = true;
685 Features["setprio-inc-wg-inst"] = true;
686 Features["s-memrealtime"] = true;
687 Features["s-memtime-inst"] = true;
688 Features["tanh-insts"] = true;
689 Features["tensor-cvt-lut-insts"] = true;
690 Features["transpose-load-f4f6-insts"] = true;
691 Features["vmem-pref-insts"] = true;
692 Features["vmem-to-lds-load-insts"] = true;
693 Features["wavefrontsize32"] = true;
694 Features["wavefrontsize64"] = true;
695 } else if (T.isAMDGCN()) {
696 StringMap<bool> DefaultFeatures;
697 fillAMDGCNFeatureMap(GPU, T, DefaultFeatures);
698 return insertWaveSizeFeature(GPU, T, DefaultFeatures, Features);
699 } else {
700 if (GPU.empty())
701 GPU = "r600";
702
703 switch (llvm::AMDGPU::parseArchR600(GPU)) {
704 case GK_CAYMAN:
705 case GK_CYPRESS:
706 case GK_RV770:
707 case GK_RV670:
708 // TODO: Add fp64 when implemented.
709 break;
710 case GK_TURKS:
711 case GK_CAICOS:
712 case GK_BARTS:
713 case GK_SUMO:
714 case GK_REDWOOD:
715 case GK_JUNIPER:
716 case GK_CEDAR:
717 case GK_RV730:
718 case GK_RV710:
719 case GK_RS880:
720 case GK_R630:
721 case GK_R600:
722 break;
723 default:
724 llvm_unreachable("Unhandled GPU!");
725 }
726 }
727 return {NO_ERROR, StringRef()};
728}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define F(x, y, z)
Definition MD5.cpp:54
#define T
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static void fillAMDGCNFeatureMap(StringRef GPU, const Triple &T, StringMap< bool > &Features)
Fills Features map with default values for given target GPU.
static void setImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies, ArrayRef< BasicSubtargetFeatureKV > FeatureTable)
For each feature that is (transitively) implied by this feature, set it.
static std::pair< FeatureError, StringRef > insertWaveSizeFeature(StringRef GPU, const Triple &T, const StringMap< bool > &DefaultFeatures, StringMap< bool > &Features)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
const FeatureBitset & getAsBitset() const
Container class for subtarget features.
constexpr bool test(unsigned I) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
iterator end()
Definition StringMap.h:224
iterator find(StringRef Key)
Definition StringMap.h:237
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition StringMap.h:285
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition StringMap.h:321
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:140
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
Definition StringRef.h:600
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition StringRef.h:290
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition StringRef.h:270
StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
Definition StringRef.h:636
A switch()-like statement whose cases are string literals.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI StringRef getArchNameR600(GPUKind AK)
GPUKind
GPU kinds supported by the AMDGPU target.
LLVM_ABI StringRef getCanonicalArchName(const Triple &T, StringRef Arch)
LLVM_ABI void fillValidArchListR600(SmallVectorImpl< StringRef > &Values)
LLVM_ABI StringRef getArchFamilyNameAMDGCN(GPUKind AK)
LLVM_ABI IsaVersion getIsaVersion(StringRef GPU)
LLVM_ABI void fillValidArchListAMDGCN(SmallVectorImpl< StringRef > &Values)
LLVM_ABI GPUKind parseArchAMDGCN(StringRef CPU)
@ UNSUPPORTED_TARGET_FEATURE
@ INVALID_FEATURE_COMBINATION
LLVM_ABI std::pair< FeatureError, StringRef > fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, StringMap< bool > &Features)
Fills Features map with default values for given target GPU.
LLVM_ABI StringRef getArchNameAMDGCN(GPUKind AK)
LLVM_ABI unsigned getArchAttrAMDGCN(GPUKind AK)
LLVM_ABI unsigned getArchAttrR600(GPUKind AK)
LLVM_ABI GPUKind parseArchR600(StringRef CPU)
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1765
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Definition STLExtras.h:2052
LLVM_ABI std::optional< llvm::StringMap< bool > > getCPUDefaultTargetFeatures(StringRef CPU, ArrayRef< BasicSubtargetSubTypeKV > ProcDesc, ArrayRef< BasicSubtargetFeatureKV > ProcFeatures)
Instruction set architecture version.
Used to provide key value pairs for feature and CPU bit flags.
FeatureBitArray Implies
K-V bit mask.