| 1 |
//===--- AMDGPU.h - Declare AMDGPU target feature support -------*- 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 declares AMDGPU TargetInfo objects. |
| 10 |
// |
| 11 |
//===----------------------------------------------------------------------===// |
| 12 |
|
| 13 |
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H |
| 14 |
#define LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H |
| 15 |
|
| 16 |
#include "clang/Basic/TargetID.h" |
| 17 |
#include "clang/Basic/TargetInfo.h" |
| 18 |
#include "clang/Basic/TargetOptions.h" |
| 19 |
#include "llvm/ADT/StringSet.h" |
| 20 |
#include "llvm/Support/AMDGPUAddrSpace.h" |
| 21 |
#include "llvm/Support/Compiler.h" |
| 22 |
#include "llvm/TargetParser/TargetParser.h" |
| 23 |
#include "llvm/TargetParser/Triple.h" |
| 24 |
#include <optional> |
| 25 |
|
| 26 |
namespace clang { |
| 27 |
namespace targets { |
| 28 |
|
| 29 |
class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { |
| 30 |
|
| 31 |
static const char *const GCCRegNames[]; |
| 32 |
|
| 33 |
static const LangASMap AMDGPUDefIsGenMap; |
| 34 |
static const LangASMap AMDGPUDefIsPrivMap; |
| 35 |
|
| 36 |
llvm::AMDGPU::GPUKind GPUKind; |
| 37 |
unsigned GPUFeatures; |
| 38 |
unsigned WavefrontSize; |
| 39 |
|
| 40 |
/// Whether to use cumode or WGP mode. True for cumode. False for WGP mode. |
| 41 |
bool CUMode; |
| 42 |
|
| 43 |
/// Whether having image instructions. |
| 44 |
bool HasImage = false; |
| 45 |
|
| 46 |
/// Target ID is device name followed by optional feature name postfixed |
| 47 |
/// by plus or minus sign delimitted by colon, e.g. gfx908:xnack+:sramecc-. |
| 48 |
/// If the target ID contains feature+, map it to true. |
| 49 |
/// If the target ID contains feature-, map it to false. |
| 50 |
/// If the target ID does not contain a feature (default), do not map it. |
| 51 |
llvm::StringMap<bool> OffloadArchFeatures; |
| 52 |
std::string TargetID; |
| 53 |
|
| 54 |
bool hasFP64() const { |
| 55 |
return getTriple().isAMDGCN() || |
| 56 |
!!(GPUFeatures & llvm::AMDGPU::FEATURE_FP64); |
| 57 |
} |
| 58 |
|
| 59 |
/// Has fast fma f32 |
| 60 |
bool hasFastFMAF() const { |
| 61 |
return !!(GPUFeatures & llvm::AMDGPU::FEATURE_FAST_FMA_F32); |
| 62 |
} |
| 63 |
|
| 64 |
/// Has fast fma f64 |
| 65 |
bool hasFastFMA() const { return getTriple().isAMDGCN(); } |
| 66 |
|
| 67 |
bool hasFMAF() const { |
| 68 |
return getTriple().isAMDGCN() || |
| 69 |
!!(GPUFeatures & llvm::AMDGPU::FEATURE_FMA); |
| 70 |
} |
| 71 |
|
| 72 |
bool hasFullRateDenormalsF32() const { |
| 73 |
return !!(GPUFeatures & llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32); |
| 74 |
} |
| 75 |
|
| 76 |
bool hasLDEXPF() const { |
| 77 |
return getTriple().isAMDGCN() || |
| 78 |
!!(GPUFeatures & llvm::AMDGPU::FEATURE_LDEXP); |
| 79 |
} |
| 80 |
|
| 81 |
static bool isAMDGCN(const llvm::Triple &TT) { return TT.isAMDGCN(); } |
| 82 |
|
| 83 |
static bool isR600(const llvm::Triple &TT) { |
| 84 |
return TT.getArch() == llvm::Triple::r600; |
| 85 |
} |
| 86 |
|
| 87 |
bool hasFlatSupport() const { |
| 88 |
if (GPUKind >= llvm::AMDGPU::GK_GFX700) |
| 89 |
return true; |
| 90 |
|
| 91 |
// Dummy target is assumed to be gfx700+ for amdhsa. |
| 92 |
if (GPUKind == llvm::AMDGPU::GK_NONE && |
| 93 |
getTriple().getOS() == llvm::Triple::AMDHSA) |
| 94 |
return true; |
| 95 |
|
| 96 |
return false; |
| 97 |
} |
| 98 |
|
| 99 |
public: |
| 100 |
AMDGPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
| 101 |
|
| 102 |
void setAddressSpaceMap(bool DefaultIsPrivate); |
| 103 |
|
| 104 |
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts, |
| 105 |
const TargetInfo *Aux) override; |
| 106 |
|
| 107 |
uint64_t getPointerWidthV(LangAS AS) const override { |
| 108 |
if (isR600(getTriple())) |
| 109 |
return 32; |
| 110 |
unsigned TargetAS = getTargetAddressSpace(AS); |
| 111 |
|
| 112 |
if (TargetAS == llvm::AMDGPUAS::PRIVATE_ADDRESS || |
| 113 |
TargetAS == llvm::AMDGPUAS::LOCAL_ADDRESS) |
| 114 |
return 32; |
| 115 |
|
| 116 |
return 64; |
| 117 |
} |
| 118 |
|
| 119 |
uint64_t getPointerAlignV(LangAS AddrSpace) const override { |
| 120 |
return getPointerWidthV(AddrSpace); |
| 121 |
} |
| 122 |
|
| 123 |
virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const override { |
| 124 |
// The flat address space AS(0) is a superset of all the other address |
| 125 |
// spaces used by the backend target. |
| 126 |
return A == B || |
| 127 |
((A == LangAS::Default || |
| 128 |
(isTargetAddressSpace(A) && |
| 129 |
toTargetAddressSpace(A) == llvm::AMDGPUAS::FLAT_ADDRESS)) && |
| 130 |
isTargetAddressSpace(B) && |
| 131 |
toTargetAddressSpace(B) >= llvm::AMDGPUAS::FLAT_ADDRESS && |
| 132 |
toTargetAddressSpace(B) <= llvm::AMDGPUAS::PRIVATE_ADDRESS && |
| 133 |
toTargetAddressSpace(B) != llvm::AMDGPUAS::REGION_ADDRESS); |
| 134 |
} |
| 135 |
|
| 136 |
uint64_t getMaxPointerWidth() const override { |
| 137 |
return getTriple().isAMDGCN() ? 64 : 32; |
| 138 |
} |
| 139 |
|
| 140 |
bool hasBFloat16Type() const override { return isAMDGCN(getTriple()); } |
| 141 |
|
| 142 |
std::string_view getClobbers() const override { return ""; } |
| 143 |
|
| 144 |
ArrayRef<const char *> getGCCRegNames() const override; |
| 145 |
|
| 146 |
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { |
| 147 |
return {}; |
| 148 |
} |
| 149 |
|
| 150 |
/// Accepted register names: (n, m is unsigned integer, n < m) |
| 151 |
/// v |
| 152 |
/// s |
| 153 |
/// a |
| 154 |
/// {vn}, {v[n]} |
| 155 |
/// {sn}, {s[n]} |
| 156 |
/// {an}, {a[n]} |
| 157 |
/// {S} , where S is a special register name |
| 158 |
////{v[n:m]} |
| 159 |
/// {s[n:m]} |
| 160 |
/// {a[n:m]} |
| 161 |
bool validateAsmConstraint(const char *&Name, |
| 162 |
TargetInfo::ConstraintInfo &Info) const override { |
| 163 |
static const ::llvm::StringSet<> SpecialRegs({ |
| 164 |
"exec", "vcc", "flat_scratch", "m0", "scc", "tba", "tma", |
| 165 |
"flat_scratch_lo", "flat_scratch_hi", "vcc_lo", "vcc_hi", "exec_lo", |
| 166 |
"exec_hi", "tma_lo", "tma_hi", "tba_lo", "tba_hi", |
| 167 |
}); |
| 168 |
|
| 169 |
switch (*Name) { |
| 170 |
case 'I': |
| 171 |
Info.setRequiresImmediate(-16, 64); |
| 172 |
return true; |
| 173 |
case 'J': |
| 174 |
Info.setRequiresImmediate(-32768, 32767); |
| 175 |
return true; |
| 176 |
case 'A': |
| 177 |
case 'B': |
| 178 |
case 'C': |
| 179 |
Info.setRequiresImmediate(); |
| 180 |
return true; |
| 181 |
default: |
| 182 |
break; |
| 183 |
} |
| 184 |
|
| 185 |
StringRef S(Name); |
| 186 |
|
| 187 |
if (S == "DA" || S == "DB") { |
| 188 |
Name++; |
| 189 |
Info.setRequiresImmediate(); |
| 190 |
return true; |
| 191 |
} |
| 192 |
|
| 193 |
bool HasLeftParen = S.consume_front("{"); |
| 194 |
if (S.empty()) |
| 195 |
return false; |
| 196 |
if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') { |
| 197 |
if (!HasLeftParen) |
| 198 |
return false; |
| 199 |
auto E = S.find('}'); |
| 200 |
if (!SpecialRegs.count(S.substr(0, E))) |
| 201 |
return false; |
| 202 |
S = S.drop_front(E + 1); |
| 203 |
if (!S.empty()) |
| 204 |
return false; |
| 205 |
// Found {S} where S is a special register. |
| 206 |
Info.setAllowsRegister(); |
| 207 |
Name = S.data() - 1; |
| 208 |
return true; |
| 209 |
} |
| 210 |
S = S.drop_front(); |
| 211 |
if (!HasLeftParen) { |
| 212 |
if (!S.empty()) |
| 213 |
return false; |
| 214 |
// Found s, v or a. |
| 215 |
Info.setAllowsRegister(); |
| 216 |
Name = S.data() - 1; |
| 217 |
return true; |
| 218 |
} |
| 219 |
bool HasLeftBracket = S.consume_front("["); |
| 220 |
unsigned long long N; |
| 221 |
if (S.empty() || consumeUnsignedInteger(S, 10, N)) |
| 222 |
return false; |
| 223 |
if (S.consume_front(":")) { |
| 224 |
if (!HasLeftBracket) |
| 225 |
return false; |
| 226 |
unsigned long long M; |
| 227 |
if (consumeUnsignedInteger(S, 10, M) || N >= M) |
| 228 |
return false; |
| 229 |
} |
| 230 |
if (HasLeftBracket) { |
| 231 |
if (!S.consume_front("]")) |
| 232 |
return false; |
| 233 |
} |
| 234 |
if (!S.consume_front("}")) |
| 235 |
return false; |
| 236 |
if (!S.empty()) |
| 237 |
return false; |
| 238 |
// Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]} |
| 239 |
// or {a[n:m]}. |
| 240 |
Info.setAllowsRegister(); |
| 241 |
Name = S.data() - 1; |
| 242 |
return true; |
| 243 |
} |
| 244 |
|
| 245 |
// \p Constraint will be left pointing at the last character of |
| 246 |
// the constraint. In practice, it won't be changed unless the |
| 247 |
// constraint is longer than one character. |
| 248 |
std::string convertConstraint(const char *&Constraint) const override { |
| 249 |
|
| 250 |
StringRef S(Constraint); |
| 251 |
if (S == "DA" || S == "DB") { |
| 252 |
return std::string("^") + std::string(Constraint++, 2); |
| 253 |
} |
| 254 |
|
| 255 |
const char *Begin = Constraint; |
| 256 |
TargetInfo::ConstraintInfo Info("", ""); |
| 257 |
if (validateAsmConstraint(Constraint, Info)) |
| 258 |
return std::string(Begin).substr(0, Constraint - Begin + 1); |
| 259 |
|
| 260 |
Constraint = Begin; |
| 261 |
return std::string(1, *Constraint); |
| 262 |
} |
| 263 |
|
| 264 |
bool |
| 265 |
initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, |
| 266 |
StringRef CPU, |
| 267 |
const std::vector<std::string> &FeatureVec) const override; |
| 268 |
|
| 269 |
llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override; |
| 270 |
|
| 271 |
bool useFP16ConversionIntrinsics() const override { return false; } |
| 272 |
|
| 273 |
void getTargetDefines(const LangOptions &Opts, |
| 274 |
MacroBuilder &Builder) const override; |
| 275 |
|
| 276 |
BuiltinVaListKind getBuiltinVaListKind() const override { |
| 277 |
return TargetInfo::CharPtrBuiltinVaList; |
| 278 |
} |
| 279 |
|
| 280 |
bool isValidCPUName(StringRef Name) const override { |
| 281 |
if (getTriple().isAMDGCN()) |
| 282 |
return llvm::AMDGPU::parseArchAMDGCN(Name) != llvm::AMDGPU::GK_NONE; |
| 283 |
return llvm::AMDGPU::parseArchR600(Name) != llvm::AMDGPU::GK_NONE; |
| 284 |
} |
| 285 |
|
| 286 |
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override; |
| 287 |
|
| 288 |
bool setCPU(const std::string &Name) override { |
| 289 |
if (getTriple().isAMDGCN()) { |
| 290 |
GPUKind = llvm::AMDGPU::parseArchAMDGCN(Name); |
| 291 |
GPUFeatures = llvm::AMDGPU::getArchAttrAMDGCN(GPUKind); |
| 292 |
} else { |
| 293 |
GPUKind = llvm::AMDGPU::parseArchR600(Name); |
| 294 |
GPUFeatures = llvm::AMDGPU::getArchAttrR600(GPUKind); |
| 295 |
} |
| 296 |
|
| 297 |
return GPUKind != llvm::AMDGPU::GK_NONE; |
| 298 |
} |
| 299 |
|
| 300 |
void setSupportedOpenCLOpts() override { |
| 301 |
auto &Opts = getSupportedOpenCLOpts(); |
| 302 |
Opts["cl_clang_storage_class_specifiers"] = true; |
| 303 |
Opts["__cl_clang_variadic_functions"] = true; |
| 304 |
Opts["__cl_clang_function_pointers"] = true; |
| 305 |
Opts["__cl_clang_non_portable_kernel_param_types"] = true; |
| 306 |
Opts["__cl_clang_bitfields"] = true; |
| 307 |
|
| 308 |
bool IsAMDGCN = isAMDGCN(getTriple()); |
| 309 |
|
| 310 |
Opts["cl_khr_fp64"] = hasFP64(); |
| 311 |
Opts["__opencl_c_fp64"] = hasFP64(); |
| 312 |
|
| 313 |
if (IsAMDGCN || GPUKind >= llvm::AMDGPU::GK_CEDAR) { |
| 314 |
Opts["cl_khr_byte_addressable_store"] = true; |
| 315 |
Opts["cl_khr_global_int32_base_atomics"] = true; |
| 316 |
Opts["cl_khr_global_int32_extended_atomics"] = true; |
| 317 |
Opts["cl_khr_local_int32_base_atomics"] = true; |
| 318 |
Opts["cl_khr_local_int32_extended_atomics"] = true; |
| 319 |
} |
| 320 |
|
| 321 |
if (IsAMDGCN) { |
| 322 |
Opts["cl_khr_fp16"] = true; |
| 323 |
Opts["cl_khr_int64_base_atomics"] = true; |
| 324 |
Opts["cl_khr_int64_extended_atomics"] = true; |
| 325 |
Opts["cl_khr_mipmap_image"] = true; |
| 326 |
Opts["cl_khr_mipmap_image_writes"] = true; |
| 327 |
Opts["cl_khr_subgroups"] = true; |
| 328 |
Opts["cl_amd_media_ops"] = true; |
| 329 |
Opts["cl_amd_media_ops2"] = true; |
| 330 |
|
| 331 |
// FIXME: Check subtarget for image support. |
| 332 |
Opts["__opencl_c_images"] = true; |
| 333 |
Opts["__opencl_c_3d_image_writes"] = true; |
| 334 |
Opts["__opencl_c_read_write_images"] = true; |
| 335 |
Opts["cl_khr_3d_image_writes"] = true; |
| 336 |
Opts["__opencl_c_program_scope_global_variables"] = true; |
| 337 |
Opts["__opencl_c_atomic_order_acq_rel"] = true; |
| 338 |
Opts["__opencl_c_atomic_order_seq_cst"] = true; |
| 339 |
Opts["__opencl_c_atomic_scope_device"] = true; |
| 340 |
Opts["__opencl_c_atomic_scope_all_devices"] = true; |
| 341 |
Opts["__opencl_c_work_group_collective_functions"] = true; |
| 342 |
|
| 343 |
if (hasFlatSupport()) { |
| 344 |
Opts["__opencl_c_generic_address_space"] = true; |
| 345 |
Opts["__opencl_c_device_enqueue"] = true; |
| 346 |
Opts["__opencl_c_pipes"] = true; |
| 347 |
} |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const override { |
| 352 |
switch (TK) { |
| 353 |
case OCLTK_Image: |
| 354 |
return LangAS::opencl_constant; |
| 355 |
|
| 356 |
case OCLTK_ClkEvent: |
| 357 |
case OCLTK_Queue: |
| 358 |
case OCLTK_ReserveID: |
| 359 |
return LangAS::opencl_global; |
| 360 |
|
| 361 |
default: |
| 362 |
return TargetInfo::getOpenCLTypeAddrSpace(TK); |
| 363 |
} |
| 364 |
} |
| 365 |
|
| 366 |
LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const override { |
| 367 |
switch (AS) { |
| 368 |
case 0: |
| 369 |
return LangAS::opencl_generic; |
| 370 |
case 1: |
| 371 |
return LangAS::opencl_global; |
| 372 |
case 3: |
| 373 |
return LangAS::opencl_local; |
| 374 |
case 4: |
| 375 |
return LangAS::opencl_constant; |
| 376 |
case 5: |
| 377 |
return LangAS::opencl_private; |
| 378 |
default: |
| 379 |
return getLangASFromTargetAS(AS); |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
LangAS getCUDABuiltinAddressSpace(unsigned AS) const override { |
| 384 |
switch (AS) { |
| 385 |
case 0: |
| 386 |
return LangAS::Default; |
| 387 |
case 1: |
| 388 |
return LangAS::cuda_device; |
| 389 |
case 3: |
| 390 |
return LangAS::cuda_shared; |
| 391 |
case 4: |
| 392 |
return LangAS::cuda_constant; |
| 393 |
default: |
| 394 |
return getLangASFromTargetAS(AS); |
| 395 |
} |
| 396 |
} |
| 397 |
|
| 398 |
std::optional<LangAS> getConstantAddressSpace() const override { |
| 399 |
return getLangASFromTargetAS(llvm::AMDGPUAS::CONSTANT_ADDRESS); |
| 400 |
} |
| 401 |
|
| 402 |
const llvm::omp::GV &getGridValue() const override { |
| 403 |
switch (WavefrontSize) { |
| 404 |
case 32: |
| 405 |
return llvm::omp::getAMDGPUGridValues<32>(); |
| 406 |
case 64: |
| 407 |
return llvm::omp::getAMDGPUGridValues<64>(); |
| 408 |
default: |
| 409 |
llvm_unreachable("getGridValue not implemented for this wavesize"); |
| 410 |
} |
| 411 |
} |
| 412 |
|
| 413 |
/// \returns Target specific vtbl ptr address space. |
| 414 |
unsigned getVtblPtrAddressSpace() const override { |
| 415 |
return static_cast<unsigned>(llvm::AMDGPUAS::CONSTANT_ADDRESS); |
| 416 |
} |
| 417 |
|
| 418 |
/// \returns If a target requires an address within a target specific address |
| 419 |
/// space \p AddressSpace to be converted in order to be used, then return the |
| 420 |
/// corresponding target specific DWARF address space. |
| 421 |
/// |
| 422 |
/// \returns Otherwise return std::nullopt and no conversion will be emitted |
| 423 |
/// in the DWARF. |
| 424 |
std::optional<unsigned> |
| 425 |
getDWARFAddressSpace(unsigned AddressSpace) const override { |
| 426 |
int DWARFAS = llvm::AMDGPU::mapToDWARFAddrSpace(AddressSpace); |
| 427 |
// If there is no corresponding address space identifier, or it would be |
| 428 |
// the default, then don't emit the attribute. |
| 429 |
if (DWARFAS == -1 || DWARFAS == llvm::AMDGPU::DWARFAS::DEFAULT) |
| 430 |
return std::nullopt; |
| 431 |
return DWARFAS; |
| 432 |
} |
| 433 |
|
| 434 |
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { |
| 435 |
switch (CC) { |
| 436 |
default: |
| 437 |
return CCCR_Warning; |
| 438 |
case CC_C: |
| 439 |
case CC_DeviceKernel: |
| 440 |
return CCCR_OK; |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
// In amdgcn target the null pointer in global, constant, and generic |
| 445 |
// address space has value 0 but in private and local address space has |
| 446 |
// value ~0. |
| 447 |
uint64_t getNullPointerValue(LangAS AS) const override { |
| 448 |
// Check language-specific address spaces |
| 449 |
if (AS == LangAS::opencl_local || AS == LangAS::opencl_private || |
| 450 |
AS == LangAS::sycl_local || AS == LangAS::sycl_private) |
| 451 |
return ~0; |
| 452 |
if (isTargetAddressSpace(AS)) |
| 453 |
return llvm::AMDGPU::getNullPointerValue(toTargetAddressSpace(AS)); |
| 454 |
return 0; |
| 455 |
} |
| 456 |
|
| 457 |
void setAuxTarget(const TargetInfo *Aux) override; |
| 458 |
|
| 459 |
bool hasBitIntType() const override { return true; } |
| 460 |
|
| 461 |
// Record offload arch features since they are needed for defining the |
| 462 |
// pre-defined macros. |
| 463 |
bool handleTargetFeatures(std::vector<std::string> &Features, |
| 464 |
DiagnosticsEngine &Diags) override { |
| 465 |
HasFullBFloat16 = true; |
| 466 |
auto TargetIDFeatures = |
| 467 |
getAllPossibleTargetIDFeatures(getTriple(), getArchNameAMDGCN(GPUKind)); |
| 468 |
for (const auto &F : Features) { |
| 469 |
assert(F.front() == '+' || F.front() == '-'); |
| 470 |
if (F == "+wavefrontsize64") |
| 471 |
WavefrontSize = 64; |
| 472 |
else if (F == "+cumode") |
| 473 |
CUMode = true; |
| 474 |
else if (F == "-cumode") |
| 475 |
CUMode = false; |
| 476 |
else if (F == "+image-insts") |
| 477 |
HasImage = true; |
| 478 |
bool IsOn = F.front() == '+'; |
| 479 |
StringRef Name = StringRef(F).drop_front(); |
| 480 |
if (!llvm::is_contained(TargetIDFeatures, Name)) |
| 481 |
continue; |
| 482 |
assert(!OffloadArchFeatures.contains(Name)); |
| 483 |
OffloadArchFeatures[Name] = IsOn; |
| 484 |
} |
| 485 |
return true; |
| 486 |
} |
| 487 |
|
| 488 |
std::optional<std::string> getTargetID() const override { |
| 489 |
if (!isAMDGCN(getTriple())) |
| 490 |
return std::nullopt; |
| 491 |
// When -target-cpu is not set, we assume generic code that it is valid |
| 492 |
// for all GPU and use an empty string as target ID to represent that. |
| 493 |
if (GPUKind == llvm::AMDGPU::GK_NONE) |
| 494 |
return std::string(""); |
| 495 |
return getCanonicalTargetID(getArchNameAMDGCN(GPUKind), |
| 496 |
OffloadArchFeatures); |
| 497 |
} |
| 498 |
|
| 499 |
bool hasHIPImageSupport() const override { return HasImage; } |
| 500 |
|
| 501 |
std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override { |
| 502 |
// This is imprecise as the value can vary between 64, 128 (even 256!) bytes |
| 503 |
// depending on the level of cache and the target architecture. We select |
| 504 |
// the size that corresponds to the largest L1 cache line for all |
| 505 |
// architectures. |
| 506 |
return std::make_pair(128, 128); |
| 507 |
} |
| 508 |
}; |
| 509 |
|
| 510 |
} // namespace targets |
| 511 |
} // namespace clang |
| 512 |
|
| 513 |
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H |