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" 22 #include "llvm/Support/TargetParser.h" 40 static const LangASMap AMDGPUDefIsPrivMap;
42 llvm::AMDGPU::GPUKind GPUKind;
46 bool hasFP64()
const {
47 return getTriple().getArch() == llvm::Triple::amdgcn ||
48 !!(GPUFeatures & llvm::AMDGPU::FEATURE_FP64);
52 bool hasFastFMAF()
const {
53 return !!(GPUFeatures & llvm::AMDGPU::FEATURE_FAST_FMA_F32);
57 bool hasFastFMA()
const {
58 return getTriple().getArch() == llvm::Triple::amdgcn;
61 bool hasFMAF()
const {
62 return getTriple().getArch() == llvm::Triple::amdgcn ||
63 !!(GPUFeatures & llvm::AMDGPU::FEATURE_FMA);
66 bool hasFullRateDenormalsF32()
const {
67 return !!(GPUFeatures & llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32);
70 bool hasLDEXPF()
const {
71 return getTriple().getArch() == llvm::Triple::amdgcn ||
72 !!(GPUFeatures & llvm::AMDGPU::FEATURE_LDEXP);
75 static bool isAMDGCN(
const llvm::Triple &TT) {
76 return TT.getArch() == llvm::Triple::amdgcn;
79 static bool isR600(
const llvm::Triple &TT) {
80 return TT.getArch() == llvm::Triple::r600;
86 void setAddressSpaceMap(
bool DefaultIsPrivate);
91 if (isR600(getTriple()))
94 if (AddrSpace == Private || AddrSpace == Local)
101 return getPointerWidthV(AddrSpace);
105 return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32;
126 static const ::llvm::StringSet<> SpecialRegs({
127 "exec",
"vcc",
"flat_scratch",
"m0",
"scc",
"tba",
"tma",
128 "flat_scratch_lo",
"flat_scratch_hi",
"vcc_lo",
"vcc_hi",
"exec_lo",
129 "exec_hi",
"tma_lo",
"tma_hi",
"tba_lo",
"tba_hi",
133 bool HasLeftParen =
false;
134 if (S.front() ==
'{') {
140 if (S.front() !=
'v' && S.front() !=
's') {
143 auto E = S.find(
'}');
144 if (!SpecialRegs.count(S.substr(0, E)))
146 S = S.drop_front(E + 1);
163 bool HasLeftBracket =
false;
164 if (!S.empty() && S.front() ==
'[') {
165 HasLeftBracket =
true;
168 unsigned long long N;
169 if (S.empty() || consumeUnsignedInteger(S, 10, N))
171 if (!S.empty() && S.front() ==
':') {
175 unsigned long long M;
176 if (consumeUnsignedInteger(S, 10, M) || N >= M)
179 if (HasLeftBracket) {
180 if (S.empty() || S.front() !=
']')
184 if (S.empty() || S.front() !=
'}')
199 const char *
Begin = Constraint;
201 if (validateAsmConstraint(Constraint, Info))
202 return std::string(Begin).substr(0, Constraint - Begin + 1);
205 return std::string(1, *Constraint);
211 const std::vector<std::string> &FeatureVec)
const override;
226 if (getTriple().getArch() == llvm::Triple::amdgcn)
227 return llvm::AMDGPU::parseArchAMDGCN(Name) != llvm::AMDGPU::GK_NONE;
228 return llvm::AMDGPU::parseArchR600(Name) != llvm::AMDGPU::GK_NONE;
233 bool setCPU(
const std::string &Name)
override {
234 if (getTriple().getArch() == llvm::Triple::amdgcn) {
235 GPUKind = llvm::AMDGPU::parseArchAMDGCN(Name);
236 GPUFeatures = llvm::AMDGPU::getArchAttrAMDGCN(GPUKind);
238 GPUKind = llvm::AMDGPU::parseArchR600(Name);
239 GPUFeatures = llvm::AMDGPU::getArchAttrR600(GPUKind);
242 return GPUKind != llvm::AMDGPU::GK_NONE;
246 auto &Opts = getSupportedOpenCLOpts();
247 Opts.support(
"cl_clang_storage_class_specifiers");
248 Opts.support(
"cl_khr_icd");
250 bool IsAMDGCN = isAMDGCN(getTriple());
253 Opts.support(
"cl_khr_fp64");
255 if (IsAMDGCN || GPUKind >= llvm::AMDGPU::GK_CEDAR) {
256 Opts.support(
"cl_khr_byte_addressable_store");
257 Opts.support(
"cl_khr_global_int32_base_atomics");
258 Opts.support(
"cl_khr_global_int32_extended_atomics");
259 Opts.support(
"cl_khr_local_int32_base_atomics");
260 Opts.support(
"cl_khr_local_int32_extended_atomics");
264 Opts.support(
"cl_khr_fp16");
265 Opts.support(
"cl_khr_int64_base_atomics");
266 Opts.support(
"cl_khr_int64_extended_atomics");
267 Opts.support(
"cl_khr_mipmap_image");
268 Opts.support(
"cl_khr_subgroups");
269 Opts.support(
"cl_khr_3d_image_writes");
270 Opts.support(
"cl_amd_media_ops");
271 Opts.support(
"cl_amd_media_ops2");
282 case OCLTK_ReserveID:
317 return static_cast<unsigned>(Constant);
328 const unsigned DWARF_Private = 1;
329 const unsigned DWARF_Local = 2;
330 if (AddressSpace == Private) {
331 return DWARF_Private;
332 }
else if (AddressSpace == Local) {
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.