16 #include "llvm/ADT/ArrayRef.h" 17 #include "llvm/ADT/StringExtras.h" 18 #include "llvm/ADT/StringSwitch.h" 19 #include "llvm/Support/AArch64TargetParser.h" 21 using namespace clang;
25 #define BUILTIN(ID, TYPE, ATTRS) \ 26 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 27 #include "clang/Basic/BuiltinsNEON.def" 29 #define BUILTIN(ID, TYPE, ATTRS) \ 30 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 31 #define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \ 32 {#ID, TYPE, ATTRS, nullptr, LANG, nullptr}, 33 #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ 34 {#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE}, 35 #include "clang/Basic/BuiltinsAArch64.def" 56 if (Triple.isArch64Bit())
95 if (Triple.getOS() == llvm::Triple::Linux)
97 else if (Triple.getOS() == llvm::Triple::UnknownOS)
99 Opts.
EABIVersion == llvm::EABI::GNU ?
"\01_mcount" :
"mcount";
105 if (Name !=
"aapcs" && Name !=
"darwinpcs")
114 StringRef &Err)
const {
115 llvm::AArch64::ParsedBranchProtection PBP;
116 if (!llvm::AArch64::parseBranchProtection(Spec, PBP, Err))
120 llvm::StringSwitch<CodeGenOptions::SignReturnAddressScope>(PBP.Scope)
125 if (PBP.Key ==
"a_key")
135 return Name ==
"generic" ||
136 llvm::AArch64::parseCPUArch(Name) != llvm::AArch64::ArchKind::INVALID;
145 llvm::AArch64::fillValidCPUArchList(Values);
187 if (
getTriple().getOS() == llvm::Triple::UnknownOS &&
211 Builder.
defineMacro(
"__ARM_FEATURE_NUMERIC_MAXMIN",
"1");
212 Builder.
defineMacro(
"__ARM_FEATURE_DIRECTED_ROUNDING",
"1");
214 Builder.
defineMacro(
"__ARM_ALIGN_MAX_STACK_PWR",
"4");
221 Builder.
defineMacro(
"__ARM_FP16_FORMAT_IEEE",
"1");
224 if (Opts.UnsafeFPMath)
228 Twine(Opts.WCharSize ? Opts.WCharSize : 4));
230 Builder.
defineMacro(
"__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ?
"1" :
"4");
232 if (FPU & NeonMode) {
245 Builder.
defineMacro(
"__ARM_FEATURE_UNALIGNED",
"1");
247 if ((FPU & NeonMode) && HasFullFP16)
248 Builder.
defineMacro(
"__ARM_FEATURE_FP16_VECTOR_ARITHMETIC",
"1");
250 Builder.
defineMacro(
"__ARM_FEATURE_FP16_SCALAR_ARITHMETIC",
"1");
256 Builder.
defineMacro(
"__ARM_FEATURE_MEMORY_TAGGING",
"1");
261 if ((FPU & NeonMode) && HasFP16FML)
267 case llvm::AArch64::ArchKind::ARMV8_1A:
270 case llvm::AArch64::ArchKind::ARMV8_2A:
273 case llvm::AArch64::ArchKind::ARMV8_3A:
276 case llvm::AArch64::ArchKind::ARMV8_4A:
279 case llvm::AArch64::ArchKind::ARMV8_5A:
285 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
286 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
287 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
288 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
297 return Feature ==
"aarch64" || Feature ==
"arm64" || Feature ==
"arm" ||
298 (Feature ==
"neon" && (FPU & NeonMode)) ||
299 (Feature ==
"sve" && (FPU & SveMode));
313 ArchKind = llvm::AArch64::ArchKind::ARMV8A;
315 for (
const auto &Feature : Features) {
316 if (Feature ==
"+neon")
318 if (Feature ==
"+sve")
320 if (Feature ==
"+crc")
322 if (Feature ==
"+crypto")
324 if (Feature ==
"+strict-align")
325 HasUnaligned =
false;
326 if (Feature ==
"+v8.1a")
327 ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
328 if (Feature ==
"+v8.2a")
329 ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
330 if (Feature ==
"+v8.3a")
331 ArchKind = llvm::AArch64::ArchKind::ARMV8_3A;
332 if (Feature ==
"+v8.4a")
333 ArchKind = llvm::AArch64::ArchKind::ARMV8_4A;
334 if (Feature ==
"+v8.5a")
335 ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
336 if (Feature ==
"+fullfp16")
338 if (Feature ==
"+dotprod")
340 if (Feature ==
"+fp16fml")
342 if (Feature ==
"+mte")
344 if (Feature ==
"+tme")
375 const char *
const AArch64TargetInfo::GCCRegNames[] = {
377 "w0",
"w1",
"w2",
"w3",
"w4",
"w5",
"w6",
"w7",
"w8",
"w9",
"w10",
"w11",
378 "w12",
"w13",
"w14",
"w15",
"w16",
"w17",
"w18",
"w19",
"w20",
"w21",
"w22",
379 "w23",
"w24",
"w25",
"w26",
"w27",
"w28",
"w29",
"w30",
"wsp",
382 "x0",
"x1",
"x2",
"x3",
"x4",
"x5",
"x6",
"x7",
"x8",
"x9",
"x10",
"x11",
383 "x12",
"x13",
"x14",
"x15",
"x16",
"x17",
"x18",
"x19",
"x20",
"x21",
"x22",
384 "x23",
"x24",
"x25",
"x26",
"x27",
"x28",
"fp",
"lr",
"sp",
387 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
"s8",
"s9",
"s10",
"s11",
388 "s12",
"s13",
"s14",
"s15",
"s16",
"s17",
"s18",
"s19",
"s20",
"s21",
"s22",
389 "s23",
"s24",
"s25",
"s26",
"s27",
"s28",
"s29",
"s30",
"s31",
392 "d0",
"d1",
"d2",
"d3",
"d4",
"d5",
"d6",
"d7",
"d8",
"d9",
"d10",
"d11",
393 "d12",
"d13",
"d14",
"d15",
"d16",
"d17",
"d18",
"d19",
"d20",
"d21",
"d22",
394 "d23",
"d24",
"d25",
"d26",
"d27",
"d28",
"d29",
"d30",
"d31",
397 "v0",
"v1",
"v2",
"v3",
"v4",
"v5",
"v6",
"v7",
"v8",
"v9",
"v10",
"v11",
398 "v12",
"v13",
"v14",
"v15",
"v16",
"v17",
"v18",
"v19",
"v20",
"v21",
"v22",
399 "v23",
"v24",
"v25",
"v26",
"v27",
"v28",
"v29",
"v30",
"v31",
402 "z0",
"z1",
"z2",
"z3",
"z4",
"z5",
"z6",
"z7",
"z8",
"z9",
"z10",
403 "z11",
"z12",
"z13",
"z14",
"z15",
"z16",
"z17",
"z18",
"z19",
"z20",
"z21",
404 "z22",
"z23",
"z24",
"z25",
"z26",
"z27",
"z28",
"z29",
"z30",
"z31",
407 "p0",
"p1",
"p2",
"p3",
"p4",
"p5",
"p6",
"p7",
"p8",
"p9",
"p10",
408 "p11",
"p12",
"p13",
"p14",
"p15" 412 return llvm::makeArrayRef(GCCRegNames);
448 {{
"r29",
"x29"},
"fp"},
449 {{
"r30",
"x30"},
"lr"},
455 return llvm::makeArrayRef(GCCRegAliases);
486 llvm_unreachable(
"FIXME: Unimplemented support for U* constraints.");
498 StringRef Constraint,
char Modifier,
unsigned Size,
499 std::string &SuggestedModifier)
const {
501 while (Constraint[0] ==
'=' || Constraint[0] ==
'+' || Constraint[0] ==
'&')
502 Constraint = Constraint.substr(1);
504 switch (Constraint[0]) {
521 SuggestedModifier =
"w";
544 void AArch64leTargetInfo::setDataLayout() {
551 resetDataLayout(
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
572 void AArch64beTargetInfo::setDataLayout() {
573 assert(!
getTriple().isOSBinFormatMachO());
574 resetDataLayout(
"E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
648 if (TypeSize >= 512) {
650 }
else if (TypeSize >= 64) {
652 }
else if (TypeSize >= 16) {
689 const llvm::Triple &Triple,
692 if (Triple.isArch32Bit())
715 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
CodeGenOptions::SignReturnAddressKeyValue SignKey
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
unsigned HasAArch64SVETypes
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.
CodeGenOptions::SignReturnAddressScope SignReturnAddr
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.
bool validateBranchProtection(StringRef, BranchProtectionInfo &, StringRef &) const override
Determine if this TargetInfo supports the given branch protection specification.
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 --------------------——===//
bool BranchTargetEnforcement
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const llvm::fltSemantics * LongDoubleFormat
WatchOS is a modernisation of the iOS ABI, which roughly means it's the iOS64 ABI ported to 32-bits...
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...
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield...
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 hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
void resetDataLayout(StringRef DL)
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
unsigned short MaxVectorAlign