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" 39 static const LangASMap AMDGPUDefIsPrivMap;
42 enum GPUKind : uint32_t {
64 GK_R600_FIRST = GK_R600,
65 GK_R600_LAST = GK_TURKS,
84 GK_AMDGCN_FIRST = GK_GFX600,
85 GK_AMDGCN_LAST = GK_GFX906,
89 llvm::StringLiteral Name;
90 llvm::StringLiteral CanonicalName;
91 AMDGPUTargetInfo::GPUKind
Kind;
99 static constexpr GPUInfo InvalidGPU =
100 {{
""}, {
""}, GK_NONE,
false,
false,
false,
false,
false};
101 static constexpr GPUInfo R600GPUs[26] = {
105 {{
"r600"}, {
"r600"}, GK_R600,
false,
false,
false,
false,
false},
106 {{
"rv630"}, {
"r600"}, GK_R600,
false,
false,
false,
false,
false},
107 {{
"rv635"}, {
"r600"}, GK_R600,
false,
false,
false,
false,
false},
108 {{
"r630"}, {
"r630"}, GK_R630,
false,
false,
false,
false,
false},
109 {{
"rs780"}, {
"rs880"}, GK_RS880,
false,
false,
false,
false,
false},
110 {{
"rs880"}, {
"rs880"}, GK_RS880,
false,
false,
false,
false,
false},
111 {{
"rv610"}, {
"rs880"}, GK_RS880,
false,
false,
false,
false,
false},
112 {{
"rv620"}, {
"rs880"}, GK_RS880,
false,
false,
false,
false,
false},
113 {{
"rv670"}, {
"rv670"}, GK_RV670,
false,
false,
false,
false,
false},
114 {{
"rv710"}, {
"rv710"}, GK_RV710,
false,
false,
false,
false,
false},
115 {{
"rv730"}, {
"rv730"}, GK_RV730,
false,
false,
false,
false,
false},
116 {{
"rv740"}, {
"rv770"}, GK_RV770,
false,
false,
false,
false,
false},
117 {{
"rv770"}, {
"rv770"}, GK_RV770,
false,
false,
false,
false,
false},
118 {{
"cedar"}, {
"cedar"}, GK_CEDAR,
false,
false,
false,
false,
false},
119 {{
"palm"}, {
"cedar"}, GK_CEDAR,
false,
false,
false,
false,
false},
120 {{
"cypress"}, {
"cypress"}, GK_CYPRESS,
true,
false,
false,
false,
false},
121 {{
"hemlock"}, {
"cypress"}, GK_CYPRESS,
true,
false,
false,
false,
false},
122 {{
"juniper"}, {
"juniper"}, GK_JUNIPER,
false,
false,
false,
false,
false},
123 {{
"redwood"}, {
"redwood"}, GK_REDWOOD,
false,
false,
false,
false,
false},
124 {{
"sumo"}, {
"sumo"}, GK_SUMO,
false,
false,
false,
false,
false},
125 {{
"sumo2"}, {
"sumo"}, GK_SUMO,
false,
false,
false,
false,
false},
126 {{
"barts"}, {
"barts"}, GK_BARTS,
false,
false,
false,
false,
false},
127 {{
"caicos"}, {
"caicos"}, GK_BARTS,
false,
false,
false,
false,
false},
128 {{
"aruba"}, {
"cayman"}, GK_CAYMAN,
true,
false,
false,
false,
false},
129 {{
"cayman"}, {
"cayman"}, GK_CAYMAN,
true,
false,
false,
false,
false},
130 {{
"turks"}, {
"turks"}, GK_TURKS,
false,
false,
false,
false,
false},
132 static constexpr GPUInfo AMDGCNGPUs[32] = {
136 {{
"gfx600"}, {
"gfx600"}, GK_GFX600,
true,
true,
true,
true,
true},
137 {{
"tahiti"}, {
"gfx600"}, GK_GFX600,
true,
true,
true,
true,
true},
138 {{
"gfx601"}, {
"gfx601"}, GK_GFX601,
true,
false,
true,
true,
true},
139 {{
"hainan"}, {
"gfx601"}, GK_GFX601,
true,
false,
true,
true,
true},
140 {{
"oland"}, {
"gfx601"}, GK_GFX601,
true,
false,
true,
true,
true},
141 {{
"pitcairn"}, {
"gfx601"}, GK_GFX601,
true,
false,
true,
true,
true},
142 {{
"verde"}, {
"gfx601"}, GK_GFX601,
true,
false,
true,
true,
true},
143 {{
"gfx700"}, {
"gfx700"}, GK_GFX700,
true,
false,
true,
true,
true},
144 {{
"kaveri"}, {
"gfx700"}, GK_GFX700,
true,
false,
true,
true,
true},
145 {{
"gfx701"}, {
"gfx701"}, GK_GFX701,
true,
true,
true,
true,
true},
146 {{
"hawaii"}, {
"gfx701"}, GK_GFX701,
true,
true,
true,
true,
true},
147 {{
"gfx702"}, {
"gfx702"}, GK_GFX702,
true,
true,
true,
true,
true},
148 {{
"gfx703"}, {
"gfx703"}, GK_GFX703,
true,
false,
true,
true,
true},
149 {{
"kabini"}, {
"gfx703"}, GK_GFX703,
true,
false,
true,
true,
true},
150 {{
"mullins"}, {
"gfx703"}, GK_GFX703,
true,
false,
true,
true,
true},
151 {{
"gfx704"}, {
"gfx704"}, GK_GFX704,
true,
false,
true,
true,
true},
152 {{
"bonaire"}, {
"gfx704"}, GK_GFX704,
true,
false,
true,
true,
true},
153 {{
"gfx801"}, {
"gfx801"}, GK_GFX801,
true,
true,
true,
true,
true},
154 {{
"carrizo"}, {
"gfx801"}, GK_GFX801,
true,
true,
true,
true,
true},
155 {{
"gfx802"}, {
"gfx802"}, GK_GFX802,
true,
false,
true,
true,
true},
156 {{
"iceland"}, {
"gfx802"}, GK_GFX802,
true,
false,
true,
true,
true},
157 {{
"tonga"}, {
"gfx802"}, GK_GFX802,
true,
false,
true,
true,
true},
158 {{
"gfx803"}, {
"gfx803"}, GK_GFX803,
true,
false,
true,
true,
true},
159 {{
"fiji"}, {
"gfx803"}, GK_GFX803,
true,
false,
true,
true,
true},
160 {{
"polaris10"}, {
"gfx803"}, GK_GFX803,
true,
false,
true,
true,
true},
161 {{
"polaris11"}, {
"gfx803"}, GK_GFX803,
true,
false,
true,
true,
true},
162 {{
"gfx810"}, {
"gfx810"}, GK_GFX810,
true,
false,
true,
true,
true},
163 {{
"stoney"}, {
"gfx810"}, GK_GFX810,
true,
false,
true,
true,
true},
164 {{
"gfx900"}, {
"gfx900"}, GK_GFX900,
true,
true,
true,
true,
true},
165 {{
"gfx902"}, {
"gfx902"}, GK_GFX900,
true,
true,
true,
true,
true},
166 {{
"gfx904"}, {
"gfx904"}, GK_GFX904,
true,
true,
true,
true,
true},
167 {{
"gfx906"}, {
"gfx906"}, GK_GFX906,
true,
true,
true,
true,
true},
170 static GPUInfo parseR600Name(StringRef Name);
172 static GPUInfo parseAMDGCNName(StringRef Name);
174 GPUInfo parseGPUName(StringRef Name)
const;
178 static bool isAMDGCN(
const llvm::Triple &TT) {
179 return TT.getArch() == llvm::Triple::amdgcn;
185 void setAddressSpaceMap(
bool DefaultIsPrivate);
190 if (GPU.Kind <= GK_R600_LAST)
192 if (AddrSpace == Private || AddrSpace == Local)
198 return getPointerWidthV(AddrSpace);
202 return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32;
223 static const ::llvm::StringSet<> SpecialRegs({
224 "exec",
"vcc",
"flat_scratch",
"m0",
"scc",
"tba",
"tma",
225 "flat_scratch_lo",
"flat_scratch_hi",
"vcc_lo",
"vcc_hi",
"exec_lo",
226 "exec_hi",
"tma_lo",
"tma_hi",
"tba_lo",
"tba_hi",
230 bool HasLeftParen =
false;
231 if (S.front() ==
'{') {
237 if (S.front() !=
'v' && S.front() !=
's') {
240 auto E = S.find(
'}');
241 if (!SpecialRegs.count(S.substr(0, E)))
243 S = S.drop_front(E + 1);
260 bool HasLeftBracket =
false;
261 if (!S.empty() && S.front() ==
'[') {
262 HasLeftBracket =
true;
265 unsigned long long N;
266 if (S.empty() || consumeUnsignedInteger(S, 10, N))
268 if (!S.empty() && S.front() ==
':') {
272 unsigned long long M;
273 if (consumeUnsignedInteger(S, 10, M) || N >= M)
276 if (HasLeftBracket) {
277 if (S.empty() || S.front() !=
']')
281 if (S.empty() || S.front() !=
'}')
296 const char *
Begin = Constraint;
298 if (validateAsmConstraint(Constraint, Info))
299 return std::string(Begin).substr(0, Constraint - Begin + 1);
302 return std::string(1, *Constraint);
308 const std::vector<std::string> &FeatureVec)
const override;
323 if (getTriple().getArch() == llvm::Triple::amdgcn)
324 return GK_NONE != parseAMDGCNName(Name).Kind;
326 return GK_NONE != parseR600Name(Name).Kind;
331 bool setCPU(
const std::string &Name)
override {
332 if (getTriple().getArch() == llvm::Triple::amdgcn)
333 GPU = parseAMDGCNName(Name);
335 GPU = parseR600Name(Name);
337 return GK_NONE != GPU.Kind;
341 auto &Opts = getSupportedOpenCLOpts();
342 Opts.support(
"cl_clang_storage_class_specifiers");
343 Opts.support(
"cl_khr_icd");
346 Opts.support(
"cl_khr_fp64");
347 if (GPU.Kind >= GK_CEDAR) {
348 Opts.support(
"cl_khr_byte_addressable_store");
349 Opts.support(
"cl_khr_global_int32_base_atomics");
350 Opts.support(
"cl_khr_global_int32_extended_atomics");
351 Opts.support(
"cl_khr_local_int32_base_atomics");
352 Opts.support(
"cl_khr_local_int32_extended_atomics");
354 if (GPU.Kind >= GK_AMDGCN_FIRST) {
355 Opts.support(
"cl_khr_fp16");
356 Opts.support(
"cl_khr_int64_base_atomics");
357 Opts.support(
"cl_khr_int64_extended_atomics");
358 Opts.support(
"cl_khr_mipmap_image");
359 Opts.support(
"cl_khr_subgroups");
360 Opts.support(
"cl_khr_3d_image_writes");
361 Opts.support(
"cl_amd_media_ops");
362 Opts.support(
"cl_amd_media_ops2");
373 case OCLTK_ReserveID:
387 return static_cast<unsigned>(Constant);
398 const unsigned DWARF_Private = 1;
399 const unsigned DWARF_Local = 2;
400 if (AddressSpace == Private) {
401 return DWARF_Private;
402 }
else if (AddressSpace == Local) {
430 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H
std::string convertConstraint(const char *&Constraint) const override
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;
unsigned[(unsigned) LangAS::FirstTargetAddressSpace] LangASMap
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
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.