| 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|FEATURE_XNACK_ALWAYS}, |
| 178 | {.Name: {"gfx1251" }, .CanonicalName: {"gfx1251" }, .Kind: GK_GFX1251, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK_ALWAYS}, |
| 179 | {.Name: {"gfx1310" }, .CanonicalName: {"gfx1310" }, .Kind: GK_GFX1310, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
| 180 | |
| 181 | {.Name: {"gfx9-generic" }, .CanonicalName: {"gfx9-generic" }, .Kind: GK_GFX9_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, |
| 182 | {.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}, |
| 183 | {.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}, |
| 184 | {.Name: {"gfx11-generic" }, .CanonicalName: {"gfx11-generic" }, .Kind: GK_GFX11_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
| 185 | {.Name: {"gfx12-generic" }, .CanonicalName: {"gfx12-generic" }, .Kind: GK_GFX12_GENERIC, .Features: FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, |
| 186 | {.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}, |
| 187 | // clang-format on |
| 188 | }; |
| 189 | |
| 190 | const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef<GPUInfo> Table) { |
| 191 | GPUInfo Search = { .Name: {"" }, .CanonicalName: {"" }, .Kind: AK, .Features: AMDGPU::FEATURE_NONE }; |
| 192 | |
| 193 | auto I = |
| 194 | llvm::lower_bound(Range&: Table, Value&: Search, C: [](const GPUInfo &A, const GPUInfo &B) { |
| 195 | return A.Kind < B.Kind; |
| 196 | }); |
| 197 | |
| 198 | if (I == Table.end() || I->Kind != Search.Kind) |
| 199 | return nullptr; |
| 200 | return I; |
| 201 | } |
| 202 | |
| 203 | } // namespace |
| 204 | |
| 205 | StringRef llvm::AMDGPU::getArchFamilyNameAMDGCN(GPUKind AK) { |
| 206 | switch (AK) { |
| 207 | case AMDGPU::GK_GFX9_GENERIC: |
| 208 | case AMDGPU::GK_GFX9_4_GENERIC: |
| 209 | return "gfx9" ; |
| 210 | case AMDGPU::GK_GFX10_1_GENERIC: |
| 211 | case AMDGPU::GK_GFX10_3_GENERIC: |
| 212 | return "gfx10" ; |
| 213 | case AMDGPU::GK_GFX11_GENERIC: |
| 214 | return "gfx11" ; |
| 215 | case AMDGPU::GK_GFX12_GENERIC: |
| 216 | return "gfx12" ; |
| 217 | default: { |
| 218 | StringRef ArchName = getArchNameAMDGCN(AK); |
| 219 | return ArchName.empty() ? "" : ArchName.drop_back(N: 2); |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | StringRef llvm::AMDGPU::getArchNameAMDGCN(GPUKind AK) { |
| 225 | if (const auto *Entry = getArchEntry(AK, Table: AMDGCNGPUs)) |
| 226 | return Entry->CanonicalName; |
| 227 | return "" ; |
| 228 | } |
| 229 | |
| 230 | StringRef llvm::AMDGPU::getArchNameR600(GPUKind AK) { |
| 231 | if (const auto *Entry = getArchEntry(AK, Table: R600GPUs)) |
| 232 | return Entry->CanonicalName; |
| 233 | return "" ; |
| 234 | } |
| 235 | |
| 236 | AMDGPU::GPUKind llvm::AMDGPU::parseArchAMDGCN(StringRef CPU) { |
| 237 | for (const auto &C : AMDGCNGPUs) { |
| 238 | if (CPU == C.Name) |
| 239 | return C.Kind; |
| 240 | } |
| 241 | |
| 242 | return AMDGPU::GPUKind::GK_NONE; |
| 243 | } |
| 244 | |
| 245 | AMDGPU::GPUKind llvm::AMDGPU::parseArchR600(StringRef CPU) { |
| 246 | for (const auto &C : R600GPUs) { |
| 247 | if (CPU == C.Name) |
| 248 | return C.Kind; |
| 249 | } |
| 250 | |
| 251 | return AMDGPU::GPUKind::GK_NONE; |
| 252 | } |
| 253 | |
| 254 | unsigned AMDGPU::getArchAttrAMDGCN(GPUKind AK) { |
| 255 | if (const auto *Entry = getArchEntry(AK, Table: AMDGCNGPUs)) |
| 256 | return Entry->Features; |
| 257 | return FEATURE_NONE; |
| 258 | } |
| 259 | |
| 260 | unsigned AMDGPU::getArchAttrR600(GPUKind AK) { |
| 261 | if (const auto *Entry = getArchEntry(AK, Table: R600GPUs)) |
| 262 | return Entry->Features; |
| 263 | return FEATURE_NONE; |
| 264 | } |
| 265 | |
| 266 | void AMDGPU::fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values) { |
| 267 | // XXX: Should this only report unique canonical names? |
| 268 | for (const auto &C : AMDGCNGPUs) |
| 269 | Values.push_back(Elt: C.Name); |
| 270 | } |
| 271 | |
| 272 | void AMDGPU::fillValidArchListR600(SmallVectorImpl<StringRef> &Values) { |
| 273 | for (const auto &C : R600GPUs) |
| 274 | Values.push_back(Elt: C.Name); |
| 275 | } |
| 276 | |
| 277 | AMDGPU::IsaVersion AMDGPU::getIsaVersion(StringRef GPU) { |
| 278 | AMDGPU::GPUKind AK = parseArchAMDGCN(CPU: GPU); |
| 279 | if (AK == AMDGPU::GPUKind::GK_NONE) { |
| 280 | if (GPU == "generic-hsa" ) |
| 281 | return {.Major: 7, .Minor: 0, .Stepping: 0}; |
| 282 | if (GPU == "generic" ) |
| 283 | return {.Major: 6, .Minor: 0, .Stepping: 0}; |
| 284 | return {.Major: 0, .Minor: 0, .Stepping: 0}; |
| 285 | } |
| 286 | |
| 287 | // clang-format off |
| 288 | switch (AK) { |
| 289 | case GK_GFX600: return {.Major: 6, .Minor: 0, .Stepping: 0}; |
| 290 | case GK_GFX601: return {.Major: 6, .Minor: 0, .Stepping: 1}; |
| 291 | case GK_GFX602: return {.Major: 6, .Minor: 0, .Stepping: 2}; |
| 292 | case GK_GFX700: return {.Major: 7, .Minor: 0, .Stepping: 0}; |
| 293 | case GK_GFX701: return {.Major: 7, .Minor: 0, .Stepping: 1}; |
| 294 | case GK_GFX702: return {.Major: 7, .Minor: 0, .Stepping: 2}; |
| 295 | case GK_GFX703: return {.Major: 7, .Minor: 0, .Stepping: 3}; |
| 296 | case GK_GFX704: return {.Major: 7, .Minor: 0, .Stepping: 4}; |
| 297 | case GK_GFX705: return {.Major: 7, .Minor: 0, .Stepping: 5}; |
| 298 | case GK_GFX801: return {.Major: 8, .Minor: 0, .Stepping: 1}; |
| 299 | case GK_GFX802: return {.Major: 8, .Minor: 0, .Stepping: 2}; |
| 300 | case GK_GFX803: return {.Major: 8, .Minor: 0, .Stepping: 3}; |
| 301 | case GK_GFX805: return {.Major: 8, .Minor: 0, .Stepping: 5}; |
| 302 | case GK_GFX810: return {.Major: 8, .Minor: 1, .Stepping: 0}; |
| 303 | case GK_GFX900: return {.Major: 9, .Minor: 0, .Stepping: 0}; |
| 304 | case GK_GFX902: return {.Major: 9, .Minor: 0, .Stepping: 2}; |
| 305 | case GK_GFX904: return {.Major: 9, .Minor: 0, .Stepping: 4}; |
| 306 | case GK_GFX906: return {.Major: 9, .Minor: 0, .Stepping: 6}; |
| 307 | case GK_GFX908: return {.Major: 9, .Minor: 0, .Stepping: 8}; |
| 308 | case GK_GFX909: return {.Major: 9, .Minor: 0, .Stepping: 9}; |
| 309 | case GK_GFX90A: return {.Major: 9, .Minor: 0, .Stepping: 10}; |
| 310 | case GK_GFX90C: return {.Major: 9, .Minor: 0, .Stepping: 12}; |
| 311 | case GK_GFX942: return {.Major: 9, .Minor: 4, .Stepping: 2}; |
| 312 | case GK_GFX950: return {.Major: 9, .Minor: 5, .Stepping: 0}; |
| 313 | case GK_GFX1010: return {.Major: 10, .Minor: 1, .Stepping: 0}; |
| 314 | case GK_GFX1011: return {.Major: 10, .Minor: 1, .Stepping: 1}; |
| 315 | case GK_GFX1012: return {.Major: 10, .Minor: 1, .Stepping: 2}; |
| 316 | case GK_GFX1013: return {.Major: 10, .Minor: 1, .Stepping: 3}; |
| 317 | case GK_GFX1030: return {.Major: 10, .Minor: 3, .Stepping: 0}; |
| 318 | case GK_GFX1031: return {.Major: 10, .Minor: 3, .Stepping: 1}; |
| 319 | case GK_GFX1032: return {.Major: 10, .Minor: 3, .Stepping: 2}; |
| 320 | case GK_GFX1033: return {.Major: 10, .Minor: 3, .Stepping: 3}; |
| 321 | case GK_GFX1034: return {.Major: 10, .Minor: 3, .Stepping: 4}; |
| 322 | case GK_GFX1035: return {.Major: 10, .Minor: 3, .Stepping: 5}; |
| 323 | case GK_GFX1036: return {.Major: 10, .Minor: 3, .Stepping: 6}; |
| 324 | case GK_GFX1100: return {.Major: 11, .Minor: 0, .Stepping: 0}; |
| 325 | case GK_GFX1101: return {.Major: 11, .Minor: 0, .Stepping: 1}; |
| 326 | case GK_GFX1102: return {.Major: 11, .Minor: 0, .Stepping: 2}; |
| 327 | case GK_GFX1103: return {.Major: 11, .Minor: 0, .Stepping: 3}; |
| 328 | case GK_GFX1150: return {.Major: 11, .Minor: 5, .Stepping: 0}; |
| 329 | case GK_GFX1151: return {.Major: 11, .Minor: 5, .Stepping: 1}; |
| 330 | case GK_GFX1152: return {.Major: 11, .Minor: 5, .Stepping: 2}; |
| 331 | case GK_GFX1153: return {.Major: 11, .Minor: 5, .Stepping: 3}; |
| 332 | case GK_GFX1200: return {.Major: 12, .Minor: 0, .Stepping: 0}; |
| 333 | case GK_GFX1201: return {.Major: 12, .Minor: 0, .Stepping: 1}; |
| 334 | case GK_GFX1250: return {.Major: 12, .Minor: 5, .Stepping: 0}; |
| 335 | case GK_GFX1251: return {.Major: 12, .Minor: 5, .Stepping: 1}; |
| 336 | case GK_GFX1310: return {.Major: 13, .Minor: 1, .Stepping: 0}; |
| 337 | |
| 338 | // Generic targets return the lowest common denominator |
| 339 | // within their family. That is, the ISA that is the most |
| 340 | // restricted in terms of features. |
| 341 | // |
| 342 | // gfx9-generic is tricky because there is no lowest |
| 343 | // common denominator, so we return gfx900 which has mad-mix |
| 344 | // but this family doesn't have it. |
| 345 | // |
| 346 | // This API should never be used to check for a particular |
| 347 | // feature anyway. |
| 348 | // |
| 349 | // TODO: Split up this API depending on its caller so |
| 350 | // generic target handling is more obvious and less risky. |
| 351 | case GK_GFX9_GENERIC: return {.Major: 9, .Minor: 0, .Stepping: 0}; |
| 352 | case GK_GFX9_4_GENERIC: return {.Major: 9, .Minor: 4, .Stepping: 0}; |
| 353 | case GK_GFX10_1_GENERIC: return {.Major: 10, .Minor: 1, .Stepping: 0}; |
| 354 | case GK_GFX10_3_GENERIC: return {.Major: 10, .Minor: 3, .Stepping: 0}; |
| 355 | case GK_GFX11_GENERIC: return {.Major: 11, .Minor: 0, .Stepping: 3}; |
| 356 | case GK_GFX12_GENERIC: return {.Major: 12, .Minor: 0, .Stepping: 0}; |
| 357 | default: return {.Major: 0, .Minor: 0, .Stepping: 0}; |
| 358 | } |
| 359 | // clang-format on |
| 360 | } |
| 361 | |
| 362 | StringRef AMDGPU::getCanonicalArchName(const Triple &T, StringRef Arch) { |
| 363 | assert(T.isAMDGPU()); |
| 364 | auto ProcKind = T.isAMDGCN() ? parseArchAMDGCN(CPU: Arch) : parseArchR600(CPU: Arch); |
| 365 | if (ProcKind == GK_NONE) |
| 366 | return StringRef(); |
| 367 | |
| 368 | return T.isAMDGCN() ? getArchNameAMDGCN(AK: ProcKind) : getArchNameR600(AK: ProcKind); |
| 369 | } |
| 370 | |
| 371 | static std::pair<FeatureError, StringRef> |
| 372 | insertWaveSizeFeature(StringRef GPU, const Triple &T, |
| 373 | const StringMap<bool> &DefaultFeatures, |
| 374 | StringMap<bool> &Features) { |
| 375 | const bool IsNullGPU = GPU.empty(); |
| 376 | const bool TargetHasWave32 = DefaultFeatures.count(Key: "wavefrontsize32" ); |
| 377 | const bool TargetHasWave64 = DefaultFeatures.count(Key: "wavefrontsize64" ); |
| 378 | |
| 379 | auto Wave32Itr = Features.find(Key: "wavefrontsize32" ); |
| 380 | auto Wave64Itr = Features.find(Key: "wavefrontsize64" ); |
| 381 | const bool EnableWave32 = |
| 382 | Wave32Itr != Features.end() && Wave32Itr->getValue(); |
| 383 | const bool EnableWave64 = |
| 384 | Wave64Itr != Features.end() && Wave64Itr->getValue(); |
| 385 | const bool DisableWave32 = |
| 386 | Wave32Itr != Features.end() && !Wave32Itr->getValue(); |
| 387 | const bool DisableWave64 = |
| 388 | Wave64Itr != Features.end() && !Wave64Itr->getValue(); |
| 389 | |
| 390 | if (EnableWave32 && EnableWave64) |
| 391 | return {AMDGPU::INVALID_FEATURE_COMBINATION, |
| 392 | "'+wavefrontsize32' and '+wavefrontsize64' are mutually exclusive" }; |
| 393 | if (DisableWave32 && DisableWave64) |
| 394 | return {AMDGPU::INVALID_FEATURE_COMBINATION, |
| 395 | "'-wavefrontsize32' and '-wavefrontsize64' are mutually exclusive" }; |
| 396 | |
| 397 | if (!IsNullGPU) { |
| 398 | if (TargetHasWave64) { |
| 399 | if (EnableWave32) |
| 400 | return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "+wavefrontsize32" }; |
| 401 | if (DisableWave64) |
| 402 | return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "-wavefrontsize64" }; |
| 403 | } |
| 404 | |
| 405 | if (TargetHasWave32) { |
| 406 | if (EnableWave64) |
| 407 | return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "+wavefrontsize64" }; |
| 408 | if (DisableWave32) |
| 409 | return {AMDGPU::UNSUPPORTED_TARGET_FEATURE, "-wavefrontsize32" }; |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | // Don't assume any wavesize with an unknown subtarget. |
| 414 | // Default to wave32 if target supports both. |
| 415 | if (!IsNullGPU && !EnableWave32 && !EnableWave64 && !TargetHasWave32 && |
| 416 | !TargetHasWave64) |
| 417 | Features.insert(KV: std::make_pair(x: "wavefrontsize32" , y: true)); |
| 418 | |
| 419 | for (const auto &Entry : DefaultFeatures) { |
| 420 | if (!Features.count(Key: Entry.getKey())) |
| 421 | Features[Entry.getKey()] = Entry.getValue(); |
| 422 | } |
| 423 | |
| 424 | return {NO_ERROR, StringRef()}; |
| 425 | } |
| 426 | |
| 427 | /// Fills Features map with default values for given target GPU. |
| 428 | /// \p Features contains overriding target features and this function returns |
| 429 | /// default target features with entries overridden by \p Features. |
| 430 | static void fillAMDGCNFeatureMap(StringRef GPU, const Triple &T, |
| 431 | StringMap<bool> &Features) { |
| 432 | AMDGPU::GPUKind Kind = parseArchAMDGCN(CPU: GPU); |
| 433 | switch (Kind) { |
| 434 | case GK_GFX1310: |
| 435 | case GK_GFX1251: |
| 436 | case GK_GFX1250: |
| 437 | Features["ci-insts" ] = true; |
| 438 | Features["dot7-insts" ] = true; |
| 439 | Features["dot8-insts" ] = true; |
| 440 | Features["dl-insts" ] = true; |
| 441 | Features["16-bit-insts" ] = true; |
| 442 | Features["dpp" ] = true; |
| 443 | Features["gfx8-insts" ] = true; |
| 444 | Features["gfx9-insts" ] = true; |
| 445 | Features["gfx10-insts" ] = true; |
| 446 | Features["gfx10-3-insts" ] = true; |
| 447 | Features["gfx11-insts" ] = true; |
| 448 | Features["gfx12-insts" ] = true; |
| 449 | Features["gfx1250-insts" ] = true; |
| 450 | Features["bitop3-insts" ] = true; |
| 451 | Features["prng-inst" ] = true; |
| 452 | Features["tanh-insts" ] = true; |
| 453 | Features["tensor-cvt-lut-insts" ] = true; |
| 454 | Features["transpose-load-f4f6-insts" ] = true; |
| 455 | Features["bf16-trans-insts" ] = true; |
| 456 | Features["bf16-cvt-insts" ] = true; |
| 457 | Features["bf16-pk-insts" ] = true; |
| 458 | Features["fp8-conversion-insts" ] = true; |
| 459 | Features["fp8e5m3-insts" ] = true; |
| 460 | Features["permlane16-swap" ] = true; |
| 461 | Features["ashr-pk-insts" ] = true; |
| 462 | Features["add-min-max-insts" ] = true; |
| 463 | Features["pk-add-min-max-insts" ] = true; |
| 464 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
| 465 | Features["vmem-pref-insts" ] = true; |
| 466 | Features["atomic-fadd-rtn-insts" ] = true; |
| 467 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
| 468 | Features["atomic-flat-pk-add-16-insts" ] = true; |
| 469 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
| 470 | Features["atomic-ds-pk-add-16-insts" ] = true; |
| 471 | Features["setprio-inc-wg-inst" ] = true; |
| 472 | Features["s-wakeup-barrier-inst" ] = true; |
| 473 | Features["atomic-fmin-fmax-global-f32" ] = true; |
| 474 | Features["atomic-fmin-fmax-global-f64" ] = true; |
| 475 | Features["wavefrontsize32" ] = true; |
| 476 | Features["clusters" ] = true; |
| 477 | Features["mcast-load-insts" ] = true; |
| 478 | Features["cube-insts" ] = true; |
| 479 | Features["lerp-inst" ] = true; |
| 480 | Features["sad-insts" ] = true; |
| 481 | Features["qsad-insts" ] = true; |
| 482 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 483 | break; |
| 484 | case GK_GFX1201: |
| 485 | case GK_GFX1200: |
| 486 | case GK_GFX12_GENERIC: |
| 487 | Features["ci-insts" ] = true; |
| 488 | Features["dot7-insts" ] = true; |
| 489 | Features["dot8-insts" ] = true; |
| 490 | Features["dot9-insts" ] = true; |
| 491 | Features["dot10-insts" ] = true; |
| 492 | Features["dot11-insts" ] = true; |
| 493 | Features["dot12-insts" ] = true; |
| 494 | Features["dl-insts" ] = true; |
| 495 | Features["atomic-ds-pk-add-16-insts" ] = true; |
| 496 | Features["atomic-flat-pk-add-16-insts" ] = true; |
| 497 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
| 498 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
| 499 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
| 500 | Features["16-bit-insts" ] = true; |
| 501 | Features["dpp" ] = true; |
| 502 | Features["gfx8-insts" ] = true; |
| 503 | Features["gfx9-insts" ] = true; |
| 504 | Features["gfx10-insts" ] = true; |
| 505 | Features["gfx10-3-insts" ] = true; |
| 506 | Features["gfx11-insts" ] = true; |
| 507 | Features["gfx12-insts" ] = true; |
| 508 | Features["atomic-fadd-rtn-insts" ] = true; |
| 509 | Features["image-insts" ] = true; |
| 510 | Features["cube-insts" ] = true; |
| 511 | Features["lerp-inst" ] = true; |
| 512 | Features["sad-insts" ] = true; |
| 513 | Features["qsad-insts" ] = true; |
| 514 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 515 | Features["fp8-conversion-insts" ] = true; |
| 516 | Features["atomic-fmin-fmax-global-f32" ] = true; |
| 517 | break; |
| 518 | case GK_GFX1153: |
| 519 | case GK_GFX1152: |
| 520 | case GK_GFX1151: |
| 521 | case GK_GFX1150: |
| 522 | case GK_GFX1103: |
| 523 | case GK_GFX1102: |
| 524 | case GK_GFX1101: |
| 525 | case GK_GFX1100: |
| 526 | case GK_GFX11_GENERIC: |
| 527 | Features["ci-insts" ] = true; |
| 528 | Features["dot5-insts" ] = true; |
| 529 | Features["dot7-insts" ] = true; |
| 530 | Features["dot8-insts" ] = true; |
| 531 | Features["dot9-insts" ] = true; |
| 532 | Features["dot10-insts" ] = true; |
| 533 | Features["dot12-insts" ] = true; |
| 534 | Features["dl-insts" ] = true; |
| 535 | Features["16-bit-insts" ] = true; |
| 536 | Features["dpp" ] = true; |
| 537 | Features["gfx8-insts" ] = true; |
| 538 | Features["gfx9-insts" ] = true; |
| 539 | Features["gfx10-insts" ] = true; |
| 540 | Features["gfx10-3-insts" ] = true; |
| 541 | Features["gfx11-insts" ] = true; |
| 542 | Features["atomic-fadd-rtn-insts" ] = true; |
| 543 | Features["image-insts" ] = true; |
| 544 | Features["cube-insts" ] = true; |
| 545 | Features["lerp-inst" ] = true; |
| 546 | Features["sad-insts" ] = true; |
| 547 | Features["qsad-insts" ] = true; |
| 548 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 549 | Features["gws" ] = true; |
| 550 | Features["atomic-fmin-fmax-global-f32" ] = true; |
| 551 | break; |
| 552 | case GK_GFX1036: |
| 553 | case GK_GFX1035: |
| 554 | case GK_GFX1034: |
| 555 | case GK_GFX1033: |
| 556 | case GK_GFX1032: |
| 557 | case GK_GFX1031: |
| 558 | case GK_GFX1030: |
| 559 | case GK_GFX10_3_GENERIC: |
| 560 | Features["ci-insts" ] = true; |
| 561 | Features["dot1-insts" ] = true; |
| 562 | Features["dot2-insts" ] = true; |
| 563 | Features["dot5-insts" ] = true; |
| 564 | Features["dot6-insts" ] = true; |
| 565 | Features["dot7-insts" ] = true; |
| 566 | Features["dot10-insts" ] = true; |
| 567 | Features["dl-insts" ] = true; |
| 568 | Features["16-bit-insts" ] = true; |
| 569 | Features["dpp" ] = true; |
| 570 | Features["gfx8-insts" ] = true; |
| 571 | Features["gfx9-insts" ] = true; |
| 572 | Features["gfx10-insts" ] = true; |
| 573 | Features["gfx10-3-insts" ] = true; |
| 574 | Features["image-insts" ] = true; |
| 575 | Features["s-memrealtime" ] = true; |
| 576 | Features["s-memtime-inst" ] = true; |
| 577 | Features["gws" ] = true; |
| 578 | Features["vmem-to-lds-load-insts" ] = true; |
| 579 | Features["atomic-fmin-fmax-global-f32" ] = true; |
| 580 | Features["atomic-fmin-fmax-global-f64" ] = true; |
| 581 | Features["cube-insts" ] = true; |
| 582 | Features["lerp-inst" ] = true; |
| 583 | Features["sad-insts" ] = true; |
| 584 | Features["qsad-insts" ] = true; |
| 585 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 586 | break; |
| 587 | case GK_GFX1012: |
| 588 | case GK_GFX1011: |
| 589 | Features["dot1-insts" ] = true; |
| 590 | Features["dot2-insts" ] = true; |
| 591 | Features["dot5-insts" ] = true; |
| 592 | Features["dot6-insts" ] = true; |
| 593 | Features["dot7-insts" ] = true; |
| 594 | Features["dot10-insts" ] = true; |
| 595 | [[fallthrough]]; |
| 596 | case GK_GFX1013: |
| 597 | case GK_GFX1010: |
| 598 | case GK_GFX10_1_GENERIC: |
| 599 | Features["dl-insts" ] = true; |
| 600 | Features["ci-insts" ] = true; |
| 601 | Features["16-bit-insts" ] = true; |
| 602 | Features["dpp" ] = true; |
| 603 | Features["gfx8-insts" ] = true; |
| 604 | Features["gfx9-insts" ] = true; |
| 605 | Features["gfx10-insts" ] = true; |
| 606 | Features["image-insts" ] = true; |
| 607 | Features["s-memrealtime" ] = true; |
| 608 | Features["s-memtime-inst" ] = true; |
| 609 | Features["gws" ] = true; |
| 610 | Features["vmem-to-lds-load-insts" ] = true; |
| 611 | Features["atomic-fmin-fmax-global-f32" ] = true; |
| 612 | Features["atomic-fmin-fmax-global-f64" ] = true; |
| 613 | Features["cube-insts" ] = true; |
| 614 | Features["lerp-inst" ] = true; |
| 615 | Features["sad-insts" ] = true; |
| 616 | Features["qsad-insts" ] = true; |
| 617 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 618 | break; |
| 619 | case GK_GFX950: |
| 620 | Features["bitop3-insts" ] = true; |
| 621 | Features["fp6bf6-cvt-scale-insts" ] = true; |
| 622 | Features["fp4-cvt-scale-insts" ] = true; |
| 623 | Features["bf8-cvt-scale-insts" ] = true; |
| 624 | Features["fp8-cvt-scale-insts" ] = true; |
| 625 | Features["f16bf16-to-fp6bf6-cvt-scale-insts" ] = true; |
| 626 | Features["f32-to-f16bf16-cvt-sr-insts" ] = true; |
| 627 | Features["prng-inst" ] = true; |
| 628 | Features["permlane16-swap" ] = true; |
| 629 | Features["permlane32-swap" ] = true; |
| 630 | Features["ashr-pk-insts" ] = true; |
| 631 | Features["dot12-insts" ] = true; |
| 632 | Features["dot13-insts" ] = true; |
| 633 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
| 634 | Features["gfx950-insts" ] = true; |
| 635 | [[fallthrough]]; |
| 636 | case GK_GFX942: |
| 637 | Features["fp8-insts" ] = true; |
| 638 | Features["fp8-conversion-insts" ] = true; |
| 639 | if (Kind != GK_GFX950) |
| 640 | Features["xf32-insts" ] = true; |
| 641 | [[fallthrough]]; |
| 642 | case GK_GFX9_4_GENERIC: |
| 643 | Features["gfx940-insts" ] = true; |
| 644 | Features["atomic-ds-pk-add-16-insts" ] = true; |
| 645 | Features["atomic-flat-pk-add-16-insts" ] = true; |
| 646 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
| 647 | Features["gfx90a-insts" ] = true; |
| 648 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
| 649 | Features["atomic-fadd-rtn-insts" ] = true; |
| 650 | Features["dot3-insts" ] = true; |
| 651 | Features["dot4-insts" ] = true; |
| 652 | Features["dot5-insts" ] = true; |
| 653 | Features["dot6-insts" ] = true; |
| 654 | Features["mai-insts" ] = true; |
| 655 | Features["dl-insts" ] = true; |
| 656 | Features["dot1-insts" ] = true; |
| 657 | Features["dot2-insts" ] = true; |
| 658 | Features["dot7-insts" ] = true; |
| 659 | Features["dot10-insts" ] = true; |
| 660 | Features["gfx9-insts" ] = true; |
| 661 | Features["gfx8-insts" ] = true; |
| 662 | Features["16-bit-insts" ] = true; |
| 663 | Features["dpp" ] = true; |
| 664 | Features["s-memrealtime" ] = true; |
| 665 | Features["ci-insts" ] = true; |
| 666 | Features["s-memtime-inst" ] = true; |
| 667 | Features["gws" ] = true; |
| 668 | Features["vmem-to-lds-load-insts" ] = true; |
| 669 | Features["atomic-fmin-fmax-global-f64" ] = true; |
| 670 | Features["wavefrontsize64" ] = true; |
| 671 | Features["cube-insts" ] = true; |
| 672 | Features["lerp-inst" ] = true; |
| 673 | Features["sad-insts" ] = true; |
| 674 | Features["qsad-insts" ] = true; |
| 675 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 676 | break; |
| 677 | case GK_GFX90A: |
| 678 | Features["gfx90a-insts" ] = true; |
| 679 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
| 680 | Features["atomic-fadd-rtn-insts" ] = true; |
| 681 | Features["atomic-fmin-fmax-global-f64" ] = true; |
| 682 | [[fallthrough]]; |
| 683 | case GK_GFX908: |
| 684 | Features["dot3-insts" ] = true; |
| 685 | Features["dot4-insts" ] = true; |
| 686 | Features["dot5-insts" ] = true; |
| 687 | Features["dot6-insts" ] = true; |
| 688 | Features["mai-insts" ] = true; |
| 689 | [[fallthrough]]; |
| 690 | case GK_GFX906: |
| 691 | Features["dl-insts" ] = true; |
| 692 | Features["dot1-insts" ] = true; |
| 693 | Features["dot2-insts" ] = true; |
| 694 | Features["dot7-insts" ] = true; |
| 695 | Features["dot10-insts" ] = true; |
| 696 | [[fallthrough]]; |
| 697 | case GK_GFX90C: |
| 698 | case GK_GFX909: |
| 699 | case GK_GFX904: |
| 700 | case GK_GFX902: |
| 701 | case GK_GFX900: |
| 702 | case GK_GFX9_GENERIC: |
| 703 | Features["gfx9-insts" ] = true; |
| 704 | Features["vmem-to-lds-load-insts" ] = true; |
| 705 | [[fallthrough]]; |
| 706 | case GK_GFX810: |
| 707 | case GK_GFX805: |
| 708 | case GK_GFX803: |
| 709 | case GK_GFX802: |
| 710 | case GK_GFX801: |
| 711 | Features["gfx8-insts" ] = true; |
| 712 | Features["16-bit-insts" ] = true; |
| 713 | Features["dpp" ] = true; |
| 714 | Features["s-memrealtime" ] = true; |
| 715 | Features["ci-insts" ] = true; |
| 716 | Features["image-insts" ] = true; |
| 717 | Features["s-memtime-inst" ] = true; |
| 718 | Features["gws" ] = true; |
| 719 | Features["wavefrontsize64" ] = true; |
| 720 | Features["cube-insts" ] = true; |
| 721 | Features["lerp-inst" ] = true; |
| 722 | Features["sad-insts" ] = true; |
| 723 | Features["qsad-insts" ] = true; |
| 724 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 725 | break; |
| 726 | case GK_GFX705: |
| 727 | case GK_GFX704: |
| 728 | case GK_GFX703: |
| 729 | case GK_GFX702: |
| 730 | case GK_GFX701: |
| 731 | case GK_GFX700: |
| 732 | Features["ci-insts" ] = true; |
| 733 | Features["cube-insts" ] = true; |
| 734 | Features["lerp-inst" ] = true; |
| 735 | Features["sad-insts" ] = true; |
| 736 | Features["qsad-insts" ] = true; |
| 737 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 738 | Features["image-insts" ] = true; |
| 739 | Features["s-memtime-inst" ] = true; |
| 740 | Features["gws" ] = true; |
| 741 | Features["atomic-fmin-fmax-global-f32" ] = true; |
| 742 | Features["atomic-fmin-fmax-global-f64" ] = true; |
| 743 | Features["wavefrontsize64" ] = true; |
| 744 | break; |
| 745 | case GK_GFX602: |
| 746 | case GK_GFX601: |
| 747 | case GK_GFX600: |
| 748 | Features["image-insts" ] = true; |
| 749 | Features["s-memtime-inst" ] = true; |
| 750 | Features["gws" ] = true; |
| 751 | Features["atomic-fmin-fmax-global-f32" ] = true; |
| 752 | Features["atomic-fmin-fmax-global-f64" ] = true; |
| 753 | Features["wavefrontsize64" ] = true; |
| 754 | Features["cube-insts" ] = true; |
| 755 | Features["lerp-inst" ] = true; |
| 756 | Features["sad-insts" ] = true; |
| 757 | Features["cvt-pknorm-vop2-insts" ] = true; |
| 758 | break; |
| 759 | case GK_NONE: |
| 760 | break; |
| 761 | default: |
| 762 | llvm_unreachable("Unhandled GPU!" ); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | /// Fills Features map with default values for given target GPU. |
| 767 | /// \p Features contains overriding target features and this function returns |
| 768 | /// default target features with entries overridden by \p Features. |
| 769 | std::pair<FeatureError, StringRef> |
| 770 | AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, |
| 771 | StringMap<bool> &Features) { |
| 772 | // XXX - What does the member GPU mean if device name string passed here? |
| 773 | if (T.isSPIRV() && T.getOS() == Triple::OSType::AMDHSA) { |
| 774 | // AMDGCN SPIRV must support the union of all AMDGCN features. This list |
| 775 | // should be kept in sorted order and updated whenever new features are |
| 776 | // added. |
| 777 | Features["16-bit-insts" ] = true; |
| 778 | Features["ashr-pk-insts" ] = true; |
| 779 | Features["atomic-buffer-pk-add-bf16-inst" ] = true; |
| 780 | Features["atomic-buffer-global-pk-add-f16-insts" ] = true; |
| 781 | Features["atomic-ds-pk-add-16-insts" ] = true; |
| 782 | Features["atomic-fadd-rtn-insts" ] = true; |
| 783 | Features["atomic-flat-pk-add-16-insts" ] = true; |
| 784 | Features["atomic-global-pk-add-bf16-inst" ] = true; |
| 785 | Features["bf16-trans-insts" ] = true; |
| 786 | Features["bf16-cvt-insts" ] = true; |
| 787 | Features["bf8-cvt-scale-insts" ] = true; |
| 788 | Features["bitop3-insts" ] = true; |
| 789 | Features["ci-insts" ] = true; |
| 790 | Features["dl-insts" ] = true; |
| 791 | Features["dot1-insts" ] = true; |
| 792 | Features["dot2-insts" ] = true; |
| 793 | Features["dot3-insts" ] = true; |
| 794 | Features["dot4-insts" ] = true; |
| 795 | Features["dot5-insts" ] = true; |
| 796 | Features["dot6-insts" ] = true; |
| 797 | Features["dot7-insts" ] = true; |
| 798 | Features["dot8-insts" ] = true; |
| 799 | Features["dot9-insts" ] = true; |
| 800 | Features["dot10-insts" ] = true; |
| 801 | Features["dot11-insts" ] = true; |
| 802 | Features["dot12-insts" ] = true; |
| 803 | Features["dot13-insts" ] = true; |
| 804 | Features["dpp" ] = true; |
| 805 | Features["f16bf16-to-fp6bf6-cvt-scale-insts" ] = true; |
| 806 | Features["f32-to-f16bf16-cvt-sr-insts" ] = true; |
| 807 | Features["fp4-cvt-scale-insts" ] = true; |
| 808 | Features["fp6bf6-cvt-scale-insts" ] = true; |
| 809 | Features["fp8e5m3-insts" ] = true; |
| 810 | Features["fp8-conversion-insts" ] = true; |
| 811 | Features["fp8-cvt-scale-insts" ] = true; |
| 812 | Features["fp8-insts" ] = true; |
| 813 | Features["gfx8-insts" ] = true; |
| 814 | Features["gfx9-insts" ] = true; |
| 815 | Features["gfx90a-insts" ] = true; |
| 816 | Features["gfx940-insts" ] = true; |
| 817 | Features["gfx950-insts" ] = true; |
| 818 | Features["gfx10-insts" ] = true; |
| 819 | Features["gfx10-3-insts" ] = true; |
| 820 | Features["gfx11-insts" ] = true; |
| 821 | Features["gfx12-insts" ] = true; |
| 822 | Features["gfx1250-insts" ] = true; |
| 823 | Features["gws" ] = true; |
| 824 | Features["image-insts" ] = true; |
| 825 | Features["mai-insts" ] = true; |
| 826 | Features["permlane16-swap" ] = true; |
| 827 | Features["permlane32-swap" ] = true; |
| 828 | Features["prng-inst" ] = true; |
| 829 | Features["setprio-inc-wg-inst" ] = true; |
| 830 | Features["s-memrealtime" ] = true; |
| 831 | Features["s-memtime-inst" ] = true; |
| 832 | Features["tanh-insts" ] = true; |
| 833 | Features["tensor-cvt-lut-insts" ] = true; |
| 834 | Features["transpose-load-f4f6-insts" ] = true; |
| 835 | Features["vmem-pref-insts" ] = true; |
| 836 | Features["vmem-to-lds-load-insts" ] = true; |
| 837 | Features["wavefrontsize32" ] = true; |
| 838 | Features["wavefrontsize64" ] = true; |
| 839 | } else if (T.isAMDGCN()) { |
| 840 | StringMap<bool> DefaultFeatures; |
| 841 | fillAMDGCNFeatureMap(GPU, T, Features&: DefaultFeatures); |
| 842 | return insertWaveSizeFeature(GPU, T, DefaultFeatures, Features); |
| 843 | } else { |
| 844 | if (GPU.empty()) |
| 845 | GPU = "r600" ; |
| 846 | |
| 847 | switch (llvm::AMDGPU::parseArchR600(CPU: GPU)) { |
| 848 | case GK_CAYMAN: |
| 849 | case GK_CYPRESS: |
| 850 | case GK_RV770: |
| 851 | case GK_RV670: |
| 852 | // TODO: Add fp64 when implemented. |
| 853 | break; |
| 854 | case GK_TURKS: |
| 855 | case GK_CAICOS: |
| 856 | case GK_BARTS: |
| 857 | case GK_SUMO: |
| 858 | case GK_REDWOOD: |
| 859 | case GK_JUNIPER: |
| 860 | case GK_CEDAR: |
| 861 | case GK_RV730: |
| 862 | case GK_RV710: |
| 863 | case GK_RS880: |
| 864 | case GK_R630: |
| 865 | case GK_R600: |
| 866 | break; |
| 867 | default: |
| 868 | llvm_unreachable("Unhandled GPU!" ); |
| 869 | } |
| 870 | } |
| 871 | return {NO_ERROR, StringRef()}; |
| 872 | } |
| 873 | |