18#include "llvm/ADT/StringSwitch.h"
24#define BUILTIN(ID, TYPE, ATTRS) \
25 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
26#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
27 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
28#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
29 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
30#include "clang/Basic/BuiltinsNVPTX.def"
33const char *
const NVPTXTargetInfo::GCCRegNames[] = {
"r0"};
37 unsigned TargetPointerWidth)
39 assert((TargetPointerWidth == 32 || TargetPointerWidth == 64) &&
40 "NVPTX only supports 32- and 64-bit modes.");
45 if (!Feature.starts_with(
"+ptx") ||
46 Feature.drop_front(4).getAsInteger(10, PTXV))
68 if (TargetPointerWidth == 32)
72 "e-p3:32:32-p4:32:32-p5:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
79 if (!HostTriple.isNVPTX())
86 switch (TargetPointerWidth) {
98 llvm_unreachable(
"TargetPointerWidth must be 32 or 64");
110 IntWidth = HostTarget->getIntWidth();
111 IntAlign = HostTarget->getIntAlign();
124 NewAlign = HostTarget->getNewAlign();
126 HostTarget->getDefaultAlignForAttributeAligned();
127 SizeType = HostTarget->getSizeType();
132 WIntType = HostTarget->getWIntType();
167 return llvm::StringSwitch<bool>(Feature)
168 .Cases(
"ptx",
"nvptx",
true)
174 Builder.defineMacro(
"__PTX__");
175 Builder.defineMacro(
"__NVPTX__");
181 if (Opts.CUDAIsDevice || Opts.OpenMPIsTargetDevice || !HostTarget) {
183 std::string CUDAArchCode = [
this] {
240 assert(
false &&
"No GPU arch when compiling CUDA device code.");
285 llvm_unreachable(
"unhandled OffloadArch");
287 Builder.defineMacro(
"__CUDA_ARCH__", CUDAArchCode);
289 Builder.defineMacro(
"__CUDA_ARCH_FEAT_SM90_ALL",
"1");
static constexpr Builtin::Info BuiltinInfo[]
static constexpr Builtin::Info BuiltinInfo[]
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...
Exposes information about the current target.
const LangASMap * AddrSpaceMap
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
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.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
bool NVPTXUseShortPointers
If enabled, use 32-bit pointers for accessing const/local/shared address space.
NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts, unsigned TargetPointerWidth)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
ArrayRef< const char * > getGCCRegNames() const override
static const unsigned NVPTXAddrSpaceMap[]
std::unique_ptr< TargetInfo > AllocateTarget(const llvm::Triple &Triple, const TargetOptions &Opts)
The JSON file list parser is used to communicate input to InstallAPI.
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