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"
92 std::unique_ptr<TargetInfo> HostTarget;
97 assert((Triple.isSPIR() || Triple.isSPIRV()) &&
98 "Invalid architecture for SPIR or SPIR-V.");
100 VLASupported =
false;
101 LongWidth = LongAlign = 64;
103 UseAddrSpaceMapMangling =
true;
104 HasLegalHalfType =
true;
108 NoAsmVariants =
true;
111 if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() &&
112 HostTriple.getArch() != llvm::Triple::UnknownArch) {
116 BoolWidth = HostTarget->getBoolWidth();
117 BoolAlign = HostTarget->getBoolAlign();
118 IntWidth = HostTarget->getIntWidth();
119 IntAlign = HostTarget->getIntAlign();
120 HalfWidth = HostTarget->getHalfWidth();
121 HalfAlign = HostTarget->getHalfAlign();
122 FloatWidth = HostTarget->getFloatWidth();
123 FloatAlign = HostTarget->getFloatAlign();
124 DoubleWidth = HostTarget->getDoubleWidth();
125 DoubleAlign = HostTarget->getDoubleAlign();
126 LongWidth = HostTarget->getLongWidth();
127 LongAlign = HostTarget->getLongAlign();
128 LongLongWidth = HostTarget->getLongLongWidth();
129 LongLongAlign = HostTarget->getLongLongAlign();
131 HostTarget->getMinGlobalAlign( 0,
133 NewAlign = HostTarget->getNewAlign();
134 DefaultAlignForAttributeAligned =
135 HostTarget->getDefaultAlignForAttributeAligned();
136 IntMaxType = HostTarget->getIntMaxType();
137 WCharType = HostTarget->getWCharType();
138 WIntType = HostTarget->getWIntType();
139 Char16Type = HostTarget->getChar16Type();
140 Char32Type = HostTarget->getChar32Type();
141 Int64Type = HostTarget->getInt64Type();
142 SigAtomicType = HostTarget->getSigAtomicType();
143 ProcessIDType = HostTarget->getProcessIDType();
145 UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment();
146 UseZeroLengthBitfieldAlignment =
147 HostTarget->useZeroLengthBitfieldAlignment();
148 UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
149 ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
155 MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth();
180 return TargetInfo::VoidPtrBuiltinVaList;
183 std::optional<unsigned>
202 TargetInfo::adjust(Diags, Opts);
215 (getTriple().isSPIRV() && Opts.CUDAIsDevice));
221 supportAllOpenCLOpts();
233 assert(Triple.isSPIR() &&
"Invalid architecture for SPIR.");
234 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
235 "SPIR target must use unknown OS");
236 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
237 "SPIR target must use unknown environment type");
244 return Feature ==
"spir";
254 assert(Triple.getArch() == llvm::Triple::spir &&
255 "Invalid architecture for 32-bit SPIR.");
256 PointerWidth = PointerAlign = 32;
257 SizeType = TargetInfo::UnsignedInt;
258 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
259 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
260 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
271 assert(Triple.getArch() == llvm::Triple::spir64 &&
272 "Invalid architecture for 64-bit SPIR.");
273 PointerWidth = PointerAlign = 64;
274 SizeType = TargetInfo::UnsignedLong;
275 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
276 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
277 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
288 assert(Triple.isSPIRV() &&
"Invalid architecture for SPIR-V.");
292 return Feature ==
"spirv";
303 assert(Triple.getArch() == llvm::Triple::spirv &&
304 "Invalid architecture for Logical SPIR-V.");
305 assert(Triple.getOS() == llvm::Triple::Vulkan &&
306 Triple.getVulkanVersion() != llvm::VersionTuple(0) &&
307 "Logical SPIR-V requires a valid Vulkan environment.");
308 assert(Triple.getEnvironment() >= llvm::Triple::Pixel &&
309 Triple.getEnvironment() <= llvm::Triple::Amplification &&
310 "Logical SPIR-V environment must be a valid shader stage.");
311 PointerWidth = PointerAlign = 64;
314 SizeType = TargetInfo::UnsignedInt;
315 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
316 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
327 assert(Triple.getArch() == llvm::Triple::spirv32 &&
328 "Invalid architecture for 32-bit SPIR-V.");
329 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
330 "32-bit SPIR-V target must use unknown OS");
331 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
332 "32-bit SPIR-V target must use unknown environment type");
333 PointerWidth = PointerAlign = 32;
334 SizeType = TargetInfo::UnsignedInt;
335 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
338 MaxAtomicInlineWidth = std::max<unsigned char>(MaxAtomicInlineWidth, 32);
339 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-"
340 "v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
351 assert(Triple.getArch() == llvm::Triple::spirv64 &&
352 "Invalid architecture for 64-bit SPIR-V.");
353 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
354 "64-bit SPIR-V target must use unknown OS");
355 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
356 "64-bit SPIR-V target must use unknown environment type");
357 PointerWidth = PointerAlign = 64;
358 SizeType = TargetInfo::UnsignedLong;
359 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
362 MaxAtomicInlineWidth = std::max<unsigned char>(MaxAtomicInlineWidth, 64);
363 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
364 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
376 assert(Triple.getArch() == llvm::Triple::spirv64 &&
377 "Invalid architecture for 64-bit AMDGCN SPIR-V.");
378 assert(Triple.getVendor() == llvm::Triple::VendorType::AMD &&
379 "64-bit AMDGCN SPIR-V target must use AMD vendor");
380 assert(getTriple().getOS() == llvm::Triple::OSType::AMDHSA &&
381 "64-bit AMDGCN SPIR-V target must use AMDHSA OS");
382 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
383 "64-bit SPIR-V target must use unknown environment type");
384 PointerWidth = PointerAlign = 64;
385 SizeType = TargetInfo::UnsignedLong;
386 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
389 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
390 "v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0");
392 BFloat16Width = BFloat16Align = 16;
393 BFloat16Format = &llvm::APFloat::BFloat();
395 HasLegalHalfType =
true;
397 HalfArgsAndReturns =
true;
406 const std::vector<std::string> &)
const override;
408 bool validateAsmConstraint(
const char *&Name,
411 std::string convertConstraint(
const char *&Constraint)
const override;
418 void setAuxTarget(
const TargetInfo *Aux)
override;
421 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.