17#include "llvm/ADT/StringSwitch.h"
25#define GET_BUILTIN_STR_TABLE
26#include "clang/Basic/BuiltinsNVPTX.inc"
27#undef GET_BUILTIN_STR_TABLE
30#define GET_BUILTIN_INFOS
31#include "clang/Basic/BuiltinsNVPTX.inc"
32#undef GET_BUILTIN_INFOS
36const char *
const NVPTXTargetInfo::GCCRegNames[] = {
"r0"};
40 unsigned TargetPointerWidth)
42 assert((TargetPointerWidth == 32 || TargetPointerWidth == 64) &&
43 "NVPTX only supports 32- and 64-bit modes.");
50 if (!
Feature.starts_with(
"+ptx") ||
51 Feature.drop_front(4).getAsInteger(10, PTXV))
71#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) \
72 ReadOnlyFeatures.insert(NAME);
73#include "llvm/TargetParser/NVPTXTargetParser.def"
84 if (!HostTriple.isNVPTX())
91 switch (TargetPointerWidth) {
103 llvm_unreachable(
"TargetPointerWidth must be 32 or 64");
115 IntWidth = HostTarget->getIntWidth();
116 IntAlign = HostTarget->getIntAlign();
129 NewAlign = HostTarget->getNewAlign();
131 HostTarget->getDefaultAlignForAttributeAligned();
132 SizeType = HostTarget->getSizeType();
137 WIntType = HostTarget->getWIntType();
168 if (Name !=
"shortptr")
180 return llvm::StringSwitch<bool>(
Feature)
181 .Cases({
"ptx",
"nvptx"},
true)
187 Builder.defineMacro(
"__PTX__");
188 Builder.defineMacro(
"__NVPTX__");
194 if (Opts.CUDAIsDevice || Opts.OpenMPIsTargetDevice || !HostTarget) {
197 Builder.defineMacro(
"__CUDA_ARCH__", llvm::Twine(ArchID));
200 Builder.defineMacro(
"__CUDA_ARCH_SPECIFIC__", llvm::Twine(ArchID));
202 "__CUDA_ARCH_FEAT_SM" + llvm::Twine(ArchID / 10) +
"_ALL",
"1");
205 Builder.defineMacro(
"__CUDA_ARCH_FAMILY_SPECIFIC__", llvm::Twine(ArchID));
static constexpr llvm::StringTable BuiltinStrings
static constexpr Builtin::Info BuiltinInfos[]
static constexpr unsigned NumBuiltins
Defines enum values for all the target-independent builtin functions.
Defines the clang::MacroBuilder utility class.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static constexpr OffloadArch getUnused()
TargetInfo(const llvm::Triple &T)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const LangASMap * AddrSpaceMap
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...
void resetDataLayout()
Set the data layout based on current triple and ABI.
std::string DataLayoutString
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.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts, unsigned TargetPointerWidth)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
llvm::SmallVector< Builtin::InfosShard > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
ArrayRef< const char * > getGCCRegNames() const override
bool setABI(const std::string &Name) override
Use the specified ABI.
static constexpr LangASMap NVPTXAddrSpaceMap
std::unique_ptr< clang::TargetInfo > AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts)
Top level wrappers for InstallAPI frontend operations.
unsigned CudaArchToID(OffloadArch Arch)
Get the numeric ID (e.g. 700) of a CUDA architecture.
@ Default
Set to the current date and time.
bool IsNVIDIAAcceleratedOffloadArch(OffloadArch Arch)
Check if the CUDA architecture is an accelerated variant (e.g. sm_90a).
bool IsNVIDIAFamilySpecificOffloadArch(OffloadArch Arch)
Check if the CUDA architecture is a family-specific variant (e.g. sm_100f).
The info used to represent each builtin.
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