13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H 14 #define LLVM_CLANG_LIB_BASIC_TARGETS_AMDGPU_H 18 #include "llvm/ADT/StringSet.h" 19 #include "llvm/ADT/Triple.h" 20 #include "llvm/Support/Compiler.h" 21 #include "llvm/Support/TargetParser.h" 39 static const LangASMap AMDGPUDefIsPrivMap;
41 llvm::AMDGPU::GPUKind GPUKind;
44 bool hasFP64()
const {
45 return getTriple().getArch() == llvm::Triple::amdgcn ||
46 !!(GPUFeatures & llvm::AMDGPU::FEATURE_FP64);
50 bool hasFastFMAF()
const {
51 return !!(GPUFeatures & llvm::AMDGPU::FEATURE_FAST_FMA_F32);
55 bool hasFastFMA()
const {
56 return getTriple().getArch() == llvm::Triple::amdgcn;
59 bool hasFMAF()
const {
60 return getTriple().getArch() == llvm::Triple::amdgcn ||
61 !!(GPUFeatures & llvm::AMDGPU::FEATURE_FMA);
64 bool hasFullRateDenormalsF32()
const {
65 return !!(GPUFeatures & llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32);
68 bool hasLDEXPF()
const {
69 return getTriple().getArch() == llvm::Triple::amdgcn ||
70 !!(GPUFeatures & llvm::AMDGPU::FEATURE_LDEXP);
73 static bool isAMDGCN(
const llvm::Triple &TT) {
74 return TT.getArch() == llvm::Triple::amdgcn;
77 static bool isR600(
const llvm::Triple &TT) {
78 return TT.getArch() == llvm::Triple::r600;
84 void setAddressSpaceMap(
bool DefaultIsPrivate);
89 if (isR600(getTriple()))
92 if (AddrSpace == Private || AddrSpace == Local)
99 return getPointerWidthV(AddrSpace);
103 return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32;
124 static const ::llvm::StringSet<> SpecialRegs({
125 "exec",
"vcc",
"flat_scratch",
"m0",
"scc",
"tba",
"tma",
126 "flat_scratch_lo",
"flat_scratch_hi",
"vcc_lo",
"vcc_hi",
"exec_lo",
127 "exec_hi",
"tma_lo",
"tma_hi",
"tba_lo",
"tba_hi",
131 bool HasLeftParen =
false;
132 if (S.front() ==
'{') {
138 if (S.front() !=
'v' && S.front() !=
's') {
141 auto E = S.find(
'}');
142 if (!SpecialRegs.count(S.substr(0, E)))
144 S = S.drop_front(E + 1);
161 bool HasLeftBracket =
false;
162 if (!S.empty() && S.front() ==
'[') {
163 HasLeftBracket =
true;
166 unsigned long long N;
167 if (S.empty() || consumeUnsignedInteger(S, 10, N))
169 if (!S.empty() && S.front() ==
':') {
173 unsigned long long M;
174 if (consumeUnsignedInteger(S, 10, M) || N >= M)
177 if (HasLeftBracket) {
178 if (S.empty() || S.front() !=
']')
182 if (S.empty() || S.front() !=
'}')
197 const char *
Begin = Constraint;
199 if (validateAsmConstraint(Constraint, Info))
200 return std::string(Begin).substr(0, Constraint - Begin + 1);
203 return std::string(1, *Constraint);
209 const std::vector<std::string> &FeatureVec)
const override;
224 if (getTriple().getArch() == llvm::Triple::amdgcn)
225 return llvm::AMDGPU::parseArchAMDGCN(Name) != llvm::AMDGPU::GK_NONE;
226 return llvm::AMDGPU::parseArchR600(Name) != llvm::AMDGPU::GK_NONE;
231 bool setCPU(
const std::string &Name)
override {
232 if (getTriple().getArch() == llvm::Triple::amdgcn) {
233 GPUKind = llvm::AMDGPU::parseArchAMDGCN(Name);
234 GPUFeatures = llvm::AMDGPU::getArchAttrAMDGCN(GPUKind);
236 GPUKind = llvm::AMDGPU::parseArchR600(Name);
237 GPUFeatures = llvm::AMDGPU::getArchAttrR600(GPUKind);
240 return GPUKind != llvm::AMDGPU::GK_NONE;
244 auto &Opts = getSupportedOpenCLOpts();
245 Opts.support(
"cl_clang_storage_class_specifiers");
246 Opts.support(
"cl_khr_icd");
248 bool IsAMDGCN = isAMDGCN(getTriple());
251 Opts.support(
"cl_khr_fp64");
253 if (IsAMDGCN || GPUKind >= llvm::AMDGPU::GK_CEDAR) {
254 Opts.support(
"cl_khr_byte_addressable_store");
255 Opts.support(
"cl_khr_global_int32_base_atomics");
256 Opts.support(
"cl_khr_global_int32_extended_atomics");
257 Opts.support(
"cl_khr_local_int32_base_atomics");
258 Opts.support(
"cl_khr_local_int32_extended_atomics");
262 Opts.support(
"cl_khr_fp16");
263 Opts.support(
"cl_khr_int64_base_atomics");
264 Opts.support(
"cl_khr_int64_extended_atomics");
265 Opts.support(
"cl_khr_mipmap_image");
266 Opts.support(
"cl_khr_subgroups");
267 Opts.support(
"cl_khr_3d_image_writes");
268 Opts.support(
"cl_amd_media_ops");
269 Opts.support(
"cl_amd_media_ops2");
280 case OCLTK_ReserveID:
315 return static_cast<unsigned>(Constant);
326 const unsigned DWARF_Private = 1;
327 const unsigned DWARF_Local = 2;
328 if (AddressSpace == Private) {
329 return DWARF_Private;
330 }
else if (AddressSpace == Local) {
354 void setAuxTarget(
const TargetInfo *Aux)
override;
360 #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...
LangAS getCUDABuiltinAddressSpace(unsigned AS) const override
Map from the address space field in builtin description strings to the language address space...
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...
LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const override
Map from the address space field in builtin description strings to the language address space...
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.