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.");
48 if (!
Feature.starts_with(
"+ptx") ||
49 Feature.drop_front(4).getAsInteger(10, PTXV))
71 if (TargetPointerWidth == 32)
72 resetDataLayout(
"e-p:32:32-p6:32:32-p7:32:32-i64:64-i128:128-i256:256-v16:"
73 "16-v32:32-n16:32:64");
75 resetDataLayout(
"e-p3:32:32-p4:32:32-p5:32:32-p6:32:32-p7:32:32-i64:64-"
76 "i128:128-i256:256-v16:"
77 "16-v32:32-n16:32:64");
80 "e-p6:32:32-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64");
85 if (!HostTriple.isNVPTX())
92 switch (TargetPointerWidth) {
104 llvm_unreachable(
"TargetPointerWidth must be 32 or 64");
116 IntWidth = HostTarget->getIntWidth();
117 IntAlign = HostTarget->getIntAlign();
130 NewAlign = HostTarget->getNewAlign();
132 HostTarget->getDefaultAlignForAttributeAligned();
133 SizeType = HostTarget->getSizeType();
138 WIntType = HostTarget->getWIntType();
173 return llvm::StringSwitch<bool>(
Feature)
174 .Cases(
"ptx",
"nvptx",
true)
180 Builder.defineMacro(
"__PTX__");
181 Builder.defineMacro(
"__NVPTX__");
187 if (Opts.CUDAIsDevice || Opts.OpenMPIsTargetDevice || !HostTarget) {
189 llvm::StringRef CUDAArchCode = [
this] {
250 assert(
false &&
"No GPU arch when compiling CUDA device code.");
310 llvm_unreachable(
"unhandled OffloadArch");
312 Builder.defineMacro(
"__CUDA_ARCH__", CUDAArchCode);
320 Builder.defineMacro(
"__CUDA_ARCH_FEAT_SM" + CUDAArchCode.drop_back() +
"_ALL",
"1");
static constexpr llvm::StringTable BuiltinStrings
static constexpr Builtin::Info BuiltinInfos[]
static constexpr int NumBuiltins
static constexpr Builtin::Info BuiltinInfos[]
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 -----------------------—===//
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
static const unsigned NVPTXAddrSpaceMap[]
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.
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