13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
22#include "llvm/Support/Compiler.h"
23#include "llvm/Support/VersionTuple.h"
24#include "llvm/TargetParser/Triple.h"
72 std::unique_ptr<TargetInfo> HostTarget;
80 assert((Triple.isSPIR() || Triple.isSPIRV()) &&
81 "Invalid architecture for SPIR or SPIR-V.");
98 if (!HostTriple.isSPIR() && !HostTriple.isSPIRV() &&
99 HostTriple.getArch() != llvm::Triple::UnknownArch) {
105 IntWidth = HostTarget->getIntWidth();
106 IntAlign = HostTarget->getIntAlign();
118 HostTarget->getMinGlobalAlign( 0,
120 NewAlign = HostTarget->getNewAlign();
122 HostTarget->getDefaultAlignForAttributeAligned();
125 WIntType = HostTarget->getWIntType();
134 HostTarget->useZeroLengthBitfieldAlignment();
144 SizeType = HostTarget->getSizeType();
176 return HostTarget->getBuiltinVaListKind();
180 std::optional<unsigned>
210 (Opts.CUDAIsDevice ||
211 getTriple().getVendor() == llvm::Triple::Intel)));
229 assert(Triple.isSPIR() &&
"Invalid architecture for SPIR.");
230 assert(
getTriple().getOS() == llvm::Triple::UnknownOS &&
231 "SPIR target must use unknown OS");
232 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
233 "SPIR target must use unknown environment type");
250 assert(Triple.getArch() == llvm::Triple::spir &&
251 "Invalid architecture for 32-bit SPIR.");
257 if (!HostTarget || HostTarget->getPointerWidth(
LangAS::Default) != 32) {
266 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
277 assert(Triple.getArch() == llvm::Triple::spir64 &&
278 "Invalid architecture for 64-bit SPIR.");
284 if (!HostTarget || HostTarget->getPointerWidth(
LangAS::Default) != 64) {
293 "v96:128-v192:256-v256:256-v512:512-v1024:1024-G1");
304 assert(Triple.isSPIRV() &&
"Invalid architecture for SPIR-V.");
333 assert(Triple.getArch() == llvm::Triple::spirv &&
334 "Invalid architecture for Logical SPIR-V.");
347 if (
getTriple().getOS() != llvm::Triple::Vulkan ||
348 getTriple().getVulkanVersion() == llvm::VersionTuple(0)) {
349 Diags.
Report(diag::err_target_spirv_requires_vulkan);
352 if (
getTriple().getEnvironment() != llvm::Triple::UnknownEnvironment &&
353 (
getTriple().getEnvironment() < llvm::Triple::Pixel ||
354 getTriple().getEnvironment() > llvm::Triple::Amplification)) {
355 Diags.
Report(diag::err_target_spirv_invalid_shader_stage);
369 assert(Triple.getArch() == llvm::Triple::spirv32 &&
370 "Invalid architecture for 32-bit SPIR-V.");
371 assert((
getTriple().getOS() == llvm::Triple::UnknownOS ||
372 getTriple().getOS() == llvm::Triple::ChipStar ||
373 getTriple().getOS() == llvm::Triple::Vulkan) &&
374 "32-bit SPIR-V target must use unknown, chipstar, or vulkan OS");
375 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
376 "32-bit SPIR-V target must use unknown environment type");
382 if (!HostTarget || HostTarget->getPointerWidth(
LangAS::Default) != 32) {
400 assert(Triple.getArch() == llvm::Triple::spirv64 &&
401 "Invalid architecture for 64-bit SPIR-V.");
402 assert((
getTriple().getOS() == llvm::Triple::UnknownOS ||
403 getTriple().getOS() == llvm::Triple::ChipStar ||
404 getTriple().getOS() == llvm::Triple::Vulkan) &&
405 "64-bit SPIR-V target must use unknown, chipstar, or vulkan OS");
406 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
407 "64-bit SPIR-V target must use unknown environment type");
413 if (!HostTarget || HostTarget->getPointerWidth(
LangAS::Default) != 64) {
427 return llvm::omp::SPIRVGridValues;
451 assert(Triple.getArch() == llvm::Triple::spirv64 &&
452 "Invalid architecture for 64-bit AMDGCN SPIR-V.");
453 assert(Triple.getVendor() == llvm::Triple::VendorType::AMD &&
454 "64-bit AMDGCN SPIR-V target must use AMD vendor");
455 assert(
getTriple().getOS() == llvm::Triple::OSType::AMDHSA &&
456 "64-bit AMDGCN SPIR-V target must use AMDHSA OS");
457 assert(
getTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
458 "64-bit SPIR-V target must use unknown environment type");
481 const std::vector<std::string> &)
const override;
483 bool validateAsmConstraint(
const char *&Name,
486 std::string convertConstraint(
const char *&Constraint)
const override;
494 return llvm::omp::SPIRVGridValues;
497 void setAuxTarget(
const TargetInfo *Aux)
override;
510 bool isValidCPUName(StringRef Name)
const override;
519 assert(Triple.getVendor() == llvm::Triple::VendorType::Intel &&
520 "64-bit Intel SPIR-V target must use Intel vendor");
Provides definitions for the various language-specific address spaces.
Defines the Diagnostic-related interfaces.
static StringRef getTriple(const Command &Job)
Defines the clang::TargetOptions class.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
The type of a lookup table which maps from language-specific address spaces to target-specific ones.
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
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
void resetDataLayout(StringRef DL)
Set the data layout to the given string.
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.
const TargetInfo * getHostTarget() const
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)
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.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const override
Returns true if an address space can be safely converted to another.
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.
const llvm::omp::GV & getGridValue() const override
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
bool validateTarget(DiagnosticsEngine &Diags) const override
Check the target is valid after it is fully initialized.
SPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Defines the clang::TargetInfo interface.
static constexpr LangASMap SPIRDefIsPrivMap
static constexpr LangASMap SPIRDefIsGenMap
std::unique_ptr< clang::TargetInfo > AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts)
Top level wrappers for InstallAPI frontend operations.
bool isTargetAddressSpace(LangAS AS)
unsigned toTargetAddressSpace(LangAS AS)
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.
bool VectorsAreElementAligned
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