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 namespace { 22 23 struct GPUInfo { 24 StringLiteral Name; 25 StringLiteral CanonicalName; 26 AMDGPU::GPUKind Kind; 27 unsigned Features; 28 }; 29 30 constexpr GPUInfo R600GPUs[] = { 31 // Name Canonical Kind Features 32 // Name 33 {{"r600"}, {"r600"}, GK_R600, FEATURE_NONE }, 34 {{"rv630"}, {"r600"}, GK_R600, FEATURE_NONE }, 35 {{"rv635"}, {"r600"}, GK_R600, FEATURE_NONE }, 36 {{"r630"}, {"r630"}, GK_R630, FEATURE_NONE }, 37 {{"rs780"}, {"rs880"}, GK_RS880, FEATURE_NONE }, 38 {{"rs880"}, {"rs880"}, GK_RS880, FEATURE_NONE }, 39 {{"rv610"}, {"rs880"}, GK_RS880, FEATURE_NONE }, 40 {{"rv620"}, {"rs880"}, GK_RS880, FEATURE_NONE }, 41 {{"rv670"}, {"rv670"}, GK_RV670, FEATURE_NONE }, 42 {{"rv710"}, {"rv710"}, GK_RV710, FEATURE_NONE }, 43 {{"rv730"}, {"rv730"}, GK_RV730, FEATURE_NONE }, 44 {{"rv740"}, {"rv770"}, GK_RV770, FEATURE_NONE }, 45 {{"rv770"}, {"rv770"}, GK_RV770, FEATURE_NONE }, 46 {{"cedar"}, {"cedar"}, GK_CEDAR, FEATURE_NONE }, 47 {{"palm"}, {"cedar"}, GK_CEDAR, FEATURE_NONE }, 48 {{"cypress"}, {"cypress"}, GK_CYPRESS, FEATURE_FMA }, 49 {{"hemlock"}, {"cypress"}, GK_CYPRESS, FEATURE_FMA }, 50 {{"juniper"}, {"juniper"}, GK_JUNIPER, FEATURE_NONE }, 51 {{"redwood"}, {"redwood"}, GK_REDWOOD, FEATURE_NONE }, 52 {{"sumo"}, {"sumo"}, GK_SUMO, FEATURE_NONE }, 53 {{"sumo2"}, {"sumo"}, GK_SUMO, FEATURE_NONE }, 54 {{"barts"}, {"barts"}, GK_BARTS, FEATURE_NONE }, 55 {{"caicos"}, {"caicos"}, GK_CAICOS, FEATURE_NONE }, 56 {{"aruba"}, {"cayman"}, GK_CAYMAN, FEATURE_FMA }, 57 {{"cayman"}, {"cayman"}, GK_CAYMAN, FEATURE_FMA }, 58 {{"turks"}, {"turks"}, GK_TURKS, FEATURE_NONE } 59 }; 60 61 // This table should be sorted by the value of GPUKind 62 // Don't bother listing the implicitly true features 63 constexpr GPUInfo AMDGCNGPUs[] = { 64 // Name Canonical Kind Features 65 // Name 66 {{"gfx600"}, {"gfx600"}, GK_GFX600, FEATURE_FAST_FMA_F32}, 67 {{"tahiti"}, {"gfx600"}, GK_GFX600, FEATURE_FAST_FMA_F32}, 68 {{"gfx601"}, {"gfx601"}, GK_GFX601, FEATURE_NONE}, 69 {{"pitcairn"}, {"gfx601"}, GK_GFX601, FEATURE_NONE}, 70 {{"verde"}, {"gfx601"}, GK_GFX601, FEATURE_NONE}, 71 {{"gfx602"}, {"gfx602"}, GK_GFX602, FEATURE_NONE}, 72 {{"hainan"}, {"gfx602"}, GK_GFX602, FEATURE_NONE}, 73 {{"oland"}, {"gfx602"}, GK_GFX602, FEATURE_NONE}, 74 {{"gfx700"}, {"gfx700"}, GK_GFX700, FEATURE_NONE}, 75 {{"kaveri"}, {"gfx700"}, GK_GFX700, FEATURE_NONE}, 76 {{"gfx701"}, {"gfx701"}, GK_GFX701, FEATURE_FAST_FMA_F32}, 77 {{"hawaii"}, {"gfx701"}, GK_GFX701, FEATURE_FAST_FMA_F32}, 78 {{"gfx702"}, {"gfx702"}, GK_GFX702, FEATURE_FAST_FMA_F32}, 79 {{"gfx703"}, {"gfx703"}, GK_GFX703, FEATURE_NONE}, 80 {{"kabini"}, {"gfx703"}, GK_GFX703, FEATURE_NONE}, 81 {{"mullins"}, {"gfx703"}, GK_GFX703, FEATURE_NONE}, 82 {{"gfx704"}, {"gfx704"}, GK_GFX704, FEATURE_NONE}, 83 {{"bonaire"}, {"gfx704"}, GK_GFX704, FEATURE_NONE}, 84 {{"gfx705"}, {"gfx705"}, GK_GFX705, FEATURE_NONE}, 85 {{"gfx801"}, {"gfx801"}, GK_GFX801, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 86 {{"carrizo"}, {"gfx801"}, GK_GFX801, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 87 {{"gfx802"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32}, 88 {{"iceland"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32}, 89 {{"tonga"}, {"gfx802"}, GK_GFX802, FEATURE_FAST_DENORMAL_F32}, 90 {{"gfx803"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32}, 91 {{"fiji"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32}, 92 {{"polaris10"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32}, 93 {{"polaris11"}, {"gfx803"}, GK_GFX803, FEATURE_FAST_DENORMAL_F32}, 94 {{"gfx805"}, {"gfx805"}, GK_GFX805, FEATURE_FAST_DENORMAL_F32}, 95 {{"tongapro"}, {"gfx805"}, GK_GFX805, FEATURE_FAST_DENORMAL_F32}, 96 {{"gfx810"}, {"gfx810"}, GK_GFX810, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 97 {{"stoney"}, {"gfx810"}, GK_GFX810, FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 98 {{"gfx900"}, {"gfx900"}, GK_GFX900, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 99 {{"gfx902"}, {"gfx902"}, GK_GFX902, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 100 {{"gfx904"}, {"gfx904"}, GK_GFX904, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 101 {{"gfx906"}, {"gfx906"}, GK_GFX906, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, 102 {{"gfx908"}, {"gfx908"}, GK_GFX908, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, 103 {{"gfx909"}, {"gfx909"}, GK_GFX909, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 104 {{"gfx90a"}, {"gfx90a"}, GK_GFX90A, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, 105 {{"gfx90c"}, {"gfx90c"}, GK_GFX90C, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK}, 106 {{"gfx940"}, {"gfx940"}, GK_GFX940, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, 107 {{"gfx941"}, {"gfx941"}, GK_GFX941, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, 108 {{"gfx942"}, {"gfx942"}, GK_GFX942, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_XNACK|FEATURE_SRAMECC}, 109 {{"gfx1010"}, {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, 110 {{"gfx1011"}, {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, 111 {{"gfx1012"}, {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, 112 {{"gfx1013"}, {"gfx1013"}, GK_GFX1013, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_XNACK|FEATURE_WGP}, 113 {{"gfx1030"}, {"gfx1030"}, GK_GFX1030, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 114 {{"gfx1031"}, {"gfx1031"}, GK_GFX1031, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 115 {{"gfx1032"}, {"gfx1032"}, GK_GFX1032, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 116 {{"gfx1033"}, {"gfx1033"}, GK_GFX1033, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 117 {{"gfx1034"}, {"gfx1034"}, GK_GFX1034, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 118 {{"gfx1035"}, {"gfx1035"}, GK_GFX1035, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 119 {{"gfx1036"}, {"gfx1036"}, GK_GFX1036, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 120 {{"gfx1100"}, {"gfx1100"}, GK_GFX1100, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 121 {{"gfx1101"}, {"gfx1101"}, GK_GFX1101, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 122 {{"gfx1102"}, {"gfx1102"}, GK_GFX1102, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 123 {{"gfx1103"}, {"gfx1103"}, GK_GFX1103, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 124 {{"gfx1150"}, {"gfx1150"}, GK_GFX1150, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 125 {{"gfx1151"}, {"gfx1151"}, GK_GFX1151, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32|FEATURE_WGP}, 126 }; 127 128 const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef<GPUInfo> Table) { 129 GPUInfo Search = { {""}, {""}, AK, AMDGPU::FEATURE_NONE }; 130 131 auto I = 132 llvm::lower_bound(Table, Search, [](const GPUInfo &A, const GPUInfo &B) { 133 return A.Kind < B.Kind; 134 }); 135 136 if (I == Table.end()) 137 return nullptr; 138 return I; 139 } 140 141 } // namespace 142 143 StringRef llvm::AMDGPU::getArchNameAMDGCN(GPUKind AK) { 144 if (const auto *Entry = getArchEntry(AK, AMDGCNGPUs)) 145 return Entry->CanonicalName; 146 return ""; 147 } 148 149 StringRef llvm::AMDGPU::getArchNameR600(GPUKind AK) { 150 if (const auto *Entry = getArchEntry(AK, R600GPUs)) 151 return Entry->CanonicalName; 152 return ""; 153 } 154 155 AMDGPU::GPUKind llvm::AMDGPU::parseArchAMDGCN(StringRef CPU) { 156 for (const auto &C : AMDGCNGPUs) { 157 if (CPU == C.Name) 158 return C.Kind; 159 } 160 161 return AMDGPU::GPUKind::GK_NONE; 162 } 163 164 AMDGPU::GPUKind llvm::AMDGPU::parseArchR600(StringRef CPU) { 165 for (const auto &C : R600GPUs) { 166 if (CPU == C.Name) 167 return C.Kind; 168 } 169 170 return AMDGPU::GPUKind::GK_NONE; 171 } 172 173 unsigned AMDGPU::getArchAttrAMDGCN(GPUKind AK) { 174 if (const auto *Entry = getArchEntry(AK, AMDGCNGPUs)) 175 return Entry->Features; 176 return FEATURE_NONE; 177 } 178 179 unsigned AMDGPU::getArchAttrR600(GPUKind AK) { 180 if (const auto *Entry = getArchEntry(AK, R600GPUs)) 181 return Entry->Features; 182 return FEATURE_NONE; 183 } 184 185 void AMDGPU::fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values) { 186 // XXX: Should this only report unique canonical names? 187 for (const auto &C : AMDGCNGPUs) 188 Values.push_back(C.Name); 189 } 190 191 void AMDGPU::fillValidArchListR600(SmallVectorImpl<StringRef> &Values) { 192 for (const auto &C : R600GPUs) 193 Values.push_back(C.Name); 194 } 195 196 AMDGPU::IsaVersion AMDGPU::getIsaVersion(StringRef GPU) { 197 AMDGPU::GPUKind AK = parseArchAMDGCN(GPU); 198 if (AK == AMDGPU::GPUKind::GK_NONE) { 199 if (GPU == "generic-hsa") 200 return {7, 0, 0}; 201 if (GPU == "generic") 202 return {6, 0, 0}; 203 return {0, 0, 0}; 204 } 205 206 switch (AK) { 207 case GK_GFX600: return {6, 0, 0}; 208 case GK_GFX601: return {6, 0, 1}; 209 case GK_GFX602: return {6, 0, 2}; 210 case GK_GFX700: return {7, 0, 0}; 211 case GK_GFX701: return {7, 0, 1}; 212 case GK_GFX702: return {7, 0, 2}; 213 case GK_GFX703: return {7, 0, 3}; 214 case GK_GFX704: return {7, 0, 4}; 215 case GK_GFX705: return {7, 0, 5}; 216 case GK_GFX801: return {8, 0, 1}; 217 case GK_GFX802: return {8, 0, 2}; 218 case GK_GFX803: return {8, 0, 3}; 219 case GK_GFX805: return {8, 0, 5}; 220 case GK_GFX810: return {8, 1, 0}; 221 case GK_GFX900: return {9, 0, 0}; 222 case GK_GFX902: return {9, 0, 2}; 223 case GK_GFX904: return {9, 0, 4}; 224 case GK_GFX906: return {9, 0, 6}; 225 case GK_GFX908: return {9, 0, 8}; 226 case GK_GFX909: return {9, 0, 9}; 227 case GK_GFX90A: return {9, 0, 10}; 228 case GK_GFX90C: return {9, 0, 12}; 229 case GK_GFX940: return {9, 4, 0}; 230 case GK_GFX941: return {9, 4, 1}; 231 case GK_GFX942: return {9, 4, 2}; 232 case GK_GFX1010: return {10, 1, 0}; 233 case GK_GFX1011: return {10, 1, 1}; 234 case GK_GFX1012: return {10, 1, 2}; 235 case GK_GFX1013: return {10, 1, 3}; 236 case GK_GFX1030: return {10, 3, 0}; 237 case GK_GFX1031: return {10, 3, 1}; 238 case GK_GFX1032: return {10, 3, 2}; 239 case GK_GFX1033: return {10, 3, 3}; 240 case GK_GFX1034: return {10, 3, 4}; 241 case GK_GFX1035: return {10, 3, 5}; 242 case GK_GFX1036: return {10, 3, 6}; 243 case GK_GFX1100: return {11, 0, 0}; 244 case GK_GFX1101: return {11, 0, 1}; 245 case GK_GFX1102: return {11, 0, 2}; 246 case GK_GFX1103: return {11, 0, 3}; 247 case GK_GFX1150: return {11, 5, 0}; 248 case GK_GFX1151: return {11, 5, 1}; 249 default: return {0, 0, 0}; 250 } 251 } 252 253 StringRef AMDGPU::getCanonicalArchName(const Triple &T, StringRef Arch) { 254 assert(T.isAMDGPU()); 255 auto ProcKind = T.isAMDGCN() ? parseArchAMDGCN(Arch) : parseArchR600(Arch); 256 if (ProcKind == GK_NONE) 257 return StringRef(); 258 259 return T.isAMDGCN() ? getArchNameAMDGCN(ProcKind) : getArchNameR600(ProcKind); 260 } 261 262 void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, 263 StringMap<bool> &Features) { 264 // XXX - What does the member GPU mean if device name string passed here? 265 if (T.isAMDGCN()) { 266 switch (parseArchAMDGCN(GPU)) { 267 case GK_GFX1151: 268 case GK_GFX1150: 269 case GK_GFX1103: 270 case GK_GFX1102: 271 case GK_GFX1101: 272 case GK_GFX1100: 273 Features["ci-insts"] = true; 274 Features["dot5-insts"] = true; 275 Features["dot7-insts"] = true; 276 Features["dot8-insts"] = true; 277 Features["dot9-insts"] = true; 278 Features["dot10-insts"] = true; 279 Features["dl-insts"] = true; 280 Features["16-bit-insts"] = true; 281 Features["dpp"] = true; 282 Features["gfx8-insts"] = true; 283 Features["gfx9-insts"] = true; 284 Features["gfx10-insts"] = true; 285 Features["gfx10-3-insts"] = true; 286 Features["gfx11-insts"] = true; 287 Features["atomic-fadd-rtn-insts"] = true; 288 Features["image-insts"] = true; 289 break; 290 case GK_GFX1036: 291 case GK_GFX1035: 292 case GK_GFX1034: 293 case GK_GFX1033: 294 case GK_GFX1032: 295 case GK_GFX1031: 296 case GK_GFX1030: 297 Features["ci-insts"] = true; 298 Features["dot1-insts"] = true; 299 Features["dot2-insts"] = true; 300 Features["dot5-insts"] = true; 301 Features["dot6-insts"] = true; 302 Features["dot7-insts"] = true; 303 Features["dot10-insts"] = true; 304 Features["dl-insts"] = true; 305 Features["16-bit-insts"] = true; 306 Features["dpp"] = true; 307 Features["gfx8-insts"] = true; 308 Features["gfx9-insts"] = true; 309 Features["gfx10-insts"] = true; 310 Features["gfx10-3-insts"] = true; 311 Features["image-insts"] = true; 312 Features["s-memrealtime"] = true; 313 Features["s-memtime-inst"] = true; 314 break; 315 case GK_GFX1012: 316 case GK_GFX1011: 317 Features["dot1-insts"] = true; 318 Features["dot2-insts"] = true; 319 Features["dot5-insts"] = true; 320 Features["dot6-insts"] = true; 321 Features["dot7-insts"] = true; 322 Features["dot10-insts"] = true; 323 [[fallthrough]]; 324 case GK_GFX1013: 325 case GK_GFX1010: 326 Features["dl-insts"] = true; 327 Features["ci-insts"] = true; 328 Features["16-bit-insts"] = true; 329 Features["dpp"] = true; 330 Features["gfx8-insts"] = true; 331 Features["gfx9-insts"] = true; 332 Features["gfx10-insts"] = true; 333 Features["image-insts"] = true; 334 Features["s-memrealtime"] = true; 335 Features["s-memtime-inst"] = true; 336 break; 337 case GK_GFX942: 338 case GK_GFX941: 339 case GK_GFX940: 340 Features["gfx940-insts"] = true; 341 Features["fp8-insts"] = true; 342 Features["atomic-ds-pk-add-16-insts"] = true; 343 Features["atomic-flat-pk-add-16-insts"] = true; 344 Features["atomic-global-pk-add-bf16-inst"] = true; 345 Features["gfx90a-insts"] = true; 346 Features["atomic-buffer-global-pk-add-f16-insts"] = true; 347 Features["atomic-fadd-rtn-insts"] = true; 348 Features["dot3-insts"] = true; 349 Features["dot4-insts"] = true; 350 Features["dot5-insts"] = true; 351 Features["dot6-insts"] = true; 352 Features["mai-insts"] = true; 353 Features["dl-insts"] = true; 354 Features["dot1-insts"] = true; 355 Features["dot2-insts"] = true; 356 Features["dot7-insts"] = true; 357 Features["dot10-insts"] = true; 358 Features["gfx9-insts"] = true; 359 Features["gfx8-insts"] = true; 360 Features["16-bit-insts"] = true; 361 Features["dpp"] = true; 362 Features["s-memrealtime"] = true; 363 Features["ci-insts"] = true; 364 Features["s-memtime-inst"] = true; 365 break; 366 case GK_GFX90A: 367 Features["gfx90a-insts"] = true; 368 Features["atomic-buffer-global-pk-add-f16-insts"] = true; 369 Features["atomic-fadd-rtn-insts"] = true; 370 [[fallthrough]]; 371 case GK_GFX908: 372 Features["dot3-insts"] = true; 373 Features["dot4-insts"] = true; 374 Features["dot5-insts"] = true; 375 Features["dot6-insts"] = true; 376 Features["mai-insts"] = true; 377 [[fallthrough]]; 378 case GK_GFX906: 379 Features["dl-insts"] = true; 380 Features["dot1-insts"] = true; 381 Features["dot2-insts"] = true; 382 Features["dot7-insts"] = true; 383 Features["dot10-insts"] = true; 384 [[fallthrough]]; 385 case GK_GFX90C: 386 case GK_GFX909: 387 case GK_GFX904: 388 case GK_GFX902: 389 case GK_GFX900: 390 Features["gfx9-insts"] = true; 391 [[fallthrough]]; 392 case GK_GFX810: 393 case GK_GFX805: 394 case GK_GFX803: 395 case GK_GFX802: 396 case GK_GFX801: 397 Features["gfx8-insts"] = true; 398 Features["16-bit-insts"] = true; 399 Features["dpp"] = true; 400 Features["s-memrealtime"] = true; 401 [[fallthrough]]; 402 case GK_GFX705: 403 case GK_GFX704: 404 case GK_GFX703: 405 case GK_GFX702: 406 case GK_GFX701: 407 case GK_GFX700: 408 Features["ci-insts"] = true; 409 [[fallthrough]]; 410 case GK_GFX602: 411 case GK_GFX601: 412 case GK_GFX600: 413 Features["image-insts"] = true; 414 Features["s-memtime-inst"] = true; 415 break; 416 case GK_NONE: 417 break; 418 default: 419 llvm_unreachable("Unhandled GPU!"); 420 } 421 } else { 422 if (GPU.empty()) 423 GPU = "r600"; 424 425 switch (llvm::AMDGPU::parseArchR600(GPU)) { 426 case GK_CAYMAN: 427 case GK_CYPRESS: 428 case GK_RV770: 429 case GK_RV670: 430 // TODO: Add fp64 when implemented. 431 break; 432 case GK_TURKS: 433 case GK_CAICOS: 434 case GK_BARTS: 435 case GK_SUMO: 436 case GK_REDWOOD: 437 case GK_JUNIPER: 438 case GK_CEDAR: 439 case GK_RV730: 440 case GK_RV710: 441 case GK_RS880: 442 case GK_R630: 443 case GK_R600: 444 break; 445 default: 446 llvm_unreachable("Unhandled GPU!"); 447 } 448 } 449 } 450 451 static bool isWave32Capable(StringRef GPU, const Triple &T) { 452 bool IsWave32Capable = false; 453 // XXX - What does the member GPU mean if device name string passed here? 454 if (T.isAMDGCN()) { 455 switch (parseArchAMDGCN(GPU)) { 456 case GK_GFX1151: 457 case GK_GFX1150: 458 case GK_GFX1103: 459 case GK_GFX1102: 460 case GK_GFX1101: 461 case GK_GFX1100: 462 case GK_GFX1036: 463 case GK_GFX1035: 464 case GK_GFX1034: 465 case GK_GFX1033: 466 case GK_GFX1032: 467 case GK_GFX1031: 468 case GK_GFX1030: 469 case GK_GFX1012: 470 case GK_GFX1011: 471 case GK_GFX1013: 472 case GK_GFX1010: 473 IsWave32Capable = true; 474 break; 475 default: 476 break; 477 } 478 } 479 return IsWave32Capable; 480 } 481 482 bool AMDGPU::insertWaveSizeFeature(StringRef GPU, const Triple &T, 483 StringMap<bool> &Features, 484 std::string &ErrorMsg) { 485 bool IsWave32Capable = isWave32Capable(GPU, T); 486 const bool IsNullGPU = GPU.empty(); 487 // FIXME: Not diagnosing wavefrontsize32 on wave64 only targets. 488 const bool HaveWave32 = 489 (IsWave32Capable || IsNullGPU) && Features.count("wavefrontsize32"); 490 const bool HaveWave64 = Features.count("wavefrontsize64"); 491 if (HaveWave32 && HaveWave64) { 492 ErrorMsg = "'wavefrontsize32' and 'wavefrontsize64' are mutually exclusive"; 493 return false; 494 } 495 // Don't assume any wavesize with an unknown subtarget. 496 if (!IsNullGPU) { 497 // Default to wave32 if available, or wave64 if not 498 if (!HaveWave32 && !HaveWave64) { 499 StringRef DefaultWaveSizeFeature = 500 IsWave32Capable ? "wavefrontsize32" : "wavefrontsize64"; 501 Features.insert(std::make_pair(DefaultWaveSizeFeature, true)); 502 } 503 } 504 return true; 505 } 506