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/TargetParser/Triple.h"
89 std::unique_ptr<TargetInfo> HostTarget;
94 assert((Triple.isSPIR() || Triple.isSPIRV()) &&
95 "Invalid architecture for SPIR or SPIR-V.");
96 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
97 "SPIR(-V) target must use unknown OS");
98 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
99 "SPIR(-V) target must use unknown environment type");
100 TLSSupported =
false;
101 VLASupported =
false;
102 LongWidth = LongAlign = 64;
104 UseAddrSpaceMapMangling =
true;
105 HasLegalHalfType =
true;
109 NoAsmVariants =
true;
112 if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() &&
113 HostTriple.getArch() != llvm::Triple::UnknownArch) {
117 BoolWidth = HostTarget->getBoolWidth();
118 BoolAlign = HostTarget->getBoolAlign();
119 IntWidth = HostTarget->getIntWidth();
120 IntAlign = HostTarget->getIntAlign();
121 HalfWidth = HostTarget->getHalfWidth();
122 HalfAlign = HostTarget->getHalfAlign();
123 FloatWidth = HostTarget->getFloatWidth();
124 FloatAlign = HostTarget->getFloatAlign();
125 DoubleWidth = HostTarget->getDoubleWidth();
126 DoubleAlign = HostTarget->getDoubleAlign();
127 LongWidth = HostTarget->getLongWidth();
128 LongAlign = HostTarget->getLongAlign();
129 LongLongWidth = HostTarget->getLongLongWidth();
130 LongLongAlign = HostTarget->getLongLongAlign();
131 MinGlobalAlign = HostTarget->getMinGlobalAlign( 0);
132 NewAlign = HostTarget->getNewAlign();
133 DefaultAlignForAttributeAligned =
134 HostTarget->getDefaultAlignForAttributeAligned();
135 IntMaxType = HostTarget->getIntMaxType();
136 WCharType = HostTarget->getWCharType();
137 WIntType = HostTarget->getWIntType();
138 Char16Type = HostTarget->getChar16Type();
139 Char32Type = HostTarget->getChar32Type();
140 Int64Type = HostTarget->getInt64Type();
141 SigAtomicType = HostTarget->getSigAtomicType();
142 ProcessIDType = HostTarget->getProcessIDType();
144 UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment();
145 UseZeroLengthBitfieldAlignment =
146 HostTarget->useZeroLengthBitfieldAlignment();
147 UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
148 ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
154 MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth();
183 return TargetInfo::VoidPtrBuiltinVaList;
186 std::optional<unsigned>
205 TargetInfo::adjust(Diags, Opts);
218 (getTriple().isSPIRV() && Opts.CUDAIsDevice));
224 supportAllOpenCLOpts();
236 assert(Triple.isSPIR() &&
"Invalid architecture for SPIR.");
237 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
238 "SPIR target must use unknown OS");
239 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
240 "SPIR target must use unknown environment type");
247 return Feature ==
"spir";
257 assert(Triple.getArch() == llvm::Triple::spir &&
258 "Invalid architecture for 32-bit SPIR.");
259 PointerWidth = PointerAlign = 32;
260 SizeType = TargetInfo::UnsignedInt;
261 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
262 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
263 "v96:128-v192:256-v256:256-v512:512-v1024:1024");
274 assert(Triple.getArch() == llvm::Triple::spir64 &&
275 "Invalid architecture for 64-bit SPIR.");
276 PointerWidth = PointerAlign = 64;
277 SizeType = TargetInfo::UnsignedLong;
278 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
279 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
280 "v96:128-v192:256-v256:256-v512:512-v1024:1024");
291 assert(Triple.isSPIRV() &&
"Invalid architecture for SPIR-V.");
292 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
293 "SPIR-V target must use unknown OS");
294 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
295 "SPIR-V target must use unknown environment type");
302 return Feature ==
"spirv";
310 assert(Triple.getArch() == llvm::Triple::spirv32 &&
311 "Invalid architecture for 32-bit SPIR-V.");
312 PointerWidth = PointerAlign = 32;
313 SizeType = TargetInfo::UnsignedInt;
314 PtrDiffType = IntPtrType = TargetInfo::SignedInt;
315 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
316 "v96:128-v192:256-v256:256-v512:512-v1024:1024");
327 assert(Triple.getArch() == llvm::Triple::spirv64 &&
328 "Invalid architecture for 64-bit SPIR-V.");
329 PointerWidth = PointerAlign = 64;
330 SizeType = TargetInfo::UnsignedLong;
331 PtrDiffType = IntPtrType = TargetInfo::SignedLong;
332 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
333 "v96:128-v192:256-v256:256-v512:512-v1024:1024");
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.
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)
SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
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)
CallingConv
CallingConv - Specifies the calling convention that a function uses.