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 Features["ci-insts"] = true;
344 Features["dot7-insts"] = true;
345 Features["dot8-insts"] = true;
346 Features["dot9-insts"] = true;
347 Features["dot10-insts"] = true;
348 Features["dot12-insts"] = true;
349 Features["dl-insts"] = true;
350 Features["16-bit-insts"] = true;
351 Features["dpp"] = true;
352 Features["gfx8-insts"] = true;
353 Features["gfx9-insts"] = true;
354 Features["gfx10-insts"] = true;
355 Features["gfx10-3-insts"] = true;
356 Features["gfx11-insts"] = true;
357 Features["atomic-fadd-rtn-insts"] = true;
358 Features["image-insts"] = true;
359 Features["cube-insts"] = true;
360 Features["lerp-inst"] = true;
361 Features["sad-insts"] = true;
362 Features["qsad-insts"] = true;
363 Features["cvt-pknorm-vop2-insts"] = true;
364 Features["gws"] = true;
365 Features["dot11-insts"] = true;
366 Features["fp8-conversion-insts"] = true;
367 Features["wmma-128b-insts"] = true;
368 Features["swmmac-gfx1200-insts"] = true;
369 Features["atomic-fmin-fmax-global-f32"] = true;
370 break;
371 case GK_GFX1153:
372 case GK_GFX1152:
373 case GK_GFX1151:
374 case GK_GFX1150:
375 case GK_GFX1103:
376 case GK_GFX1102:
377 case GK_GFX1101:
378 case GK_GFX1100:
379 case GK_GFX11_GENERIC:
380 Features["ci-insts"] = true;
381 Features["dot5-insts"] = true;
382 Features["dot7-insts"] = true;
383 Features["dot8-insts"] = true;
384 Features["dot9-insts"] = true;
385 Features["dot10-insts"] = true;
386 Features["dot12-insts"] = true;
387 Features["dl-insts"] = true;
388 Features["16-bit-insts"] = true;
389 Features["dpp"] = true;
390 Features["gfx8-insts"] = true;
391 Features["gfx9-insts"] = true;
392 Features["gfx10-insts"] = true;
393 Features["gfx10-3-insts"] = true;
394 Features["gfx11-insts"] = true;
395 Features["atomic-fadd-rtn-insts"] = true;
396 Features["image-insts"] = true;
397 Features["cube-insts"] = true;
398 Features["lerp-inst"] = true;
399 Features["sad-insts"] = true;
400 Features["qsad-insts"] = true;
401 Features["cvt-pknorm-vop2-insts"] = true;
402 Features["gws"] = true;
403 Features["wmma-256b-insts"] = true;
404 Features["atomic-fmin-fmax-global-f32"] = true;
405 break;
406 case GK_GFX1036:
407 case GK_GFX1035:
408 case GK_GFX1034:
409 case GK_GFX1033:
410 case GK_GFX1032:
411 case GK_GFX1031:
412 case GK_GFX1030:
413 case GK_GFX10_3_GENERIC:
414 Features["ci-insts"] = true;
415 Features["dot1-insts"] = true;
416 Features["dot2-insts"] = true;
417 Features["dot5-insts"] = true;
418 Features["dot6-insts"] = true;
419 Features["dot7-insts"] = true;
420 Features["dot10-insts"] = true;
421 Features["dl-insts"] = true;
422 Features["16-bit-insts"] = true;
423 Features["dpp"] = true;
424 Features["gfx8-insts"] = true;
425 Features["gfx9-insts"] = true;
426 Features["gfx10-insts"] = true;
427 Features["gfx10-3-insts"] = true;
428 Features["image-insts"] = true;
429 Features["s-memrealtime"] = true;
430 Features["s-memtime-inst"] = true;
431 Features["gws"] = true;
432 Features["vmem-to-lds-load-insts"] = true;
433 Features["atomic-fmin-fmax-global-f32"] = true;
434 Features["atomic-fmin-fmax-global-f64"] = true;
435 Features["cube-insts"] = true;
436 Features["lerp-inst"] = true;
437 Features["sad-insts"] = true;
438 Features["qsad-insts"] = true;
439 Features["cvt-pknorm-vop2-insts"] = true;
440 break;
441 case GK_GFX1012:
442 case GK_GFX1011:
443 Features["dot1-insts"] = true;
444 Features["dot2-insts"] = true;
445 Features["dot5-insts"] = true;
446 Features["dot6-insts"] = true;
447 Features["dot7-insts"] = true;
448 Features["dot10-insts"] = true;
449 [[fallthrough]];
450 case GK_GFX1013:
451 case GK_GFX1010:
452 case GK_GFX10_1_GENERIC:
453 Features["dl-insts"] = true;
454 Features["ci-insts"] = true;
455 Features["16-bit-insts"] = true;
456 Features["dpp"] = true;
457 Features["gfx8-insts"] = true;
458 Features["gfx9-insts"] = true;
459 Features["gfx10-insts"] = true;
460 Features["image-insts"] = true;
461 Features["s-memrealtime"] = true;
462 Features["s-memtime-inst"] = true;
463 Features["gws"] = true;
464 Features["vmem-to-lds-load-insts"] = true;
465 Features["atomic-fmin-fmax-global-f32"] = true;
466 Features["atomic-fmin-fmax-global-f64"] = true;
467 Features["cube-insts"] = true;
468 Features["lerp-inst"] = true;
469 Features["sad-insts"] = true;
470 Features["qsad-insts"] = true;
471 Features["cvt-pknorm-vop2-insts"] = true;
472 break;
473 case GK_GFX950:
474 Features["bitop3-insts"] = true;
475 Features["fp6bf6-cvt-scale-insts"] = true;
476 Features["fp4-cvt-scale-insts"] = true;
477 Features["bf8-cvt-scale-insts"] = true;
478 Features["fp8-cvt-scale-insts"] = true;
479 Features["f16bf16-to-fp6bf6-cvt-scale-insts"] = true;
480 Features["f32-to-f16bf16-cvt-sr-insts"] = true;
481 Features["prng-inst"] = true;
482 Features["permlane16-swap"] = true;
483 Features["permlane32-swap"] = true;
484 Features["ashr-pk-insts"] = true;
485 Features["dot12-insts"] = true;
486 Features["dot13-insts"] = true;
487 Features["atomic-buffer-pk-add-bf16-inst"] = true;
488 Features["gfx950-insts"] = true;
489 [[fallthrough]];
490 case GK_GFX942:
491 Features["fp8-insts"] = true;
492 Features["fp8-conversion-insts"] = true;
493 if (Kind != GK_GFX950)
494 Features["xf32-insts"] = true;
495 [[fallthrough]];
496 case GK_GFX9_4_GENERIC:
497 Features["gfx940-insts"] = true;
498 Features["atomic-ds-pk-add-16-insts"] = true;
499 Features["atomic-flat-pk-add-16-insts"] = true;
500 Features["atomic-global-pk-add-bf16-inst"] = true;
501 Features["gfx90a-insts"] = true;
502 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
503 Features["atomic-fadd-rtn-insts"] = true;
504 Features["dot3-insts"] = true;
505 Features["dot4-insts"] = true;
506 Features["dot5-insts"] = true;
507 Features["dot6-insts"] = true;
508 Features["mai-insts"] = true;
509 Features["dl-insts"] = true;
510 Features["dot1-insts"] = true;
511 Features["dot2-insts"] = true;
512 Features["dot7-insts"] = true;
513 Features["dot10-insts"] = true;
514 Features["gfx9-insts"] = true;
515 Features["gfx8-insts"] = true;
516 Features["16-bit-insts"] = true;
517 Features["dpp"] = true;
518 Features["s-memrealtime"] = true;
519 Features["ci-insts"] = true;
520 Features["s-memtime-inst"] = true;
521 Features["gws"] = true;
522 Features["vmem-to-lds-load-insts"] = true;
523 Features["atomic-fmin-fmax-global-f64"] = true;
524 Features["wavefrontsize64"] = true;
525 Features["cube-insts"] = true;
526 Features["lerp-inst"] = true;
527 Features["sad-insts"] = true;
528 Features["qsad-insts"] = true;
529 Features["cvt-pknorm-vop2-insts"] = true;
530 break;
531 case GK_GFX90A:
532 Features["gfx90a-insts"] = true;
533 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
534 Features["atomic-fadd-rtn-insts"] = true;
535 Features["atomic-fmin-fmax-global-f64"] = true;
536 [[fallthrough]];
537 case GK_GFX908:
538 Features["dot3-insts"] = true;
539 Features["dot4-insts"] = true;
540 Features["dot5-insts"] = true;
541 Features["dot6-insts"] = true;
542 Features["mai-insts"] = true;
543 [[fallthrough]];
544 case GK_GFX906:
545 Features["dl-insts"] = true;
546 Features["dot1-insts"] = true;
547 Features["dot2-insts"] = true;
548 Features["dot7-insts"] = true;
549 Features["dot10-insts"] = true;
550 [[fallthrough]];
551 case GK_GFX90C:
552 case GK_GFX909:
553 case GK_GFX904:
554 case GK_GFX902:
555 case GK_GFX900:
556 case GK_GFX9_GENERIC:
557 Features["gfx9-insts"] = true;
558 Features["vmem-to-lds-load-insts"] = true;
559 [[fallthrough]];
560 case GK_GFX810:
561 case GK_GFX805:
562 case GK_GFX803:
563 case GK_GFX802:
564 case GK_GFX801:
565 Features["gfx8-insts"] = true;
566 Features["16-bit-insts"] = true;
567 Features["dpp"] = true;
568 Features["s-memrealtime"] = true;
569 Features["ci-insts"] = true;
570 Features["image-insts"] = true;
571 Features["s-memtime-inst"] = true;
572 Features["gws"] = true;
573 Features["wavefrontsize64"] = true;
574 Features["cube-insts"] = true;
575 Features["lerp-inst"] = true;
576 Features["sad-insts"] = true;
577 Features["qsad-insts"] = true;
578 Features["cvt-pknorm-vop2-insts"] = true;
579 break;
580 case GK_GFX705:
581 case GK_GFX704:
582 case GK_GFX703:
583 case GK_GFX702:
584 case GK_GFX701:
585 case GK_GFX700:
586 Features["ci-insts"] = true;
587 Features["cube-insts"] = true;
588 Features["lerp-inst"] = true;
589 Features["sad-insts"] = true;
590 Features["qsad-insts"] = true;
591 Features["cvt-pknorm-vop2-insts"] = true;
592 Features["image-insts"] = true;
593 Features["s-memtime-inst"] = true;
594 Features["gws"] = true;
595 Features["atomic-fmin-fmax-global-f32"] = true;
596 Features["atomic-fmin-fmax-global-f64"] = true;
597 Features["wavefrontsize64"] = true;
598 break;
599 case GK_GFX602:
600 case GK_GFX601:
601 case GK_GFX600:
602 Features["image-insts"] = true;
603 Features["s-memtime-inst"] = true;
604 Features["gws"] = true;
605 Features["atomic-fmin-fmax-global-f32"] = true;
606 Features["atomic-fmin-fmax-global-f64"] = true;
607 Features["wavefrontsize64"] = true;
608 Features["cube-insts"] = true;
609 Features["lerp-inst"] = true;
610 Features["sad-insts"] = true;
611 Features["cvt-pknorm-vop2-insts"] = true;
612 break;
613 case GK_NONE:
614 break;
615 default:
616 llvm_unreachable("Unhandled GPU!");
617 }
618}
619
620/// Fills Features map with default values for given target GPU.
621/// \p Features contains overriding target features and this function returns
622/// default target features with entries overridden by \p Features.
623std::pair<FeatureError, StringRef>
625 StringMap<bool> &Features) {
626 // XXX - What does the member GPU mean if device name string passed here?
627 if (T.isSPIRV() && T.getOS() == Triple::OSType::AMDHSA) {
628 // AMDGCN SPIRV must support the union of all AMDGCN features. This list
629 // should be kept in sorted order and updated whenever new features are
630 // added.
631 Features["16-bit-insts"] = true;
632 Features["ashr-pk-insts"] = true;
633 Features["atomic-buffer-pk-add-bf16-inst"] = true;
634 Features["atomic-buffer-global-pk-add-f16-insts"] = true;
635 Features["atomic-ds-pk-add-16-insts"] = true;
636 Features["atomic-fadd-rtn-insts"] = true;
637 Features["atomic-flat-pk-add-16-insts"] = true;
638 Features["atomic-global-pk-add-bf16-inst"] = true;
639 Features["bf16-trans-insts"] = true;
640 Features["bf16-cvt-insts"] = true;
641 Features["bf8-cvt-scale-insts"] = true;
642 Features["bitop3-insts"] = true;
643 Features["ci-insts"] = true;
644 Features["dl-insts"] = true;
645 Features["dot1-insts"] = true;
646 Features["dot2-insts"] = true;
647 Features["dot3-insts"] = true;
648 Features["dot4-insts"] = true;
649 Features["dot5-insts"] = true;
650 Features["dot6-insts"] = true;
651 Features["dot7-insts"] = true;
652 Features["dot8-insts"] = true;
653 Features["dot9-insts"] = true;
654 Features["dot10-insts"] = true;
655 Features["dot11-insts"] = true;
656 Features["dot12-insts"] = true;
657 Features["dot13-insts"] = true;
658 Features["dpp"] = true;
659 Features["f16bf16-to-fp6bf6-cvt-scale-insts"] = true;
660 Features["f32-to-f16bf16-cvt-sr-insts"] = true;
661 Features["fp4-cvt-scale-insts"] = true;
662 Features["fp6bf6-cvt-scale-insts"] = true;
663 Features["fp8e5m3-insts"] = true;
664 Features["fp8-conversion-insts"] = true;
665 Features["fp8-cvt-scale-insts"] = true;
666 Features["fp8-insts"] = true;
667 Features["gfx8-insts"] = true;
668 Features["gfx9-insts"] = true;
669 Features["gfx90a-insts"] = true;
670 Features["gfx940-insts"] = true;
671 Features["gfx950-insts"] = true;
672 Features["gfx10-insts"] = true;
673 Features["gfx10-3-insts"] = true;
674 Features["gfx11-insts"] = true;
675 Features["gfx12-insts"] = true;
676 Features["gfx1250-insts"] = true;
677 Features["gws"] = true;
678 Features["image-insts"] = true;
679 Features["mai-insts"] = true;
680 Features["permlane16-swap"] = true;
681 Features["permlane32-swap"] = true;
682 Features["prng-inst"] = true;
683 Features["setprio-inc-wg-inst"] = true;
684 Features["s-memrealtime"] = true;
685 Features["s-memtime-inst"] = true;
686 Features["tanh-insts"] = true;
687 Features["tensor-cvt-lut-insts"] = true;
688 Features["transpose-load-f4f6-insts"] = true;
689 Features["vmem-pref-insts"] = true;
690 Features["vmem-to-lds-load-insts"] = true;
691 Features["wavefrontsize32"] = true;
692 Features["wavefrontsize64"] = true;
693 } else if (T.isAMDGCN()) {
694 StringMap<bool> DefaultFeatures;
695 fillAMDGCNFeatureMap(GPU, T, DefaultFeatures);
696 return insertWaveSizeFeature(GPU, T, DefaultFeatures, Features);
697 } else {
698 if (GPU.empty())
699 GPU = "r600";
700
701 switch (llvm::AMDGPU::parseArchR600(GPU)) {
702 case GK_CAYMAN:
703 case GK_CYPRESS:
704 case GK_RV770:
705 case GK_RV670:
706 // TODO: Add fp64 when implemented.
707 break;
708 case GK_TURKS:
709 case GK_CAICOS:
710 case GK_BARTS:
711 case GK_SUMO:
712 case GK_REDWOOD:
713 case GK_JUNIPER:
714 case GK_CEDAR:
715 case GK_RV730:
716 case GK_RV710:
717 case GK_RS880:
718 case GK_R630:
719 case GK_R600:
720 break;
721 default:
722 llvm_unreachable("Unhandled GPU!");
723 }
724 }
725 return {NO_ERROR, StringRef()};
726}
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.
Definition Types.h:26
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.