18#include "llvm/ADT/APSInt.h"
19#include "llvm/ADT/ArrayRef.h"
20#include "llvm/ADT/StringExtras.h"
21#include "llvm/ADT/StringSwitch.h"
22#include "llvm/TargetParser/AArch64TargetParser.h"
23#include "llvm/TargetParser/ARMTargetParserCommon.h"
30#define BUILTIN(ID, TYPE, ATTRS) \
31 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
32#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
33 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
34#include "clang/Basic/BuiltinsNEON.def"
36#define BUILTIN(ID, TYPE, ATTRS) \
37 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
38#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
39 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
40#include "clang/Basic/BuiltinsSVE.def"
42#define BUILTIN(ID, TYPE, ATTRS) \
43 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
44#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
45 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
46#include "clang/Basic/BuiltinsSME.def"
48#define BUILTIN(ID, TYPE, ATTRS) \
49 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
50#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
51 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG},
52#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
53 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
54#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
55 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
56#include "clang/Basic/BuiltinsAArch64.def"
60 if (*ArchInfo == llvm::AArch64::ARMV8R) {
70 }
else if (ArchInfo->Version.getMajor() == 8) {
71 if (ArchInfo->Version.getMinor() >= 7u) {
74 if (ArchInfo->Version.getMinor() >= 6u) {
78 if (ArchInfo->Version.getMinor() >= 5u) {
79 HasAlternativeNZCV =
true;
86 if (ArchInfo->Version.getMinor() >= 4u) {
91 if (ArchInfo->Version.getMinor() >= 3u) {
95 if (ArchInfo->Version.getMinor() >= 2u) {
98 if (ArchInfo->Version.getMinor() >= 1u) {
103 }
else if (ArchInfo->Version.getMajor() == 9) {
104 if (ArchInfo->Version.getMinor() >= 2u) {
107 if (ArchInfo->Version.getMinor() >= 1u) {
114 HasAlternativeNZCV =
true;
154 if (Triple.isArch64Bit())
199 if (Triple.getOS() == llvm::Triple::Linux)
201 else if (Triple.getOS() == llvm::Triple::UnknownOS)
203 Opts.
EABIVersion == llvm::EABI::GNU ?
"\01_mcount" :
"mcount";
209 if (Name !=
"aapcs" && Name !=
"aapcs-soft" && Name !=
"darwinpcs" &&
218 if (
hasFeature(
"fp") && ABI ==
"aapcs-soft") {
221 Diags.
Report(diag::err_target_unsupported_abi_with_fpu) << ABI;
224 if (
getTriple().getEnvironment() == llvm::Triple::PAuthTest &&
225 getTriple().getOS() != llvm::Triple::Linux) {
226 Diags.
Report(diag::err_target_unsupported_abi_for_triple)
234 StringRef RegName,
unsigned RegSize,
bool &HasSizeMismatch)
const {
235 if (RegName ==
"sp") {
236 HasSizeMismatch = RegSize != 64;
239 if (RegName.starts_with(
"w"))
240 HasSizeMismatch = RegSize != 32;
241 else if (RegName.starts_with(
"x"))
242 HasSizeMismatch = RegSize != 64;
245 StringRef RegNum = RegName.drop_front();
248 return RegNum ==
"0" ||
250 llvm::AArch64::isX18ReservedByDefault(
getTriple())) ||
256 StringRef &Err)
const {
257 llvm::ARM::ParsedBranchProtection PBP;
258 if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err, HasPAuthLR))
262 llvm::StringSwitch<LangOptions::SignReturnAddressScopeKind>(PBP.Scope)
267 if (PBP.Key ==
"a_key")
279 return llvm::AArch64::parseCpu(Name).has_value();
288 llvm::AArch64::fillValidCPUArchList(Values);
293 Builder.defineMacro(
"__ARM_FEATURE_QRDMX",
"1");
304 Builder.defineMacro(
"__ARM_FEATURE_COMPLEX",
"1");
305 Builder.defineMacro(
"__ARM_FEATURE_JCVT",
"1");
318 Builder.defineMacro(
"__ARM_FEATURE_FRINT",
"1");
399 Builder.defineMacro(
"__amd64__");
400 Builder.defineMacro(
"__amd64");
401 Builder.defineMacro(
"__x86_64");
402 Builder.defineMacro(
"__x86_64__");
403 Builder.defineMacro(
"__arm64ec__");
405 Builder.defineMacro(
"__aarch64__");
409 Builder.defineMacro(
"__GCC_ASM_FLAG_OUTPUTS__");
412 if (CodeModel ==
"default")
414 for (
char &
c : CodeModel)
416 Builder.defineMacro(
"__AARCH64_CMODEL_" + CodeModel +
"__");
419 Builder.defineMacro(
"__ARM_ACLE_VERSION(year, quarter, patch)",
420 "(100 * (year) + 10 * (quarter) + (patch))");
421#define ARM_ACLE_VERSION(Y, Q, P) (100 * (Y) + 10 * (Q) + (P))
423 Builder.defineMacro(
"__FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL",
425#undef ARM_ACLE_VERSION
426 Builder.defineMacro(
"__ARM_ARCH",
427 std::to_string(ArchInfo->Version.getMajor()));
428 Builder.defineMacro(
"__ARM_ARCH_PROFILE",
429 std::string(
"'") + (
char)ArchInfo->Profile +
"'");
431 Builder.defineMacro(
"__ARM_64BIT_STATE",
"1");
432 Builder.defineMacro(
"__ARM_PCS_AAPCS64",
"1");
433 Builder.defineMacro(
"__ARM_ARCH_ISA_A64",
"1");
435 Builder.defineMacro(
"__ARM_FEATURE_CLZ",
"1");
436 Builder.defineMacro(
"__ARM_FEATURE_FMA",
"1");
437 Builder.defineMacro(
"__ARM_FEATURE_LDREX",
"0xF");
438 Builder.defineMacro(
"__ARM_FEATURE_IDIV",
"1");
439 Builder.defineMacro(
"__ARM_FEATURE_DIV");
440 Builder.defineMacro(
"__ARM_FEATURE_NUMERIC_MAXMIN",
"1");
441 Builder.defineMacro(
"__ARM_FEATURE_DIRECTED_ROUNDING",
"1");
443 Builder.defineMacro(
"__ARM_ALIGN_MAX_STACK_PWR",
"4");
447 Builder.defineMacro(
"__ARM_STATE_ZA",
"1");
448 Builder.defineMacro(
"__ARM_STATE_ZT0",
"1");
452 Builder.defineMacro(
"__ARM_FP",
"0xE");
456 Builder.defineMacro(
"__ARM_FP16_FORMAT_IEEE",
"1");
457 Builder.defineMacro(
"__ARM_FP16_ARGS",
"1");
460 Builder.defineMacro(
"__ARM_NEON_SVE_BRIDGE",
"1");
462 if (Opts.UnsafeFPMath)
463 Builder.defineMacro(
"__ARM_FP_FAST",
"1");
465 Builder.defineMacro(
"__ARM_SIZEOF_WCHAR_T",
466 Twine(Opts.WCharSize ? Opts.WCharSize : 4));
468 Builder.defineMacro(
"__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ?
"1" :
"4");
470 if (FPU & NeonMode) {
471 Builder.defineMacro(
"__ARM_NEON",
"1");
473 Builder.defineMacro(
"__ARM_NEON_FP",
"0xE");
477 Builder.defineMacro(
"__ARM_FEATURE_SVE",
"1");
480 Builder.defineMacro(
"__ARM_FEATURE_SVE2",
"1");
483 Builder.defineMacro(
"__ARM_FEATURE_SVE2p1",
"1");
485 if (HasSVE2 && HasSVEAES)
486 Builder.defineMacro(
"__ARM_FEATURE_SVE2_AES",
"1");
488 if (HasSVE2 && HasSVE2BitPerm)
489 Builder.defineMacro(
"__ARM_FEATURE_SVE2_BITPERM",
"1");
491 if (HasSVE2 && HasSVE2SHA3)
492 Builder.defineMacro(
"__ARM_FEATURE_SVE2_SHA3",
"1");
494 if (HasSVE2 && HasSVE2SM4)
495 Builder.defineMacro(
"__ARM_FEATURE_SVE2_SM4",
"1");
498 Builder.defineMacro(
"__ARM_FEATURE_SVE_B16B16",
"1");
501 Builder.defineMacro(
"__ARM_FEATURE_SME");
502 Builder.defineMacro(
"__ARM_FEATURE_LOCALLY_STREAMING",
"1");
506 Builder.defineMacro(
"__ARM_FEATURE_SME2",
"1");
509 Builder.defineMacro(
"__ARM_FEATURE_SME2p1",
"1");
512 Builder.defineMacro(
"__ARM_FEATURE_SME_F16F16",
"1");
515 Builder.defineMacro(
"__ARM_FEATURE_SME_B16B16",
"1");
518 Builder.defineMacro(
"__ARM_FEATURE_CRC32",
"1");
521 Builder.defineMacro(
"__ARM_FEATURE_RCPC",
"3");
523 Builder.defineMacro(
"__ARM_FEATURE_RCPC",
"1");
526 Builder.defineMacro(
"__HAVE_FUNCTION_MULTI_VERSIONING",
"1");
530 if (HasAES && HasSHA2)
531 Builder.defineMacro(
"__ARM_FEATURE_CRYPTO",
"1");
534 Builder.defineMacro(
"__ARM_FEATURE_AES",
"1");
537 Builder.defineMacro(
"__ARM_FEATURE_SHA2",
"1");
540 Builder.defineMacro(
"__ARM_FEATURE_SHA3",
"1");
541 Builder.defineMacro(
"__ARM_FEATURE_SHA512",
"1");
545 Builder.defineMacro(
"__ARM_FEATURE_SM3",
"1");
546 Builder.defineMacro(
"__ARM_FEATURE_SM4",
"1");
550 Builder.defineMacro(
"__ARM_FEATURE_PAUTH",
"1");
553 Builder.defineMacro(
"__ARM_FEATURE_PAUTH_LR",
"1");
556 Builder.defineMacro(
"__ARM_FEATURE_BTI",
"1");
559 Builder.defineMacro(
"__ARM_FEATURE_UNALIGNED",
"1");
561 if ((FPU & NeonMode) && HasFullFP16)
562 Builder.defineMacro(
"__ARM_FEATURE_FP16_VECTOR_ARITHMETIC",
"1");
564 Builder.defineMacro(
"__ARM_FEATURE_FP16_SCALAR_ARITHMETIC",
"1");
567 Builder.defineMacro(
"__ARM_FEATURE_DOTPROD",
"1");
570 Builder.defineMacro(
"__ARM_FEATURE_MEMORY_TAGGING",
"1");
573 Builder.defineMacro(
"__ARM_FEATURE_TME",
"1");
576 Builder.defineMacro(
"__ARM_FEATURE_MATMUL_INT8",
"1");
579 Builder.defineMacro(
"__ARM_FEATURE_ATOMICS",
"1");
582 Builder.defineMacro(
"__ARM_FEATURE_BF16",
"1");
583 Builder.defineMacro(
"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC",
"1");
584 Builder.defineMacro(
"__ARM_BF16_FORMAT_ALTERNATIVE",
"1");
585 Builder.defineMacro(
"__ARM_FEATURE_BF16_SCALAR_ARITHMETIC",
"1");
588 if ((FPU & SveMode) && HasBFloat16) {
589 Builder.defineMacro(
"__ARM_FEATURE_SVE_BF16",
"1");
592 if ((FPU & SveMode) && HasMatmulFP64)
593 Builder.defineMacro(
"__ARM_FEATURE_SVE_MATMUL_FP64",
"1");
595 if ((FPU & SveMode) && HasMatmulFP32)
596 Builder.defineMacro(
"__ARM_FEATURE_SVE_MATMUL_FP32",
"1");
598 if ((FPU & SveMode) && HasMatMul)
599 Builder.defineMacro(
"__ARM_FEATURE_SVE_MATMUL_INT8",
"1");
601 if ((FPU & NeonMode) && HasFP16FML)
602 Builder.defineMacro(
"__ARM_FEATURE_FP16_FML",
"1");
620 if (Opts.BranchProtectionPAuthLR)
623 Builder.defineMacro(
"__ARM_FEATURE_PAC_DEFAULT", std::to_string(
Value));
626 if (Opts.BranchTargetEnforcement)
627 Builder.defineMacro(
"__ARM_FEATURE_BTI_DEFAULT",
"1");
629 if (Opts.GuardedControlStack)
630 Builder.defineMacro(
"__ARM_FEATURE_GCS_DEFAULT",
"1");
633 Builder.defineMacro(
"__ARM_FEATURE_LS64",
"1");
636 Builder.defineMacro(
"__ARM_FEATURE_RNG",
"1");
639 Builder.defineMacro(
"__ARM_FEATURE_MOPS",
"1");
642 Builder.defineMacro(
"__ARM_FEATURE_SYSREG128",
"1");
645 Builder.defineMacro(
"__ARM_FEATURE_GCS",
"1");
647 if (*ArchInfo == llvm::AArch64::ARMV8_1A)
649 else if (*ArchInfo == llvm::AArch64::ARMV8_2A)
651 else if (*ArchInfo == llvm::AArch64::ARMV8_3A)
653 else if (*ArchInfo == llvm::AArch64::ARMV8_4A)
655 else if (*ArchInfo == llvm::AArch64::ARMV8_5A)
657 else if (*ArchInfo == llvm::AArch64::ARMV8_6A)
659 else if (*ArchInfo == llvm::AArch64::ARMV8_7A)
661 else if (*ArchInfo == llvm::AArch64::ARMV8_8A)
663 else if (*ArchInfo == llvm::AArch64::ARMV8_9A)
665 else if (*ArchInfo == llvm::AArch64::ARMV9A)
667 else if (*ArchInfo == llvm::AArch64::ARMV9_1A)
669 else if (*ArchInfo == llvm::AArch64::ARMV9_2A)
671 else if (*ArchInfo == llvm::AArch64::ARMV9_3A)
673 else if (*ArchInfo == llvm::AArch64::ARMV9_4A)
675 else if (*ArchInfo == llvm::AArch64::ARMV9_5A)
677 else if (*ArchInfo == llvm::AArch64::ARMV9_6A)
681 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
682 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
683 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
684 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
685 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
688 Builder.defineMacro(
"__FP_FAST_FMA",
"1");
689 Builder.defineMacro(
"__FP_FAST_FMAF",
"1");
693 Builder.defineMacro(
"__ARM_FEATURE_SVE_VECTOR_OPERATORS",
"2");
695 if (Opts.VScaleMin && Opts.VScaleMin == Opts.VScaleMax) {
696 Builder.defineMacro(
"__ARM_FEATURE_SVE_BITS", Twine(Opts.VScaleMin * 128));
705std::optional<std::pair<unsigned, unsigned>>
707 if (LangOpts.VScaleMin || LangOpts.VScaleMax)
708 return std::pair<unsigned, unsigned>(
709 LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax);
712 return std::pair<unsigned, unsigned>(1, 16);
718 return llvm::AArch64::getFMVPriority(Features);
723 if (
auto Ext = llvm::AArch64::parseFMVExtension(Name))
724 return Ext->ID.has_value();
731 FeatureStr.split(Features,
"+");
732 for (
auto &Feature : Features)
733 if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value())
739 return llvm::StringSwitch<bool>(Feature)
740 .Cases(
"aarch64",
"arm64",
"arm",
true)
742 .Case(
"fp", FPU & FPUMode)
743 .Cases(
"neon",
"simd", FPU & NeonMode)
744 .Case(
"jscvt", HasJSCVT)
745 .Case(
"fcma", HasFCMA)
746 .Case(
"rng", HasRandGen)
747 .Case(
"flagm", HasFlagM)
748 .Case(
"flagm2", HasAlternativeNZCV)
749 .Case(
"fp16fml", HasFP16FML)
750 .Case(
"dotprod", HasDotProd)
755 .Case(
"sha2", HasSHA2)
756 .Case(
"sha3", HasSHA3)
757 .Cases(
"aes",
"pmull", HasAES)
758 .Cases(
"fp16",
"fullfp16", HasFullFP16)
760 .Case(
"dpb", HasCCPP)
761 .Case(
"dpb2", HasCCDP)
762 .Case(
"rcpc", HasRCPC)
763 .Case(
"frintts", HasFRInt3264)
764 .Case(
"i8mm", HasMatMul)
765 .Case(
"bf16", HasBFloat16)
766 .Case(
"sve", FPU & SveMode)
767 .Case(
"sve-b16b16", HasSVEB16B16)
768 .Case(
"f32mm", FPU & SveMode && HasMatmulFP32)
769 .Case(
"f64mm", FPU & SveMode && HasMatmulFP64)
770 .Case(
"sve2", FPU & SveMode && HasSVE2)
771 .Case(
"sve-aes", HasSVEAES)
772 .Case(
"sve2-bitperm", FPU & SveMode && HasSVE2BitPerm)
773 .Case(
"sve2-sha3", FPU & SveMode && HasSVE2SHA3)
774 .Case(
"sve2-sm4", FPU & SveMode && HasSVE2SM4)
775 .Case(
"sve2p1", FPU & SveMode && HasSVE2p1)
777 .Case(
"sme2", HasSME2)
778 .Case(
"sme2p1", HasSME2p1)
779 .Case(
"sme-f64f64", HasSMEF64F64)
780 .Case(
"sme-i16i64", HasSMEI16I64)
781 .Case(
"sme-fa64", HasSMEFA64)
782 .Case(
"sme-f16f16", HasSMEF16F16)
783 .Case(
"sme-b16b16", HasSMEB16B16)
784 .Case(
"memtag", HasMTE)
786 .Case(
"predres", HasPredRes)
787 .Cases(
"ssbs",
"ssbs2", HasSSBS)
789 .Cases(
"ls64",
"ls64_v",
"ls64_accdata", HasLS64)
790 .Case(
"wfxt", HasWFxT)
791 .Case(
"rcpc3", HasRCPC3)
796 StringRef Name,
bool Enabled)
const {
797 Features[Name] = Enabled;
800 const std::optional<llvm::AArch64::ArchInfo> ArchInfo =
801 llvm::AArch64::ArchInfo::findBySubArch(Name);
810 for (
const auto *OtherArch : llvm::AArch64::ArchInfos)
811 if (ArchInfo->implies(*OtherArch))
812 Features[OtherArch->getSubArch()] =
true;
815 std::vector<StringRef> CPUFeats;
816 if (llvm::AArch64::getExtensionFeatures(ArchInfo->DefaultExts, CPUFeats)) {
817 for (
auto F : CPUFeats) {
818 assert(F[0] ==
'+' &&
"Expected + in target feature!");
819 Features[F.drop_front(1)] =
true;
826 for (
const auto &Feature : Features) {
827 if (Feature ==
"-fp-armv8")
829 if (Feature ==
"-neon")
831 if (Feature ==
"-sve")
834 if (Feature ==
"+neon" || Feature ==
"+fp-armv8")
836 if (Feature ==
"+jscvt") {
840 if (Feature ==
"+fcma") {
845 if (Feature ==
"+sve") {
850 if (Feature ==
"+sve2") {
856 if (Feature ==
"+sve2p1") {
863 if (Feature ==
"+sve-aes") {
868 if (Feature ==
"+sve2-sha3") {
875 if (Feature ==
"+sve2-sm4") {
882 if (Feature ==
"+sve-b16b16")
884 if (Feature ==
"+sve2-bitperm") {
889 HasSVE2BitPerm =
true;
891 if (Feature ==
"+f32mm") {
895 HasMatmulFP32 =
true;
897 if (Feature ==
"+f64mm") {
901 HasMatmulFP64 =
true;
903 if (Feature ==
"+sme") {
908 if (Feature ==
"+sme2") {
914 if (Feature ==
"+sme2p1") {
921 if (Feature ==
"+sme-f64f64") {
927 if (Feature ==
"+sme-i16i64") {
933 if (Feature ==
"+sme-fa64") {
940 if (Feature ==
"+sme-f16f16") {
947 if (Feature ==
"+sme-b16b16") {
955 if (Feature ==
"+sb")
957 if (Feature ==
"+predres")
959 if (Feature ==
"+ssbs")
961 if (Feature ==
"+bti")
963 if (Feature ==
"+wfxt")
965 if (Feature ==
"-fmv")
967 if (Feature ==
"+crc")
969 if (Feature ==
"+rcpc")
971 if (Feature ==
"+aes") {
975 if (Feature ==
"+sha2") {
979 if (Feature ==
"+sha3") {
984 if (Feature ==
"+rdm") {
988 if (Feature ==
"+dit")
990 if (Feature ==
"+cccp")
992 if (Feature ==
"+ccdp") {
996 if (Feature ==
"+fptoint")
998 if (Feature ==
"+sm4") {
1002 if (Feature ==
"+strict-align")
1006 if (Feature ==
"+v8a" && ArchInfo->Version < llvm::AArch64::ARMV8A.Version)
1007 ArchInfo = &llvm::AArch64::ARMV8A;
1008 if (Feature ==
"+v8.1a" &&
1009 ArchInfo->Version < llvm::AArch64::ARMV8_1A.Version)
1010 ArchInfo = &llvm::AArch64::ARMV8_1A;
1011 if (Feature ==
"+v8.2a" &&
1012 ArchInfo->Version < llvm::AArch64::ARMV8_2A.Version)
1013 ArchInfo = &llvm::AArch64::ARMV8_2A;
1014 if (Feature ==
"+v8.3a" &&
1015 ArchInfo->Version < llvm::AArch64::ARMV8_3A.Version)
1016 ArchInfo = &llvm::AArch64::ARMV8_3A;
1017 if (Feature ==
"+v8.4a" &&
1018 ArchInfo->Version < llvm::AArch64::ARMV8_4A.Version)
1019 ArchInfo = &llvm::AArch64::ARMV8_4A;
1020 if (Feature ==
"+v8.5a" &&
1021 ArchInfo->Version < llvm::AArch64::ARMV8_5A.Version)
1022 ArchInfo = &llvm::AArch64::ARMV8_5A;
1023 if (Feature ==
"+v8.6a" &&
1024 ArchInfo->Version < llvm::AArch64::ARMV8_6A.Version)
1025 ArchInfo = &llvm::AArch64::ARMV8_6A;
1026 if (Feature ==
"+v8.7a" &&
1027 ArchInfo->Version < llvm::AArch64::ARMV8_7A.Version)
1028 ArchInfo = &llvm::AArch64::ARMV8_7A;
1029 if (Feature ==
"+v8.8a" &&
1030 ArchInfo->Version < llvm::AArch64::ARMV8_8A.Version)
1031 ArchInfo = &llvm::AArch64::ARMV8_8A;
1032 if (Feature ==
"+v8.9a" &&
1033 ArchInfo->Version < llvm::AArch64::ARMV8_9A.Version)
1034 ArchInfo = &llvm::AArch64::ARMV8_9A;
1035 if (Feature ==
"+v9a" && ArchInfo->Version < llvm::AArch64::ARMV9A.Version)
1036 ArchInfo = &llvm::AArch64::ARMV9A;
1037 if (Feature ==
"+v9.1a" &&
1038 ArchInfo->Version < llvm::AArch64::ARMV9_1A.Version)
1039 ArchInfo = &llvm::AArch64::ARMV9_1A;
1040 if (Feature ==
"+v9.2a" &&
1041 ArchInfo->Version < llvm::AArch64::ARMV9_2A.Version)
1042 ArchInfo = &llvm::AArch64::ARMV9_2A;
1043 if (Feature ==
"+v9.3a" &&
1044 ArchInfo->Version < llvm::AArch64::ARMV9_3A.Version)
1045 ArchInfo = &llvm::AArch64::ARMV9_3A;
1046 if (Feature ==
"+v9.4a" &&
1047 ArchInfo->Version < llvm::AArch64::ARMV9_4A.Version)
1048 ArchInfo = &llvm::AArch64::ARMV9_4A;
1049 if (Feature ==
"+v9.5a" &&
1050 ArchInfo->Version < llvm::AArch64::ARMV9_5A.Version)
1051 ArchInfo = &llvm::AArch64::ARMV9_5A;
1052 if (Feature ==
"+v9.6a" &&
1053 ArchInfo->Version < llvm::AArch64::ARMV9_6A.Version)
1054 ArchInfo = &llvm::AArch64::ARMV9_6A;
1055 if (Feature ==
"+v8r")
1056 ArchInfo = &llvm::AArch64::ARMV8R;
1057 if (Feature ==
"+fullfp16") {
1061 if (Feature ==
"+dotprod") {
1065 if (Feature ==
"+fp16fml") {
1070 if (Feature ==
"+mte")
1072 if (Feature ==
"+tme")
1074 if (Feature ==
"+pauth")
1076 if (Feature ==
"+i8mm")
1078 if (Feature ==
"+bf16")
1080 if (Feature ==
"+lse")
1082 if (Feature ==
"+ls64")
1084 if (Feature ==
"+rand")
1086 if (Feature ==
"+flagm")
1088 if (Feature ==
"+altnzcv") {
1090 HasAlternativeNZCV =
true;
1092 if (Feature ==
"+mops")
1094 if (Feature ==
"+d128")
1096 if (Feature ==
"+gcs")
1098 if (Feature ==
"+rcpc3")
1100 if (Feature ==
"+pauth-lr") {
1109 for (
const auto &Feature : Features) {
1110 if (Feature ==
"-d128")
1145 if (Features ==
"default")
1148 Features.split(AttrFeatures,
",");
1149 bool FoundArch =
false;
1151 auto SplitAndAddFeatures = [](StringRef FeatString,
1152 std::vector<std::string> &Features,
1153 llvm::AArch64::ExtensionSet &FeatureBits) {
1155 FeatString.split(SplitFeatures, StringRef(
"+"), -1,
false);
1156 for (StringRef Feature : SplitFeatures) {
1157 if (FeatureBits.parseModifier(Feature))
1165 if (Feature.starts_with(
"no"))
1166 Features.push_back(
"-" + Feature.drop_front(2).str());
1168 Features.push_back(
"+" + Feature.str());
1172 llvm::AArch64::ExtensionSet FeatureBits;
1177 for (
auto &Feature : AttrFeatures) {
1178 Feature = Feature.trim();
1179 if (Feature.starts_with(
"fpmath="))
1182 if (Feature.starts_with(
"branch-protection=")) {
1183 Ret.BranchProtection = Feature.split(
'=').second.trim();
1187 if (Feature.starts_with(
"arch=")) {
1189 Ret.Duplicate =
"arch=";
1191 std::pair<StringRef, StringRef> Split =
1192 Feature.split(
"=").second.trim().split(
"+");
1193 const llvm::AArch64::ArchInfo *AI = llvm::AArch64::parseArch(Split.first);
1199 FeatureBits.addArchDefaults(*AI);
1201 SplitAndAddFeatures(Split.second, Ret.Features, FeatureBits);
1202 }
else if (Feature.starts_with(
"cpu=")) {
1203 if (!Ret.CPU.empty())
1204 Ret.Duplicate =
"cpu=";
1208 std::pair<StringRef, StringRef> Split =
1209 Feature.split(
"=").second.trim().split(
"+");
1210 Ret.CPU = Split.first;
1211 if (
auto CpuInfo = llvm::AArch64::parseCpu(Ret.CPU)) {
1212 FeatureBits.addCPUDefaults(*CpuInfo);
1213 SplitAndAddFeatures(Split.second, Ret.Features, FeatureBits);
1216 }
else if (Feature.starts_with(
"tune=")) {
1217 if (!Ret.Tune.empty())
1218 Ret.Duplicate =
"tune=";
1220 Ret.Tune = Feature.split(
"=").second.trim();
1221 }
else if (Feature.starts_with(
"+")) {
1222 SplitAndAddFeatures(Feature, Ret.Features, FeatureBits);
1224 if (FeatureBits.parseModifier(Feature,
true))
1232 if (Feature.starts_with(
"no-"))
1233 Ret.Features.push_back(
"-" + Feature.drop_front(3).str());
1235 Ret.Features.push_back(
"+" + Feature.str());
1238 FeatureBits.toLLVMFeatureList(Ret.Features);
1271const char *
const AArch64TargetInfo::GCCRegNames[] = {
1275 "w0",
"w1",
"w2",
"w3",
"w4",
"w5",
"w6",
"w7",
"w8",
"w9",
"w10",
"w11",
1276 "w12",
"w13",
"w14",
"w15",
"w16",
"w17",
"w18",
"w19",
"w20",
"w21",
"w22",
1277 "w23",
"w24",
"w25",
"w26",
"w27",
"w28",
"w29",
"w30",
"wsp",
1280 "x0",
"x1",
"x2",
"x3",
"x4",
"x5",
"x6",
"x7",
"x8",
"x9",
"x10",
"x11",
1281 "x12",
"x13",
"x14",
"x15",
"x16",
"x17",
"x18",
"x19",
"x20",
"x21",
"x22",
1282 "x23",
"x24",
"x25",
"x26",
"x27",
"x28",
"fp",
"lr",
"sp",
1285 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
"s8",
"s9",
"s10",
"s11",
1286 "s12",
"s13",
"s14",
"s15",
"s16",
"s17",
"s18",
"s19",
"s20",
"s21",
"s22",
1287 "s23",
"s24",
"s25",
"s26",
"s27",
"s28",
"s29",
"s30",
"s31",
1290 "d0",
"d1",
"d2",
"d3",
"d4",
"d5",
"d6",
"d7",
"d8",
"d9",
"d10",
"d11",
1291 "d12",
"d13",
"d14",
"d15",
"d16",
"d17",
"d18",
"d19",
"d20",
"d21",
"d22",
1292 "d23",
"d24",
"d25",
"d26",
"d27",
"d28",
"d29",
"d30",
"d31",
1295 "v0",
"v1",
"v2",
"v3",
"v4",
"v5",
"v6",
"v7",
"v8",
"v9",
"v10",
"v11",
1296 "v12",
"v13",
"v14",
"v15",
"v16",
"v17",
"v18",
"v19",
"v20",
"v21",
"v22",
1297 "v23",
"v24",
"v25",
"v26",
"v27",
"v28",
"v29",
"v30",
"v31",
1300 "z0",
"z1",
"z2",
"z3",
"z4",
"z5",
"z6",
"z7",
"z8",
"z9",
"z10",
1301 "z11",
"z12",
"z13",
"z14",
"z15",
"z16",
"z17",
"z18",
"z19",
"z20",
"z21",
1302 "z22",
"z23",
"z24",
"z25",
"z26",
"z27",
"z28",
"z29",
"z30",
"z31",
1305 "p0",
"p1",
"p2",
"p3",
"p4",
"p5",
"p6",
"p7",
"p8",
"p9",
"p10",
1306 "p11",
"p12",
"p13",
"p14",
"p15",
1309 "pn0",
"pn1",
"pn2",
"pn3",
"pn4",
"pn5",
"pn6",
"pn7",
"pn8",
1310 "pn9",
"pn10",
"pn11",
"pn12",
"pn13",
"pn14",
"pn15",
1355 {{
"r29",
"x29"},
"fp"},
1356 {{
"r30",
"x30"},
"lr"},
1367 constexpr unsigned len = 5;
1368 auto RV = llvm::StringSwitch<unsigned>(Name)
1392 switch (*Constraint) {
1394 R = std::string(
"@3") + std::string(Constraint, 3);
1399 std::string Converted =
"{" + std::string(Constraint, Len) +
"}";
1400 Constraint += Len - 1;
1403 return std::string(1, *Constraint);
1435 if (Name[1] ==
'p' &&
1436 (Name[2] ==
'l' || Name[2] ==
'a' || Name[2] ==
'h')) {
1442 if (Name[1] ==
'c' && (Name[2] ==
'i' || Name[2] ==
'j')) {
1477 StringRef Constraint,
char Modifier,
unsigned Size,
1478 std::string &SuggestedModifier)
const {
1480 Constraint = Constraint.ltrim(
"=+&");
1482 switch (Constraint[0]) {
1502 SuggestedModifier =
"w";
1520 const llvm::APSInt &value)
const {
1521 return 0 <= value && value <= 3;
1530void AArch64leTargetInfo::setDataLayout() {
1533 resetDataLayout(
"e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-"
1534 "i128:128-n32:64-S128-Fn32",
1537 resetDataLayout(
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-"
1541 resetDataLayout(
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-"
1542 "i64:64-i128:128-n32:64-S128-Fn32");
1547 Builder.defineMacro(
"__AARCH64EL__");
1557 Builder.defineMacro(
"__AARCH64EB__");
1558 Builder.defineMacro(
"__AARCH_BIG_ENDIAN");
1559 Builder.defineMacro(
"__ARM_BIG_ENDIAN");
1563void AArch64beTargetInfo::setDataLayout() {
1564 assert(!
getTriple().isOSBinFormatMachO());
1565 resetDataLayout(
"E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-"
1566 "i64:64-i128:128-n32:64-S128-Fn32");
1575 IntWidth = IntAlign = 32;
1576 LongWidth = LongAlign = 32;
1577 DoubleAlign = LongLongAlign = 64;
1578 LongDoubleWidth = LongDoubleAlign = 64;
1579 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
1580 IntMaxType = SignedLongLong;
1581 Int64Type = SignedLongLong;
1582 SizeType = UnsignedLongLong;
1583 PtrDiffType = SignedLongLong;
1584 IntPtrType = SignedLongLong;
1588 resetDataLayout(Triple.isOSBinFormatMachO()
1589 ?
"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:"
1590 "128-n32:64-S128-Fn32"
1591 :
"e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-"
1592 "i64:64-i128:128-n32:64-S128-Fn32",
1593 Triple.isOSBinFormatMachO() ?
"_" :
"");
1605 if (getTriple().isWindowsArm64EC())
1622 return CCCR_Warning;
1629 TheCXXABI.set(TargetCXXABI::Microsoft);
1635 if (getTriple().isWindowsArm64EC()) {
1636 Builder.defineMacro(
"_M_X64",
"100");
1637 Builder.defineMacro(
"_M_AMD64",
"100");
1638 Builder.defineMacro(
"_M_ARM64EC",
"1");
1640 Builder.defineMacro(
"_M_ARM64",
"1");
1646 return CCK_MicrosoftWin64;
1650 bool HasNonWeakDef)
const {
1652 WindowsARM64TargetInfo::getMinGlobalAlign(TypeSize, HasNonWeakDef);
1658 if (TypeSize >= 512) {
1659 Align = std::max(Align, 128u);
1660 }
else if (TypeSize >= 64) {
1661 Align = std::max(Align, 64u);
1662 }
else if (TypeSize >= 16) {
1663 Align = std::max(Align, 32u);
1671 TheCXXABI.set(TargetCXXABI::GenericAArch64);
1677 Int64Type = SignedLongLong;
1678 if (getTriple().isArch32Bit())
1679 IntMaxType = SignedLongLong;
1681 WCharType = SignedInt;
1682 UseSignedCharForObjCBool =
false;
1684 LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64;
1685 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
1687 UseZeroLengthBitfieldAlignment =
false;
1689 if (getTriple().isArch32Bit()) {
1690 UseBitFieldTypeAlignment =
false;
1691 ZeroLengthBitfieldBoundary = 32;
1692 UseZeroLengthBitfieldAlignment =
true;
1693 TheCXXABI.set(TargetCXXABI::WatchOS);
1695 TheCXXABI.set(TargetCXXABI::AppleARM64);
1699 const llvm::Triple &Triple,
1701 Builder.defineMacro(
"__AARCH64_SIMD__");
1702 if (Triple.isArch32Bit())
1703 Builder.defineMacro(
"__ARM64_ARCH_8_32__");
1705 Builder.defineMacro(
"__ARM64_ARCH_8__");
1706 Builder.defineMacro(
"__ARM_NEON__");
1707 Builder.defineMacro(
"__REGISTER_PREFIX__",
"");
1708 Builder.defineMacro(
"__arm64",
"1");
1709 Builder.defineMacro(
"__arm64__",
"1");
1711 if (Triple.isArm64e())
1712 Builder.defineMacro(
"__arm64e__",
"1");
Defines the Diagnostic-related interfaces.
static unsigned matchAsmCCConstraint(const char *Name)
#define ARM_ACLE_VERSION(Y, Q, P)
static constexpr Builtin::Info BuiltinInfo[]
static constexpr Builtin::Info BuiltinInfo[]
Defines the clang::LangOptions interface.
Enumerates target-specific builtins in their own namespaces within namespace clang.
__device__ __2f16 float c
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
@ None
No signing for any function.
@ NonLeaf
Sign the return address of functions that spill LR.
@ All
Sign the return address of all functions,.
@ BKey
Return address signing uses APIB key.
@ AKey
Return address signing uses APIA key.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isSignReturnAddressWithAKey() const
Check if return address signing uses AKey.
bool hasSignReturnAddress() const
Check if return address signing is enabled.
bool isSignReturnAddressScopeAll() const
Check if leaf functions are also signed.
LangOptions::SignReturnAddressScopeKind SignReturnAddr
LangOptions::SignReturnAddressKeyKind SignKey
bool BranchProtectionPAuthLR
bool BranchTargetEnforcement
Exposes information about the current target.
TargetOptions & getTargetOpts() const
Retrieve the target options.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const LangASMap * AddrSpaceMap
unsigned HasAArch64SVETypes
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
@ AArch64ABIBuiltinVaList
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com....
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
unsigned HasUnalignedAccess
unsigned char MaxAtomicPromoteWidth
virtual std::string convertConstraint(const char *&Constraint) const
unsigned char MaxAtomicInlineWidth
unsigned HasBuiltinMSVaList
Options for controlling the target.
llvm::EABI EABIVersion
The EABI version to use.
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line.
llvm::StringMap< bool > FeatureMap
The map of which features have been enabled disabled based on the command line.
void getTargetDefinesARMV95A(const LangOptions &Opts, MacroBuilder &Builder) const
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
std::string convertConstraint(const char *&Constraint) const override
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
bool hasBFloat16Type() const override
Determine whether the _BFloat16 type is supported on this target.
ParsedTargetAttr parseTargetAttr(StringRef Str) const override
void getTargetDefinesARMV96A(const LangOptions &Opts, MacroBuilder &Builder) const
AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
ArrayRef< const char * > getGCCRegNames() const override
bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const override
Validate register name used for global register variables.
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features (e.g., +sse4).
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
void setFeatureEnabled(llvm::StringMap< bool > &Features, StringRef Name, bool Enabled) const override
Enable or disable a specific target feature; the feature name must be valid.
void getTargetDefinesARMV89A(const LangOptions &Opts, MacroBuilder &Builder) const
void getTargetDefinesARMV92A(const LangOptions &Opts, MacroBuilder &Builder) const
unsigned getFMVPriority(ArrayRef< StringRef > Features) const override
bool validateTarget(DiagnosticsEngine &Diags) const override
Check the target is valid after it is fully initialized.
void getTargetDefinesARMV93A(const LangOptions &Opts, MacroBuilder &Builder) const
bool setABI(const std::string &Name) override
Use the specified ABI.
void getTargetDefinesARMV84A(const LangOptions &Opts, MacroBuilder &Builder) const
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
StringRef getABI() const override
Get the ABI currently in use.
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
void getTargetDefinesARMV88A(const LangOptions &Opts, MacroBuilder &Builder) const
bool validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, StringRef &Err) const override
Determine if this TargetInfo supports the given branch protection specification.
void getTargetDefinesARMV87A(const LangOptions &Opts, MacroBuilder &Builder) const
void getTargetDefinesARMV9A(const LangOptions &Opts, MacroBuilder &Builder) const
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
void getTargetDefinesARMV91A(const LangOptions &Opts, MacroBuilder &Builder) const
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
void getTargetDefinesARMV81A(const LangOptions &Opts, MacroBuilder &Builder) const
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
void getTargetDefinesARMV86A(const LangOptions &Opts, MacroBuilder &Builder) const
bool setCPU(const std::string &Name) override
Target the specified CPU.
std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts) const override
Returns target-specific min and max values VScale_Range.
void getTargetDefinesARMV94A(const LangOptions &Opts, MacroBuilder &Builder) const
bool validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size, std::string &SuggestedModifier) const override
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
void getTargetDefinesARMV82A(const LangOptions &Opts, MacroBuilder &Builder) const
void getTargetDefinesARMV83A(const LangOptions &Opts, MacroBuilder &Builder) const
bool validateCpuSupports(StringRef FeatureStr) const override
bool validatePointerAuthKey(const llvm::APSInt &value) const override
Determine whether the given pointer-authentication key is valid.
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
bool doesFeatureAffectCodeGen(StringRef Name) const override
Returns true if feature has an impact on target code generation.
void getTargetDefinesARMV85A(const LangOptions &Opts, MacroBuilder &Builder) const
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
BuiltinVaListKind getBuiltinVaListKind() const override
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
unsigned getMinGlobalAlign(uint64_t TypeSize, bool HasNonWeakDef) const override
MicrosoftARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4) const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
BuiltinVaListKind getBuiltinVaListKind() const override
WindowsARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void setDataLayout() override
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Defines the clang::TargetInfo interface.
static const unsigned ARM64AddrSpaceMap[]
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Contains information gathered from parsing the contents of TargetAttr.
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
unsigned short SuitableAlign
unsigned char PointerWidth
const llvm::fltSemantics * LongDoubleFormat
std::optional< unsigned > BitIntMaxAlign
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
unsigned char PointerAlign
unsigned char BFloat16Width
unsigned char LongDoubleAlign
unsigned char LongDoubleWidth
unsigned char BFloat16Align
const llvm::fltSemantics * BFloat16Format