13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
19#include "llvm/Support/Compiler.h"
20#include "llvm/Support/VersionTuple.h"
21#include "llvm/TargetParser/Triple.h"
90 std::unique_ptr<TargetInfo> HostTarget;
95 assert((Triple.isSPIR() || Triple.isSPIRV()) &&
96 "Invalid architecture for SPIR or SPIR-V.");
99 LongWidth = LongAlign = 64;
101 UseAddrSpaceMapMangling =
true;
102 HasLegalHalfType =
true;
106 NoAsmVariants =
true;
109 if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() &&
110 HostTriple.getArch() != llvm::Triple::UnknownArch) {
114 BoolWidth = HostTarget->getBoolWidth();
115 BoolAlign = HostTarget->getBoolAlign();
116 IntWidth = HostTarget->getIntWidth();
117 IntAlign = HostTarget->getIntAlign();
118 HalfWidth = HostTarget->getHalfWidth();
119 HalfAlign = HostTarget->getHalfAlign();
120 FloatWidth = HostTarget->getFloatWidth();
121 FloatAlign = HostTarget->getFloatAlign();
122 DoubleWidth = HostTarget->getDoubleWidth();
123 DoubleAlign = HostTarget->getDoubleAlign();
124 LongWidth = HostTarget->getLongWidth();
125 LongAlign = HostTarget->getLongAlign();
126 LongLongWidth = HostTarget->getLongLongWidth();
127 LongLongAlign = HostTarget->getLongLongAlign();
129 HostTarget->getMinGlobalAlign( 0,
131 NewAlign = HostTarget->getNewAlign();
132 DefaultAlignForAttributeAligned =
133 HostTarget->getDefaultAlignForAttributeAligned();
134 IntMaxType = HostTarget->getIntMaxType();
135 WCharType = HostTarget->getWCharType();
136 WIntType = HostTarget->getWIntType();
137 Char16Type = HostTarget->getChar16Type();
138 Char32Type = HostTarget->getChar32Type();
139 Int64Type = HostTarget->getInt64Type();
140 SigAtomicType = HostTarget->getSigAtomicType();
141 ProcessIDType = HostTarget->getProcessIDType();
143 UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment();
144 UseZeroLengthBitfieldAlignment =
145 HostTarget->useZeroLengthBitfieldAlignment();
146 UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
147 ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
153 MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth();
178 return TargetInfo::VoidPtrBuiltinVaList;
181 std::optional<unsigned>
200 TargetInfo::adjust(Diags, Opts);
213 (getTriple().isSPIRV() && Opts.CUDAIsDevice));
219 supportAllOpenCLOpts();
231 assert(Triple.isSPIR() &&
"Invalid architecture for SPIR.");
232 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
233 "SPIR target must use unknown OS");
234 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
235 "SPIR target must use unknown environment type");
242 return Feature ==
"spir";
252 assert(Triple.getArch() == llvm::Triple::spir &&
253 "Invalid architecture for 32-bit SPIR.");
254 PointerWidth = PointerAlign = 32;
255 SizeType = TargetInfo::UnsignedInt;
256 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
257 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
258 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
269 assert(Triple.getArch() == llvm::Triple::spir64 &&
270 "Invalid architecture for 64-bit SPIR.");
271 PointerWidth = PointerAlign = 64;
272 SizeType = TargetInfo::UnsignedLong;
273 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
274 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
275 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
286 assert(Triple.isSPIRV() &&
"Invalid architecture for SPIR-V.");
290 return Feature ==
"spirv";
301 assert(Triple.getArch() == llvm::Triple::spirv &&
302 "Invalid architecture for Logical SPIR-V.");
303 assert(Triple.getOS() == llvm::Triple::Vulkan &&
304 Triple.getVulkanVersion() != llvm::VersionTuple(0) &&
305 "Logical SPIR-V requires a valid Vulkan environment.");
306 assert(Triple.getEnvironment() >= llvm::Triple::Pixel &&
307 Triple.getEnvironment() <= llvm::Triple::Amplification &&
308 "Logical SPIR-V environment must be a valid shader stage.");
309 PointerWidth = PointerAlign = 64;
312 SizeType = TargetInfo::UnsignedInt;
313 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
314 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
325 assert(Triple.getArch() == llvm::Triple::spirv32 &&
326 "Invalid architecture for 32-bit SPIR-V.");
327 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
328 "32-bit SPIR-V target must use unknown OS");
329 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
330 "32-bit SPIR-V target must use unknown environment type");
331 PointerWidth = PointerAlign = 32;
332 SizeType = TargetInfo::UnsignedInt;
333 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
336 MaxAtomicInlineWidth = std::max<unsigned char>(MaxAtomicInlineWidth, 32);
337 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-"
338 "v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
349 assert(Triple.getArch() == llvm::Triple::spirv64 &&
350 "Invalid architecture for 64-bit SPIR-V.");
351 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
352 "64-bit SPIR-V target must use unknown OS");
353 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
354 "64-bit SPIR-V target must use unknown environment type");
355 PointerWidth = PointerAlign = 64;
356 SizeType = TargetInfo::UnsignedLong;
357 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
360 MaxAtomicInlineWidth = std::max<unsigned char>(MaxAtomicInlineWidth, 64);
361 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
362 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
374 assert(Triple.getArch() == llvm::Triple::spirv64 &&
375 "Invalid architecture for 64-bit AMDGCN SPIR-V.");
376 assert(Triple.getVendor() == llvm::Triple::VendorType::AMD &&
377 "64-bit AMDGCN SPIR-V target must use AMD vendor");
378 assert(getTriple().getOS() == llvm::Triple::OSType::AMDHSA &&
379 "64-bit AMDGCN SPIR-V target must use AMDHSA OS");
380 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
381 "64-bit SPIR-V target must use unknown environment type");
382 PointerWidth = PointerAlign = 64;
383 SizeType = TargetInfo::UnsignedLong;
384 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
387 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
388 "v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0");
390 BFloat16Width = BFloat16Align = 16;
391 BFloat16Format = &llvm::APFloat::BFloat();
393 HasLegalHalfType =
true;
395 HalfArgsAndReturns =
true;
404 const std::vector<std::string> &)
const override;
406 bool validateAsmConstraint(
const char *&Name,
409 std::string convertConstraint(
const char *&Constraint)
const override;
416 void setAuxTarget(
const TargetInfo *Aux)
override;
419 TargetInfo::adjust(Diags, Opts);
Defines the clang::TargetOptions class.
Concrete class used by the front-end to report problems and issues.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Exposes information about the current target.
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Options for controlling the target.
std::string HostTriple
When compiling for the device side, contains the triple used to compile for the host.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
ArrayRef< const char * > getGCCRegNames() const override
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override
Set forced language options.
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
void setAddressSpaceMap(bool DefaultIsGeneric)
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
std::optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const override
BaseSPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
void setSupportedOpenCLOpts() override
Set supported OpenCL extensions and optional core features.
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
CallingConv getDefaultCallingConv() const override
Gets the default calling convention for the given target and declaration context.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
BaseSPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
bool checkArithmeticFenceSupported() const override
Controls if __arithmetic_fence is supported in the targeted backend.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts) override
Set forced language options.
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
bool hasBFloat16Type() const override
Determine whether the _BFloat16 type is supported on this target.
SPIRV64AMDGCNTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
SPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Defines the clang::TargetInfo interface.
static const unsigned SPIRDefIsPrivMap[]
static const unsigned SPIRDefIsGenMap[]
std::unique_ptr< clang::TargetInfo > AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts)
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.