18 #include "llvm/ADT/StringSwitch.h" 20 using namespace clang;
24 #define BUILTIN(ID, TYPE, ATTRS) \ 25 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 26 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ 27 {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, 28 #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ 29 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, 30 #include "clang/Basic/BuiltinsNVPTX.def" 33 const char *
const NVPTXTargetInfo::GCCRegNames[] = {
"r0"};
37 unsigned TargetPointerWidth)
39 assert((TargetPointerWidth == 32 || TargetPointerWidth == 64) &&
40 "NVPTX only supports 32- and 64-bit modes.");
44 if (!Feature.startswith(
"+ptx"))
46 PTXVersion = llvm::StringSwitch<unsigned>(Feature)
70 if (TargetPointerWidth == 32)
74 "e-p3:32:32-p4:32:32-p5:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
81 if (!HostTriple.isNVPTX())
88 switch (TargetPointerWidth) {
100 llvm_unreachable(
"TargetPointerWidth must be 32 or 64");
110 IntWidth = HostTarget->getIntWidth();
111 IntAlign = HostTarget->getIntAlign();
123 NewAlign = HostTarget->getNewAlign();
125 HostTarget->getDefaultAlignForAttributeAligned();
126 SizeType = HostTarget->getSizeType();
131 WIntType = HostTarget->getWIntType();
162 return llvm::makeArrayRef(GCCRegNames);
166 return llvm::StringSwitch<bool>(Feature)
167 .Cases(
"ptx",
"nvptx",
true)
175 if (Opts.CUDAIsDevice) {
177 std::string CUDAArchCode = [
this] {
202 assert(
false &&
"No GPU arch when compiling CUDA device code.");
235 llvm_unreachable(
"unhandled CudaArch");
237 Builder.
defineMacro(
"__CUDA_ARCH__", CUDAArchCode);
unsigned char LongLongAlign
Defines the clang::MacroBuilder utility class.
unsigned char DoubleAlign
Options for controlling the target.
std::string HostTriple
When compiling for the device side, contains the triple used to compile for the host.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
ArrayRef< const char * > getGCCRegNames() const override
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
NVPTXTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts, unsigned TargetPointerWidth)
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
unsigned char DefaultAlignForAttributeAligned
Exposes information about the current target.
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
TargetInfo * AllocateTarget(const llvm::Triple &Triple, const TargetOptions &Opts)
Enumerates target-specific builtins in their own namespaces within namespace clang.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
const LangASMap * AddrSpaceMap
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
unsigned char PointerWidth
unsigned char LongLongWidth
Dataflow Directional Tag Classes.
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield...
unsigned char MinGlobalAlign
bool NVPTXUseShortPointers
If enabled, use 32-bit pointers for accessing const/local/shared address space.
static const unsigned NVPTXAddrSpaceMap[]
unsigned char DoubleWidth
unsigned char MaxAtomicInlineWidth
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
unsigned char PointerAlign
void resetDataLayout(StringRef DL)
Defines enum values for all the target-independent builtin functions.
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...