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"
97 std::unique_ptr<TargetInfo> HostTarget;
102 assert((Triple.isSPIR() || Triple.isSPIRV()) &&
103 "Invalid architecture for SPIR or SPIR-V.");
116 if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() &&
117 HostTriple.getArch() != llvm::Triple::UnknownArch) {
123 IntWidth = HostTarget->getIntWidth();
124 IntAlign = HostTarget->getIntAlign();
136 HostTarget->getMinGlobalAlign( 0,
138 NewAlign = HostTarget->getNewAlign();
140 HostTarget->getDefaultAlignForAttributeAligned();
143 WIntType = HostTarget->getWIntType();
152 HostTarget->useZeroLengthBitfieldAlignment();
190 std::optional<unsigned>
225 (Opts.CUDAIsDevice ||
226 getTriple().getVendor() == llvm::Triple::Intel)));
244 assert(Triple.isSPIR() &&
"Invalid architecture for SPIR.");
245 assert(
getTriple().getOS() == llvm::Triple::UnknownOS &&
246 "SPIR target must use unknown OS");
247 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
248 "SPIR target must use unknown environment type");
265 assert(Triple.getArch() == llvm::Triple::spir &&
266 "Invalid architecture for 32-bit SPIR.");
274 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
285 assert(Triple.getArch() == llvm::Triple::spir64 &&
286 "Invalid architecture for 64-bit SPIR.");
294 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
305 assert(Triple.isSPIRV() &&
"Invalid architecture for SPIR-V.");
322 assert(Triple.getArch() == llvm::Triple::spirv &&
323 "Invalid architecture for Logical SPIR-V.");
324 assert(Triple.getOS() == llvm::Triple::Vulkan &&
325 Triple.getVulkanVersion() != llvm::VersionTuple(0) &&
326 "Logical SPIR-V requires a valid Vulkan environment.");
327 assert(Triple.getEnvironment() >= llvm::Triple::Pixel &&
328 Triple.getEnvironment() <= llvm::Triple::Amplification &&
329 "Logical SPIR-V environment must be a valid shader stage.");
334 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
335 "v256:256-v512:512-v1024:1024-n8:16:32:64-G10");
346 assert(Triple.getArch() == llvm::Triple::spirv32 &&
347 "Invalid architecture for 32-bit SPIR-V.");
348 assert(
getTriple().getOS() == llvm::Triple::UnknownOS &&
349 "32-bit SPIR-V target must use unknown OS");
350 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
351 "32-bit SPIR-V target must use unknown environment type");
358 resetDataLayout(
"e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-"
359 "v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
370 assert(Triple.getArch() == llvm::Triple::spirv64 &&
371 "Invalid architecture for 64-bit SPIR-V.");
372 assert(
getTriple().getOS() == llvm::Triple::UnknownOS &&
373 "64-bit SPIR-V target must use unknown OS");
374 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
375 "64-bit SPIR-V target must use unknown environment type");
382 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
383 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1");
390 return llvm::omp::SPIRVGridValues;
414 assert(Triple.getArch() == llvm::Triple::spirv64 &&
415 "Invalid architecture for 64-bit AMDGCN SPIR-V.");
416 assert(Triple.getVendor() == llvm::Triple::VendorType::AMD &&
417 "64-bit AMDGCN SPIR-V target must use AMD vendor");
418 assert(
getTriple().getOS() == llvm::Triple::OSType::AMDHSA &&
419 "64-bit AMDGCN SPIR-V target must use AMDHSA OS");
420 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
421 "64-bit SPIR-V target must use unknown environment type");
427 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
428 "v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0");
450 const std::vector<std::string> &)
const override;
452 bool validateAsmConstraint(
const char *&Name,
455 std::string convertConstraint(
const char *&Constraint)
const override;
462 void setAuxTarget(
const TargetInfo *Aux)
override;
477 assert(Triple.getVendor() == llvm::Triple::VendorType::Intel &&
478 "64-bit Intel SPIR-V target must use Intel vendor");
479 resetDataLayout(
"e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
480 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1-P9-A0");
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.
TargetInfo(const llvm::Triple &T)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const LangASMap * AddrSpaceMap
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
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 bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts, const TargetInfo *Aux)
Set forced language options.
unsigned char MaxAtomicPromoteWidth
virtual void supportAllOpenCLOpts(bool V=true)
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...
unsigned char MaxAtomicInlineWidth
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.
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts, const TargetInfo *Aux) override
Set forced language options.
ArrayRef< const char * > getGCCRegNames() const override
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
llvm::SmallVector< Builtin::InfosShard > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
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.
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.
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts, const TargetInfo *Aux) override
Set forced language options.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
bool hasBFloat16Type() const override
Determine whether the _BFloat16 type is supported on this target.
SPIRV64AMDGCNTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
SPIRV64IntelTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
std::optional< LangAS > getConstantAddressSpace() const override
Return an AST address space which can be used opportunistically for constant global memory.
void adjust(DiagnosticsEngine &Diags, LangOptions &Opts, const TargetInfo *Aux) override
Set forced language options.
SPIRV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
const llvm::omp::GV & getGridValue() const override
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.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
unsigned char PointerWidth
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield,...
unsigned char DoubleWidth
unsigned char LongLongAlign
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
unsigned char PointerAlign
unsigned char BFloat16Width
unsigned char BFloat16Align
unsigned char DoubleAlign
unsigned char LongLongWidth
unsigned char MinGlobalAlign
const llvm::fltSemantics * BFloat16Format
unsigned char DefaultAlignForAttributeAligned