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();
182 return TargetInfo::VoidPtrBuiltinVaList;
185 std::optional<unsigned>
204 TargetInfo::adjust(Diags, Opts);
217 (getTriple().isSPIRV() && Opts.CUDAIsDevice));
223 supportAllOpenCLOpts();
235 assert(Triple.isSPIR() &&
"Invalid architecture for SPIR.");
236 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
237 "SPIR target must use unknown OS");
238 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
239 "SPIR target must use unknown environment type");
246 return Feature ==
"spir";
256 assert(Triple.getArch() == llvm::Triple::spir &&
257 "Invalid architecture for 32-bit SPIR.");
258 PointerWidth = PointerAlign = 32;
259 SizeType = TargetInfo::UnsignedInt;
260 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
261 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
262 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
273 assert(Triple.getArch() == llvm::Triple::spir64 &&
274 "Invalid architecture for 64-bit SPIR.");
275 PointerWidth = PointerAlign = 64;
276 SizeType = TargetInfo::UnsignedLong;
277 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
278 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
279 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
290 assert(Triple.isSPIRV() &&
"Invalid architecture for SPIR-V.");
294 return Feature ==
"spirv";
305 assert(Triple.getArch() == llvm::Triple::spirv &&
306 "Invalid architecture for Logical SPIR-V.");
307 assert(Triple.getOS() == llvm::Triple::Vulkan &&
308 Triple.getVulkanVersion() != llvm::VersionTuple(0) &&
309 "Logical SPIR-V requires a valid Vulkan environment.");
310 assert(Triple.getEnvironment() >= llvm::Triple::Pixel &&
311 Triple.getEnvironment() <= llvm::Triple::Amplification &&
312 "Logical SPIR-V environment must be a valid shader stage.");
313 PointerWidth = PointerAlign = 64;
316 SizeType = TargetInfo::UnsignedInt;
317 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
318 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
329 assert(Triple.getArch() == llvm::Triple::spirv32 &&
330 "Invalid architecture for 32-bit SPIR-V.");
331 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
332 "32-bit SPIR-V target must use unknown OS");
333 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
334 "32-bit SPIR-V target must use unknown environment type");
335 PointerWidth = PointerAlign = 32;
336 SizeType = TargetInfo::UnsignedInt;
337 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
338 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
339 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
350 assert(Triple.getArch() == llvm::Triple::spirv64 &&
351 "Invalid architecture for 64-bit SPIR-V.");
352 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
353 "64-bit SPIR-V target must use unknown OS");
354 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
355 "64-bit SPIR-V target must use unknown environment type");
356 PointerWidth = PointerAlign = 64;
357 SizeType = TargetInfo::UnsignedLong;
358 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
359 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
360 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
372 assert(Triple.getArch() == llvm::Triple::spirv64 &&
373 "Invalid architecture for 64-bit AMDGCN SPIR-V.");
374 assert(Triple.getVendor() == llvm::Triple::VendorType::AMD &&
375 "64-bit AMDGCN SPIR-V target must use AMD vendor");
376 assert(getTriple().getOS() == llvm::Triple::OSType::AMDHSA &&
377 "64-bit AMDGCN SPIR-V target must use AMDHSA OS");
378 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
379 "64-bit SPIR-V target must use unknown environment type");
380 PointerWidth = PointerAlign = 64;
381 SizeType = TargetInfo::UnsignedLong;
382 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
384 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
385 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1-P4-A0");
387 BFloat16Width = BFloat16Align = 16;
388 BFloat16Format = &llvm::APFloat::BFloat();
390 HasLegalHalfType =
true;
392 HalfArgsAndReturns =
true;
401 const std::vector<std::string> &)
const override;
403 bool validateAsmConstraint(
const char *&Name,
406 std::string convertConstraint(
const char *&Constraint)
const override;
413 void setAuxTarget(
const TargetInfo *Aux)
override;
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)
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< TargetInfo > AllocateTarget(const llvm::Triple &Triple, const TargetOptions &Opts)
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.