14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H 15 #define LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H 19 #include "llvm/ADT/StringSet.h" 20 #include "llvm/ADT/Triple.h" 21 #include "llvm/Support/Compiler.h" 31 struct LLVM_LIBRARY_VISIBILITY AddrSpace {
32 unsigned Generic, Global, Local, Constant, Private;
33 AddrSpace(
bool IsGenericZero_ =
false) {
58 GK_EVERGREEN_DOUBLE_OPS,
72 static bool hasFullSpeedFMAF32(StringRef GPUName) {
73 return parseAMDGCNName(GPUName) >= GK_GFX9;
76 static bool isAMDGCN(
const llvm::Triple &TT) {
77 return TT.getArch() == llvm::Triple::amdgcn;
80 static bool isGenericZero(
const llvm::Triple &TT) {
81 return TT.getEnvironmentName() ==
"amdgiz" ||
82 TT.getEnvironmentName() ==
"amdgizcl";
88 void setAddressSpaceMap(
bool DefaultIsPrivate);
96 if (AddrSpace == AS.Private || AddrSpace == AS.Local) {
103 return getPointerWidthV(AddrSpace);
107 return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32;
128 static const ::llvm::StringSet<> SpecialRegs({
129 "exec",
"vcc",
"flat_scratch",
"m0",
"scc",
"tba",
"tma",
130 "flat_scratch_lo",
"flat_scratch_hi",
"vcc_lo",
"vcc_hi",
"exec_lo",
131 "exec_hi",
"tma_lo",
"tma_hi",
"tba_lo",
"tba_hi",
135 bool HasLeftParen =
false;
136 if (S.front() ==
'{') {
142 if (S.front() !=
'v' && S.front() !=
's') {
145 auto E = S.find(
'}');
146 if (!SpecialRegs.count(S.substr(0, E)))
148 S = S.drop_front(E + 1);
165 bool HasLeftBracket =
false;
166 if (!S.empty() && S.front() ==
'[') {
167 HasLeftBracket =
true;
170 unsigned long long N;
171 if (S.empty() || consumeUnsignedInteger(S, 10, N))
173 if (!S.empty() && S.front() ==
':') {
177 unsigned long long M;
178 if (consumeUnsignedInteger(S, 10, M) || N >= M)
181 if (HasLeftBracket) {
182 if (S.empty() || S.front() !=
']')
186 if (S.empty() || S.front() !=
'}')
200 const std::vector<std::string> &FeatureVec)
const override;
214 static GPUKind parseR600Name(StringRef Name);
216 static GPUKind parseAMDGCNName(StringRef Name);
219 if (getTriple().getArch() == llvm::Triple::amdgcn)
220 return GK_NONE != parseAMDGCNName(Name);
222 return GK_NONE != parseR600Name(Name);
225 bool setCPU(
const std::string &Name)
override {
226 if (getTriple().getArch() == llvm::Triple::amdgcn)
227 GPU = parseAMDGCNName(Name);
229 GPU = parseR600Name(Name);
231 return GPU != GK_NONE;
235 auto &Opts = getSupportedOpenCLOpts();
236 Opts.support(
"cl_clang_storage_class_specifiers");
237 Opts.support(
"cl_khr_icd");
240 Opts.support(
"cl_khr_fp64");
241 if (GPU >= GK_EVERGREEN) {
242 Opts.support(
"cl_khr_byte_addressable_store");
243 Opts.support(
"cl_khr_global_int32_base_atomics");
244 Opts.support(
"cl_khr_global_int32_extended_atomics");
245 Opts.support(
"cl_khr_local_int32_base_atomics");
246 Opts.support(
"cl_khr_local_int32_extended_atomics");
248 if (GPU >= GK_GFX6) {
249 Opts.support(
"cl_khr_fp16");
250 Opts.support(
"cl_khr_int64_base_atomics");
251 Opts.support(
"cl_khr_int64_extended_atomics");
252 Opts.support(
"cl_khr_mipmap_image");
253 Opts.support(
"cl_khr_subgroups");
254 Opts.support(
"cl_khr_3d_image_writes");
255 Opts.support(
"cl_amd_media_ops");
256 Opts.support(
"cl_amd_media_ops2");
267 case OCLTK_ReserveID:
290 const unsigned DWARF_Private = 1;
291 const unsigned DWARF_Local = 2;
292 if (AddressSpace == AS.Private) {
293 return DWARF_Private;
294 }
else if (AddressSpace == AS.Local) {
322 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
uint64_t getPointerWidthV(unsigned AddrSpace) const override
void setSupportedOpenCLOpts() override
Set supported OpenCL extensions and optional core features.
static const Builtin::Info BuiltinInfo[]
virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const
Get address space for OpenCL type.
LangAS getLangASFromTargetAS(unsigned TargetAS)
Options for controlling the target.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const override
uint64_t getPointerAlignV(unsigned AddrSpace) const override
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Concrete class used by the front-end to report problems and issues.
LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const override
Get address space for OpenCL type.
uint64_t getNullPointerValue(LangAS AS) const override
Get integer value for null pointer.
static const char *const GCCRegNames[]
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Accepted register names: (n, m is unsigned integer, n < m) v s {vn}, {v[n]} {sn}, {s[n]} {S} ...
Exposes information about the current target.
unsigned getVtblPtrAddressSpace() const override
bool setCPU(const std::string &Name) override
Target the specified CPU.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Defines the clang::TargetOptions class.
llvm::Optional< LangAS > getConstantAddressSpace() const override
Return an AST address space which can be used opportunistically for constant global memory...
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
Dataflow Directional Tag Classes.
typedef char* __builtin_va_list;
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Defines the clang::TargetInfo interface.
uint64_t getMaxPointerWidth() const override
Return the maximum width of pointers on this target.