16 #include "llvm/ADT/ArrayRef.h" 17 #include "llvm/ADT/StringExtras.h" 19 using namespace clang;
23 #define BUILTIN(ID, TYPE, ATTRS) \ 24 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 25 #include "clang/Basic/BuiltinsNEON.def" 27 #define BUILTIN(ID, TYPE, ATTRS) \ 28 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 29 #define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \ 30 {#ID, TYPE, ATTRS, nullptr, LANG, nullptr}, 31 #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ 32 {#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE}, 33 #include "clang/Basic/BuiltinsAArch64.def" 79 if (Triple.getOS() == llvm::Triple::Linux)
81 else if (Triple.getOS() == llvm::Triple::UnknownOS)
83 Opts.
EABIVersion == llvm::EABI::GNU ?
"\01_mcount" :
"mcount";
89 if (Name !=
"aapcs" && Name !=
"darwinpcs")
97 return Name ==
"generic" ||
98 llvm::AArch64::parseCPUArch(Name) != llvm::AArch64::ArchKind::INVALID;
107 llvm::AArch64::fillValidCPUArchList(Values);
148 if (
getTriple().getOS() == llvm::Triple::UnknownOS &&
172 Builder.
defineMacro(
"__ARM_FEATURE_NUMERIC_MAXMIN",
"1");
173 Builder.
defineMacro(
"__ARM_FEATURE_DIRECTED_ROUNDING",
"1");
175 Builder.
defineMacro(
"__ARM_ALIGN_MAX_STACK_PWR",
"4");
182 Builder.
defineMacro(
"__ARM_FP16_FORMAT_IEEE",
"1");
185 if (Opts.UnsafeFPMath)
189 Twine(Opts.WCharSize ? Opts.WCharSize : 4));
191 Builder.
defineMacro(
"__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ?
"1" :
"4");
193 if (FPU & NeonMode) {
206 Builder.
defineMacro(
"__ARM_FEATURE_UNALIGNED",
"1");
208 if ((FPU & NeonMode) && HasFullFP16)
209 Builder.
defineMacro(
"__ARM_FEATURE_FP16_VECTOR_ARITHMETIC",
"1");
211 Builder.
defineMacro(
"__ARM_FEATURE_FP16_SCALAR_ARITHMETIC",
"1");
217 Builder.
defineMacro(
"__ARM_FEATURE_MEMORY_TAGGING",
"1");
219 if ((FPU & NeonMode) && HasFP16FML)
225 case llvm::AArch64::ArchKind::ARMV8_1A:
228 case llvm::AArch64::ArchKind::ARMV8_2A:
231 case llvm::AArch64::ArchKind::ARMV8_3A:
234 case llvm::AArch64::ArchKind::ARMV8_4A:
237 case llvm::AArch64::ArchKind::ARMV8_5A:
243 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
244 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
245 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
246 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
255 return Feature ==
"aarch64" || Feature ==
"arm64" || Feature ==
"arm" ||
256 (Feature ==
"neon" && (FPU & NeonMode)) ||
257 (Feature ==
"sve" && (FPU & SveMode));
270 ArchKind = llvm::AArch64::ArchKind::ARMV8A;
272 for (
const auto &Feature : Features) {
273 if (Feature ==
"+neon")
275 if (Feature ==
"+sve")
277 if (Feature ==
"+crc")
279 if (Feature ==
"+crypto")
281 if (Feature ==
"+strict-align")
282 HasUnaligned =
false;
283 if (Feature ==
"+v8.1a")
284 ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
285 if (Feature ==
"+v8.2a")
286 ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
287 if (Feature ==
"+v8.3a")
288 ArchKind = llvm::AArch64::ArchKind::ARMV8_3A;
289 if (Feature ==
"+v8.4a")
290 ArchKind = llvm::AArch64::ArchKind::ARMV8_4A;
291 if (Feature ==
"+v8.5a")
292 ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
293 if (Feature ==
"+fullfp16")
295 if (Feature ==
"+dotprod")
297 if (Feature ==
"+fp16fml")
299 if (Feature ==
"+mte")
330 const char *
const AArch64TargetInfo::GCCRegNames[] = {
332 "w0",
"w1",
"w2",
"w3",
"w4",
"w5",
"w6",
"w7",
"w8",
"w9",
"w10",
"w11",
333 "w12",
"w13",
"w14",
"w15",
"w16",
"w17",
"w18",
"w19",
"w20",
"w21",
"w22",
334 "w23",
"w24",
"w25",
"w26",
"w27",
"w28",
"w29",
"w30",
"wsp",
337 "x0",
"x1",
"x2",
"x3",
"x4",
"x5",
"x6",
"x7",
"x8",
"x9",
"x10",
"x11",
338 "x12",
"x13",
"x14",
"x15",
"x16",
"x17",
"x18",
"x19",
"x20",
"x21",
"x22",
339 "x23",
"x24",
"x25",
"x26",
"x27",
"x28",
"fp",
"lr",
"sp",
342 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
"s8",
"s9",
"s10",
"s11",
343 "s12",
"s13",
"s14",
"s15",
"s16",
"s17",
"s18",
"s19",
"s20",
"s21",
"s22",
344 "s23",
"s24",
"s25",
"s26",
"s27",
"s28",
"s29",
"s30",
"s31",
347 "d0",
"d1",
"d2",
"d3",
"d4",
"d5",
"d6",
"d7",
"d8",
"d9",
"d10",
"d11",
348 "d12",
"d13",
"d14",
"d15",
"d16",
"d17",
"d18",
"d19",
"d20",
"d21",
"d22",
349 "d23",
"d24",
"d25",
"d26",
"d27",
"d28",
"d29",
"d30",
"d31",
352 "v0",
"v1",
"v2",
"v3",
"v4",
"v5",
"v6",
"v7",
"v8",
"v9",
"v10",
"v11",
353 "v12",
"v13",
"v14",
"v15",
"v16",
"v17",
"v18",
"v19",
"v20",
"v21",
"v22",
354 "v23",
"v24",
"v25",
"v26",
"v27",
"v28",
"v29",
"v30",
"v31",
357 "z0",
"z1",
"z2",
"z3",
"z4",
"z5",
"z6",
"z7",
"z8",
"z9",
"z10",
358 "z11",
"z12",
"z13",
"z14",
"z15",
"z16",
"z17",
"z18",
"z19",
"z20",
"z21",
359 "z22",
"z23",
"z24",
"z25",
"z26",
"z27",
"z28",
"z29",
"z30",
"z31",
362 "p0",
"p1",
"p2",
"p3",
"p4",
"p5",
"p6",
"p7",
"p8",
"p9",
"p10",
363 "p11",
"p12",
"p13",
"p14",
"p15" 367 return llvm::makeArrayRef(GCCRegNames);
403 {{
"r29",
"x29"},
"fp"},
404 {{
"r30",
"x30"},
"lr"},
410 return llvm::makeArrayRef(GCCRegAliases);
441 llvm_unreachable(
"FIXME: Unimplemented support for U* constraints.");
453 StringRef Constraint,
char Modifier,
unsigned Size,
454 std::string &SuggestedModifier)
const {
456 while (Constraint[0] ==
'=' || Constraint[0] ==
'+' || Constraint[0] ==
'&')
457 Constraint = Constraint.substr(1);
459 switch (Constraint[0]) {
476 SuggestedModifier =
"w";
497 void AArch64leTargetInfo::setDataLayout() {
501 resetDataLayout(
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
522 void AArch64beTargetInfo::setDataLayout() {
523 assert(!
getTriple().isOSBinFormatMachO());
524 resetDataLayout(
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
598 if (TypeSize >= 512) {
600 }
else if (TypeSize >= 64) {
602 }
else if (TypeSize >= 16) {
627 const llvm::Triple &Triple,
650 Triple.getEnvironmentName()),
The generic AArch64 ABI is also a modified version of the Itanium ABI, but it has fewer divergences t...
unsigned char LongLongAlign
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
The iOS 64-bit ABI is follows ARM's published 64-bit ABI more closely, but we don't guarantee to foll...
unsigned char DoubleAlign
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool setABI(const std::string &Name) override
Use the specified ABI.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
void getTargetDefinesARMV84A(const LangOptions &Opts, MacroBuilder &Builder) const
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Options for controlling the target.
unsigned UseSignedCharForObjCBool
Whether Objective-C's built-in boolean type should be signed char.
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
void getTargetDefinesARMV81A(const LangOptions &Opts, MacroBuilder &Builder) const
unsigned char LongDoubleAlign
void getTargetDefinesARMV85A(const LangOptions &Opts, MacroBuilder &Builder) const
__DEVICE__ int max(int __a, int __b)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
unsigned char MaxAtomicPromoteWidth
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features (e.g., +sse4).
The Microsoft ABI is the ABI used by Microsoft Visual Studio (and compatible compilers).
unsigned char SuitableAlign
Concrete class used by the front-end to report problems and issues.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
VersionTuple PlatformMinVersion
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
void setDataLayout() override
bool setCPU(const std::string &Name) override
Target the specified CPU.
AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
unsigned HasBuiltinMSVaList
Exposes information about the current target.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
void resetDataLayout(StringRef DL)
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const llvm::fltSemantics * LongDoubleFormat
Enumerates target-specific builtins in their own namespaces within namespace clang.
DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
unsigned IsRenderScriptTarget
unsigned char LongDoubleWidth
void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, const llvm::Triple &Triple, StringRef &PlatformName, VersionTuple &PlatformMinVersion)
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument...
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4) const override
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
llvm::EABI EABIVersion
The EABI version to use.
unsigned char PointerWidth
MicrosoftARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
StringRef getABI() const override
Get the ABI currently in use.
Dataflow Directional Tag Classes.
virtual unsigned getMinGlobalAlign(uint64_t) const
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
typedef char* __builtin_va_list;
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
void getTargetDefinesARMV82A(const LangOptions &Opts, MacroBuilder &Builder) const
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
RenderScript64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
bool validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size, std::string &SuggestedModifier) const override
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
WindowsARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
Defines the clang::TargetInfo interface.
void getTargetDefinesARMV83A(const LangOptions &Opts, MacroBuilder &Builder) const
unsigned char MaxAtomicInlineWidth
unsigned getMinGlobalAlign(uint64_t TypeSize) const override
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
ArrayRef< const char * > getGCCRegNames() const override
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
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
unsigned short MaxVectorAlign