13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
19 #include "llvm/IR/DataLayout.h"
20 #include "llvm/Support/Compiler.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/VersionTuple.h"
24 #include "llvm/TargetParser/Triple.h"
96 std::unique_ptr<TargetInfo> HostTarget;
101 assert((Triple.isSPIR() || Triple.isSPIRV()) &&
102 "Invalid architecture for SPIR or SPIR-V.");
103 TLSSupported =
false;
104 VLASupported =
false;
105 LongWidth = LongAlign = 64;
107 UseAddrSpaceMapMangling =
true;
108 HasLegalHalfType =
true;
112 NoAsmVariants =
true;
115 if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() &&
116 HostTriple.getArch() != llvm::Triple::UnknownArch) {
120 BoolWidth = HostTarget->getBoolWidth();
121 BoolAlign = HostTarget->getBoolAlign();
122 IntWidth = HostTarget->getIntWidth();
123 IntAlign = HostTarget->getIntAlign();
124 HalfWidth = HostTarget->getHalfWidth();
125 HalfAlign = HostTarget->getHalfAlign();
126 FloatWidth = HostTarget->getFloatWidth();
127 FloatAlign = HostTarget->getFloatAlign();
128 DoubleWidth = HostTarget->getDoubleWidth();
129 DoubleAlign = HostTarget->getDoubleAlign();
130 LongWidth = HostTarget->getLongWidth();
131 LongAlign = HostTarget->getLongAlign();
132 LongLongWidth = HostTarget->getLongLongWidth();
133 LongLongAlign = HostTarget->getLongLongAlign();
135 HostTarget->getMinGlobalAlign( 0,
137 NewAlign = HostTarget->getNewAlign();
138 DefaultAlignForAttributeAligned =
139 HostTarget->getDefaultAlignForAttributeAligned();
140 IntMaxType = HostTarget->getIntMaxType();
141 WCharType = HostTarget->getWCharType();
142 WIntType = HostTarget->getWIntType();
143 Char16Type = HostTarget->getChar16Type();
144 Char32Type = HostTarget->getChar32Type();
145 Int64Type = HostTarget->getInt64Type();
146 SigAtomicType = HostTarget->getSigAtomicType();
147 ProcessIDType = HostTarget->getProcessIDType();
149 UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment();
150 UseZeroLengthBitfieldAlignment =
151 HostTarget->useZeroLengthBitfieldAlignment();
152 UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment();
153 ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
159 MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth();
191 std::optional<unsigned>
228 (getTriple().isSPIRV() && Opts.CUDAIsDevice));
234 supportAllOpenCLOpts();
246 assert(Triple.isSPIR() &&
"Invalid architecture for SPIR.");
253 return Feature ==
"spir";
263 assert(Triple.getArch() == llvm::Triple::spir &&
264 "Invalid architecture for 32-bit SPIR.");
265 PointerWidth = PointerAlign = 32;
269 "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
270 "v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
281 assert(Triple.getArch() == llvm::Triple::spir64 &&
282 "Invalid architecture for 64-bit SPIR.");
283 PointerWidth = PointerAlign = 64;
288 "e-i64:64-v16:16-v24:32-v32:32-v48:64-"
289 "v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
311 DoubleAlign = LongLongAlign = 64;
312 WCharType = UnsignedShort;
344 Builder.defineMacro(
"_M_IX86",
"600");
355 LongWidth = LongAlign = 32;
356 DoubleAlign = LongLongAlign = 64;
357 IntMaxType = SignedLongLong;
358 Int64Type = SignedLongLong;
359 SizeType = UnsignedLongLong;
360 PtrDiffType = SignedLongLong;
361 IntPtrType = SignedLongLong;
362 WCharType = UnsignedShort;
392 Builder.defineMacro(
"_M_X64",
"100");
393 Builder.defineMacro(
"_M_AMD64",
"100");
401 assert(Triple.isSPIRV() &&
"Invalid architecture for SPIR-V.");
405 return Feature ==
"spirv";
416 assert(Triple.getArch() == llvm::Triple::spirv &&
417 "Invalid architecture for Logical SPIR-V.");
418 assert(Triple.getOS() == llvm::Triple::Vulkan &&
419 Triple.getVulkanVersion() != llvm::VersionTuple(0) &&
420 "Logical SPIR-V requires a valid Vulkan environment.");
421 assert(Triple.getEnvironment() >= llvm::Triple::Pixel &&
422 Triple.getEnvironment() <= llvm::Triple::Amplification &&
423 "Logical SPIR-V environment must be a valid shader stage.");
424 PointerWidth = PointerAlign = 64;
428 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
429 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
440 assert(Triple.getArch() == llvm::Triple::spirv32 &&
441 "Invalid architecture for 32-bit SPIR-V.");
442 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
443 "32-bit SPIR-V target must use unknown OS");
444 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
445 "32-bit SPIR-V target must use unknown environment type");
446 PointerWidth = PointerAlign = 32;
449 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-"
450 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
461 assert(Triple.getArch() == llvm::Triple::spirv64 &&
462 "Invalid architecture for 64-bit SPIR-V.");
463 assert(getTriple().getOS() == llvm::Triple::UnknownOS &&
464 "64-bit SPIR-V target must use unknown OS");
465 assert(getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
466 "64-bit SPIR-V target must use unknown environment type");
467 PointerWidth = PointerAlign = 64;
470 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-"
471 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
485 DoubleAlign = LongLongAlign = 64;
486 WCharType = UnsignedShort;
516 Builder.defineMacro(
"_M_IX86",
"600");
527 LongWidth = LongAlign = 32;
528 DoubleAlign = LongLongAlign = 64;
529 IntMaxType = SignedLongLong;
530 Int64Type = SignedLongLong;
531 SizeType = UnsignedLongLong;
532 PtrDiffType = SignedLongLong;
533 IntPtrType = SignedLongLong;
534 WCharType = UnsignedShort;
563 Builder.defineMacro(
"_M_X64",
"100");
564 Builder.defineMacro(
"_M_AMD64",
"100");
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.
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts)
Set forced language options.
Options for controlling the target.
std::string HostTriple
When compiling for the device side, contains the triple used to compile for the host.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() 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)
std::optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const override
ArrayRef< const char * > getGCCRegNames() const override
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
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.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
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)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
MicrosoftX86_32SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
MicrosoftX86_32SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
MicrosoftX86_64_SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
MicrosoftX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
SPIR32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
SPIR64FPGATargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
virtual size_t getMaxBitIntWidth() const override
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)
SPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
WindowsX86_32SPIRTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
BuiltinVaListKind getBuiltinVaListKind() const override
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
WindowsX86_32SPIRV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
BuiltinVaListKind getBuiltinVaListKind() const override
WindowsX86_64_SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
BuiltinVaListKind getBuiltinVaListKind() const override
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
BuiltinVaListKind getBuiltinVaListKind() const override
WindowsX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
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.