17#include "llvm/ADT/StringExtras.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/ADT/StringSwitch.h"
20#include "llvm/TargetParser/ARMTargetParser.h"
25void ARMTargetInfo::setABIAAPCS() {
34 bool IsNetBSD =
T.isOSNetBSD();
35 bool IsOpenBSD =
T.isOSOpenBSD();
36 if (!
T.isOSWindows() && !IsNetBSD && !IsOpenBSD)
45 if (
T.isOSBinFormatMachO()) {
47 ?
"E-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
48 :
"e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
50 }
else if (
T.isOSWindows()) {
51 assert(!
BigEndian &&
"Windows on ARM does not support big endian");
61 }
else if (
T.isOSNaCl()) {
62 assert(!
BigEndian &&
"NaCl on ARM does not support big endian");
63 resetDataLayout(
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S128");
66 ?
"E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
67 :
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
73void ARMTargetInfo::setABIAPCS(
bool IsAAPCS16) {
96 if (
T.isOSBinFormatMachO() && IsAAPCS16) {
97 assert(!
BigEndian &&
"AAPCS16 does not support big-endian");
99 }
else if (
T.isOSBinFormatMachO())
102 ?
"E-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
103 :
"e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32",
108 ?
"E-m:e-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
109 :
"e-m:e-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
114void ARMTargetInfo::setArchInfo() {
115 StringRef ArchName =
getTriple().getArchName();
117 ArchISA = llvm::ARM::parseArchISA(ArchName);
118 CPU = std::string(llvm::ARM::getDefaultCPU(ArchName));
119 llvm::ARM::ArchKind AK = llvm::ARM::parseArch(ArchName);
120 if (AK != llvm::ARM::ArchKind::INVALID)
122 setArchInfo(ArchKind);
125void ARMTargetInfo::setArchInfo(llvm::ARM::ArchKind Kind) {
130 SubArch = llvm::ARM::getSubArch(ArchKind);
131 ArchProfile = llvm::ARM::parseArchProfile(SubArch);
132 ArchVersion = llvm::ARM::parseArchVersion(SubArch);
135 CPUAttr = getCPUAttr();
136 CPUProfile = getCPUProfile();
139void ARMTargetInfo::setAtomic() {
142 bool ShouldUseInlineAtomic =
143 (ArchISA == llvm::ARM::ISAKind::ARM && ArchVersion >= 6) ||
144 (ArchISA == llvm::ARM::ISAKind::THUMB && ArchVersion >= 7);
146 if (ArchProfile == llvm::ARM::ProfileKind::M) {
148 if (ShouldUseInlineAtomic)
152 if (ShouldUseInlineAtomic)
157bool ARMTargetInfo::hasMVE()
const {
158 return ArchKind == llvm::ARM::ArchKind::ARMV8_1MMainline && MVE != 0;
161bool ARMTargetInfo::hasMVEFloat()
const {
162 return hasMVE() && (MVE & MVE_FP);
167bool ARMTargetInfo::isThumb()
const {
168 return ArchISA == llvm::ARM::ISAKind::THUMB;
171bool ARMTargetInfo::supportsThumb()
const {
172 return CPUAttr.count(
'T') || ArchVersion >= 6;
175bool ARMTargetInfo::supportsThumb2()
const {
176 return CPUAttr ==
"6T2" || (ArchVersion >= 7 && CPUAttr !=
"8M_BASE");
179StringRef ARMTargetInfo::getCPUAttr()
const {
184 return llvm::ARM::getCPUAttr(ArchKind);
185 case llvm::ARM::ArchKind::ARMV6M:
187 case llvm::ARM::ArchKind::ARMV7S:
189 case llvm::ARM::ArchKind::ARMV7A:
191 case llvm::ARM::ArchKind::ARMV7R:
193 case llvm::ARM::ArchKind::ARMV7M:
195 case llvm::ARM::ArchKind::ARMV7EM:
197 case llvm::ARM::ArchKind::ARMV7VE:
199 case llvm::ARM::ArchKind::ARMV8A:
201 case llvm::ARM::ArchKind::ARMV8_1A:
203 case llvm::ARM::ArchKind::ARMV8_2A:
205 case llvm::ARM::ArchKind::ARMV8_3A:
207 case llvm::ARM::ArchKind::ARMV8_4A:
209 case llvm::ARM::ArchKind::ARMV8_5A:
211 case llvm::ARM::ArchKind::ARMV8_6A:
213 case llvm::ARM::ArchKind::ARMV8_7A:
215 case llvm::ARM::ArchKind::ARMV8_8A:
217 case llvm::ARM::ArchKind::ARMV8_9A:
219 case llvm::ARM::ArchKind::ARMV9A:
221 case llvm::ARM::ArchKind::ARMV9_1A:
223 case llvm::ARM::ArchKind::ARMV9_2A:
225 case llvm::ARM::ArchKind::ARMV9_3A:
227 case llvm::ARM::ArchKind::ARMV9_4A:
229 case llvm::ARM::ArchKind::ARMV9_5A:
231 case llvm::ARM::ArchKind::ARMV9_6A:
233 case llvm::ARM::ArchKind::ARMV8MBaseline:
235 case llvm::ARM::ArchKind::ARMV8MMainline:
237 case llvm::ARM::ArchKind::ARMV8R:
239 case llvm::ARM::ArchKind::ARMV8_1MMainline:
244StringRef ARMTargetInfo::getCPUProfile()
const {
245 switch (ArchProfile) {
246 case llvm::ARM::ProfileKind::A:
248 case llvm::ARM::ProfileKind::R:
250 case llvm::ARM::ProfileKind::M:
259 :
TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(
true), LDREX(0),
261 bool IsFreeBSD = Triple.isOSFreeBSD();
262 bool IsOpenBSD = Triple.isOSOpenBSD();
263 bool IsNetBSD = Triple.isOSNetBSD();
264 bool IsHaiku = Triple.isOSHaiku();
265 bool IsOHOS = Triple.isOHOSFamily();
271 (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD ||
276 SizeType = (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD ||
282 if ((Triple.isOSDarwin() || Triple.isOSBinFormatMachO()) &&
283 !Triple.isWatchABI())
296 if (Triple.isOSBinFormatMachO()) {
299 if (Triple.getEnvironment() == llvm::Triple::EABI ||
300 Triple.getOS() == llvm::Triple::UnknownOS ||
301 ArchProfile == llvm::ARM::ProfileKind::M) {
303 }
else if (Triple.isWatchABI()) {
308 }
else if (Triple.isOSWindows()) {
313 switch (Triple.getEnvironment()) {
314 case llvm::Triple::Android:
315 case llvm::Triple::GNUEABI:
316 case llvm::Triple::GNUEABIT64:
317 case llvm::Triple::GNUEABIHF:
318 case llvm::Triple::GNUEABIHFT64:
319 case llvm::Triple::MuslEABI:
320 case llvm::Triple::MuslEABIHF:
321 case llvm::Triple::OpenHOS:
324 case llvm::Triple::EABIHF:
325 case llvm::Triple::EABI:
328 case llvm::Triple::GNU:
334 else if (IsFreeBSD || IsOpenBSD || IsHaiku || IsOHOS)
350 if (IsAAPCS && !Triple.isAndroid())
359 if (Triple.getOS() == llvm::Triple::Linux ||
360 Triple.getOS() == llvm::Triple::UnknownOS)
362 ?
"llvm.arm.gnu.eabi.mcount"
377 if (Name ==
"apcs-gnu" || Name ==
"aapcs16") {
378 setABIAPCS(Name ==
"aapcs16");
381 if (Name ==
"aapcs" || Name ==
"aapcs-vfp" || Name ==
"aapcs-linux") {
389 llvm::ARM::ArchKind CPUArch = llvm::ARM::parseCPUArch(Arch);
390 if (CPUArch == llvm::ARM::ArchKind::INVALID)
391 CPUArch = llvm::ARM::parseArch(
getTriple().getArchName());
393 if (CPUArch == llvm::ARM::ArchKind::INVALID)
396 StringRef ArchFeature = llvm::ARM::getArchName(CPUArch);
398 llvm::Triple(ArchFeature,
getTriple().getVendorName(),
401 StringRef SubArch = llvm::ARM::getSubArch(CPUArch);
402 llvm::ARM::ProfileKind Profile = llvm::ARM::parseArchProfile(SubArch);
403 return a.isArmT32() && (Profile == llvm::ARM::ProfileKind::M);
408 StringRef &Err)
const {
409 llvm::ARM::ParsedBranchProtection PBP;
410 if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err))
417 llvm::StringSwitch<LangOptions::SignReturnAddressScopeKind>(PBP.Scope)
423 if (PBP.Key ==
"b_key")
435 const std::vector<std::string> &FeaturesVec)
const {
437 std::string ArchFeature;
438 std::vector<StringRef> TargetFeatures;
439 llvm::ARM::ArchKind Arch = llvm::ARM::parseArch(
getTriple().getArchName());
443 llvm::ARM::ArchKind CPUArch = llvm::ARM::parseCPUArch(CPU);
444 if (CPUArch == llvm::ARM::ArchKind::INVALID)
446 if (CPUArch != llvm::ARM::ArchKind::INVALID) {
447 ArchFeature = (
"+" + llvm::ARM::getArchName(CPUArch)).str();
448 TargetFeatures.push_back(ArchFeature);
454 for (llvm::ARM::ArchKind I = llvm::ARM::convertV9toV8(CPUArch);
455 I != llvm::ARM::ArchKind::INVALID; --I)
456 Features[llvm::ARM::getSubArch(I)] =
true;
457 if (CPUArch > llvm::ARM::ArchKind::ARMV8A &&
458 CPUArch <= llvm::ARM::ArchKind::ARMV9_3A)
459 for (llvm::ARM::ArchKind I = CPUArch; I != llvm::ARM::ArchKind::INVALID;
461 Features[llvm::ARM::getSubArch(I)] =
true;
465 llvm::ARM::FPUKind FPUKind = llvm::ARM::getDefaultFPU(CPU, Arch);
466 llvm::ARM::getFPUFeatures(FPUKind, TargetFeatures);
469 uint64_t Extensions = llvm::ARM::getDefaultExtensions(CPU, Arch);
470 llvm::ARM::getExtensionFeatures(Extensions, TargetFeatures);
472 for (
auto Feature : TargetFeatures)
473 if (Feature[0] ==
'+')
474 Features[Feature.drop_front(1)] =
true;
479 Features[
"thumb-mode"] =
true;
481 Features[
"thumb-mode"] =
false;
485 std::vector<std::string> UpdatedFeaturesVec;
486 for (
const auto &Feature : FeaturesVec) {
489 if (Feature ==
"+soft-float-abi")
492 StringRef FixedFeature;
493 if (Feature ==
"+arm")
494 FixedFeature =
"-thumb-mode";
495 else if (Feature ==
"+thumb")
496 FixedFeature =
"+thumb-mode";
498 FixedFeature = Feature;
499 UpdatedFeaturesVec.push_back(FixedFeature.str());
527 FPRegsDisabled =
false;
531 for (
const auto &Feature : Features) {
532 if (Feature ==
"+soft-float") {
534 }
else if (Feature ==
"+vfp2sp" || Feature ==
"+vfp2") {
537 if (Feature ==
"+vfp2")
539 }
else if (Feature ==
"+vfp3sp" || Feature ==
"+vfp3d16sp" ||
540 Feature ==
"+vfp3" || Feature ==
"+vfp3d16") {
543 if (Feature ==
"+vfp3" || Feature ==
"+vfp3d16")
545 }
else if (Feature ==
"+vfp4sp" || Feature ==
"+vfp4d16sp" ||
546 Feature ==
"+vfp4" || Feature ==
"+vfp4d16") {
548 HW_FP |= HW_FP_SP | HW_FP_HP;
549 if (Feature ==
"+vfp4" || Feature ==
"+vfp4d16")
551 }
else if (Feature ==
"+fp-armv8sp" || Feature ==
"+fp-armv8d16sp" ||
552 Feature ==
"+fp-armv8" || Feature ==
"+fp-armv8d16") {
554 HW_FP |= HW_FP_SP | HW_FP_HP;
555 if (Feature ==
"+fp-armv8" || Feature ==
"+fp-armv8d16")
557 }
else if (Feature ==
"+neon") {
560 }
else if (Feature ==
"+hwdiv") {
562 }
else if (Feature ==
"+hwdiv-arm") {
564 }
else if (Feature ==
"+crc") {
566 }
else if (Feature ==
"+crypto") {
568 }
else if (Feature ==
"+sha2") {
570 }
else if (Feature ==
"+aes") {
572 }
else if (Feature ==
"+dsp") {
574 }
else if (Feature ==
"+fp64") {
576 }
else if (Feature ==
"+8msecext") {
577 if (CPUProfile !=
"M" || ArchVersion != 8) {
578 Diags.
Report(diag::err_target_unsupported_mcmse) << CPU;
581 }
else if (Feature ==
"+strict-align") {
583 }
else if (Feature ==
"+fp16") {
585 }
else if (Feature ==
"+fullfp16") {
587 }
else if (Feature ==
"+dotprod") {
589 }
else if (Feature ==
"+mve") {
591 }
else if (Feature ==
"+mve.fp") {
594 MVE |= MVE_INT | MVE_FP;
595 HW_FP |= HW_FP_SP | HW_FP_HP;
596 }
else if (Feature ==
"+i8mm") {
598 }
else if (Feature.size() == strlen(
"+cdecp0") && Feature >=
"+cdecp0" &&
599 Feature <=
"+cdecp7") {
600 unsigned Coproc = Feature.back() -
'0';
602 }
else if (Feature ==
"+bf16") {
604 }
else if (Feature ==
"-fpregs") {
605 FPRegsDisabled =
true;
606 }
else if (Feature ==
"+pacbti") {
609 }
else if (Feature ==
"+fullbf16") {
616 switch (ArchVersion) {
618 if (ArchProfile == llvm::ARM::ProfileKind::M)
620 else if (ArchKind == llvm::ARM::ArchKind::ARMV6K)
621 LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
626 if (ArchProfile == llvm::ARM::ProfileKind::M)
627 LDREX = LDREX_W | LDREX_H | LDREX_B;
629 LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
633 LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
636 if (!(FPU & NeonFPU) && FPMath == FP_Neon) {
637 Diags.
Report(diag::err_target_unsupported_fpmath) <<
"neon";
641 if (FPMath == FP_Neon)
642 Features.push_back(
"+neonfp");
643 else if (FPMath == FP_VFP)
644 Features.push_back(
"-neonfp");
650 return llvm::StringSwitch<bool>(Feature)
652 .Case(
"aarch32",
true)
653 .Case(
"softfloat", SoftFloat)
654 .Case(
"thumb", isThumb())
655 .Case(
"neon", (FPU & NeonFPU) && !SoftFloat)
656 .Case(
"vfp", FPU && !SoftFloat)
657 .Case(
"hwdiv", HWDiv & HWDivThumb)
658 .Case(
"hwdiv-arm", HWDiv & HWDivARM)
659 .Case(
"mve", hasMVE())
669 return Name ==
"generic" ||
670 llvm::ARM::parseCPUArch(Name) != llvm::ARM::ArchKind::INVALID;
674 llvm::ARM::fillValidCPUArchList(Values);
678 if (Name !=
"generic")
679 setArchInfo(llvm::ARM::parseCPUArch(Name));
681 if (ArchKind == llvm::ARM::ArchKind::INVALID)
689 if (Name ==
"neon") {
692 }
else if (Name ==
"vfp" || Name ==
"vfp2" || Name ==
"vfp3" ||
702 Builder.defineMacro(
"__ARM_FEATURE_QRDMX",
"1");
714 Builder.defineMacro(
"__ARM_FEATURE_COMPLEX",
"1");
721 Builder.defineMacro(
"__arm");
722 Builder.defineMacro(
"__arm__");
724 if (
getTriple().getOS() == llvm::Triple::UnknownOS &&
725 (
getTriple().getEnvironment() == llvm::Triple::EABI ||
726 getTriple().getEnvironment() == llvm::Triple::EABIHF) &&
728 Builder.defineMacro(
"_GNU_SOURCE");
732 Builder.defineMacro(
"__REGISTER_PREFIX__",
"");
737 Builder.defineMacro(
"__ARM_ARCH_7K__",
"2");
739 if (!CPUAttr.empty())
740 Builder.defineMacro(
"__ARM_ARCH_" + CPUAttr +
"__");
744 Builder.defineMacro(
"__ARM_ARCH", Twine(ArchVersion));
746 if (ArchVersion >= 8) {
751 Builder.defineMacro(
"__ARM_FEATURE_CRYPTO",
"1");
753 Builder.defineMacro(
"__ARM_FEATURE_SHA2",
"1");
755 Builder.defineMacro(
"__ARM_FEATURE_AES",
"1");
758 Builder.defineMacro(
"__ARM_FEATURE_CRC32",
"1");
760 Builder.defineMacro(
"__ARM_FEATURE_NUMERIC_MAXMIN",
"1");
762 Builder.defineMacro(
"__ARM_FEATURE_DIRECTED_ROUNDING",
"1");
768 if (CPUProfile.empty() || ArchProfile != llvm::ARM::ProfileKind::M)
769 Builder.defineMacro(
"__ARM_ARCH_ISA_ARM",
"1");
775 if (supportsThumb2())
776 Builder.defineMacro(
"__ARM_ARCH_ISA_THUMB",
"2");
777 else if (supportsThumb())
778 Builder.defineMacro(
"__ARM_ARCH_ISA_THUMB",
"1");
782 Builder.defineMacro(
"__ARM_32BIT_STATE",
"1");
787 if (!CPUProfile.empty())
788 Builder.defineMacro(
"__ARM_ARCH_PROFILE",
"'" + CPUProfile +
"'");
792 Builder.defineMacro(
"__ARM_FEATURE_UNALIGNED",
"1");
796 Builder.defineMacro(
"__ARM_FEATURE_LDREX",
"0x" + Twine::utohexstr(LDREX));
799 if (ArchVersion == 5 || (ArchVersion == 6 && CPUProfile !=
"M") ||
801 Builder.defineMacro(
"__ARM_FEATURE_CLZ",
"1");
805 Builder.defineMacro(
"__ARM_FP",
"0x" + Twine::utohexstr(HW_FP));
808 Builder.defineMacro(
"__ARM_ACLE",
"200");
811 Builder.defineMacro(
"__ARM_FP16_FORMAT_IEEE",
"1");
812 Builder.defineMacro(
"__ARM_FP16_ARGS",
"1");
815 if (ArchVersion >= 7 && (FPU & VFP4FPU))
816 Builder.defineMacro(
"__ARM_FEATURE_FMA",
"1");
823 if (5 <= ArchVersion && ArchVersion <= 8 && !
getTriple().isOSWindows())
824 Builder.defineMacro(
"__THUMB_INTERWORK__");
826 if (ABI ==
"aapcs" || ABI ==
"aapcs-linux" || ABI ==
"aapcs-vfp") {
830 Builder.defineMacro(
"__ARM_EABI__");
831 Builder.defineMacro(
"__ARM_PCS",
"1");
834 if ((!SoftFloat && !SoftFloatABI) || ABI ==
"aapcs-vfp" || ABI ==
"aapcs16")
835 Builder.defineMacro(
"__ARM_PCS_VFP",
"1");
837 if (SoftFloat || (SoftFloatABI && !FPU))
838 Builder.defineMacro(
"__SOFTFP__");
842 Builder.defineMacro(
"__ARM_ROPI",
"1");
844 Builder.defineMacro(
"__ARM_RWPI",
"1");
847 uint64_t FeatureCoprocBF = 0;
851 case llvm::ARM::ArchKind::ARMV4:
852 case llvm::ARM::ArchKind::ARMV4T:
854 FeatureCoprocBF = isThumb() ? 0 : FEATURE_COPROC_B1;
856 case llvm::ARM::ArchKind::ARMV5T:
857 FeatureCoprocBF = isThumb() ? 0 : FEATURE_COPROC_B1 | FEATURE_COPROC_B2;
859 case llvm::ARM::ArchKind::ARMV5TE:
860 case llvm::ARM::ArchKind::ARMV5TEJ:
863 FEATURE_COPROC_B1 | FEATURE_COPROC_B2 | FEATURE_COPROC_B3;
865 case llvm::ARM::ArchKind::ARMV6:
866 case llvm::ARM::ArchKind::ARMV6K:
867 case llvm::ARM::ArchKind::ARMV6KZ:
868 case llvm::ARM::ArchKind::ARMV6T2:
869 if (!isThumb() || ArchKind == llvm::ARM::ArchKind::ARMV6T2)
870 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
871 FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
873 case llvm::ARM::ArchKind::ARMV7A:
874 case llvm::ARM::ArchKind::ARMV7R:
875 case llvm::ARM::ArchKind::ARMV7M:
876 case llvm::ARM::ArchKind::ARMV7S:
877 case llvm::ARM::ArchKind::ARMV7EM:
878 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
879 FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
881 case llvm::ARM::ArchKind::ARMV8A:
882 case llvm::ARM::ArchKind::ARMV8R:
883 case llvm::ARM::ArchKind::ARMV8_1A:
884 case llvm::ARM::ArchKind::ARMV8_2A:
885 case llvm::ARM::ArchKind::ARMV8_3A:
886 case llvm::ARM::ArchKind::ARMV8_4A:
887 case llvm::ARM::ArchKind::ARMV8_5A:
888 case llvm::ARM::ArchKind::ARMV8_6A:
889 case llvm::ARM::ArchKind::ARMV8_7A:
890 case llvm::ARM::ArchKind::ARMV8_8A:
891 case llvm::ARM::ArchKind::ARMV8_9A:
892 case llvm::ARM::ArchKind::ARMV9A:
893 case llvm::ARM::ArchKind::ARMV9_1A:
894 case llvm::ARM::ArchKind::ARMV9_2A:
895 case llvm::ARM::ArchKind::ARMV9_3A:
896 case llvm::ARM::ArchKind::ARMV9_4A:
897 case llvm::ARM::ArchKind::ARMV9_5A:
898 case llvm::ARM::ArchKind::ARMV9_6A:
900 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B3;
902 case llvm::ARM::ArchKind::ARMV8MMainline:
903 case llvm::ARM::ArchKind::ARMV8_1MMainline:
904 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
905 FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
908 Builder.defineMacro(
"__ARM_FEATURE_COPROC",
909 "0x" + Twine::utohexstr(FeatureCoprocBF));
911 if (ArchKind == llvm::ARM::ArchKind::XSCALE)
912 Builder.defineMacro(
"__XSCALE__");
915 Builder.defineMacro(
"__THUMBEL__");
916 Builder.defineMacro(
"__thumb__");
917 if (supportsThumb2())
918 Builder.defineMacro(
"__thumb2__");
922 if ((CPUProfile !=
"M" && ArchVersion >= 6) || (CPUProfile ==
"M" && DSP))
923 Builder.defineMacro(
"__ARM_FEATURE_SIMD32",
"1");
926 if (((HWDiv & HWDivThumb) && isThumb()) ||
927 ((HWDiv & HWDivARM) && !isThumb())) {
928 Builder.defineMacro(
"__ARM_FEATURE_IDIV",
"1");
929 Builder.defineMacro(
"__ARM_ARCH_EXT_IDIV__",
"1");
933 Builder.defineMacro(
"__APCS_32__");
938 Builder.defineMacro(
"__VFP_FP__");
940 if (FPUModeIsVFP((FPUMode)FPU)) {
942 Builder.defineMacro(
"__ARM_VFPV2__");
944 Builder.defineMacro(
"__ARM_VFPV3__");
946 Builder.defineMacro(
"__ARM_VFPV4__");
948 Builder.defineMacro(
"__ARM_FPV5__");
955 if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) {
956 Builder.defineMacro(
"__ARM_NEON",
"1");
957 Builder.defineMacro(
"__ARM_NEON__");
960 Builder.defineMacro(
"__ARM_NEON_FP",
961 "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
965 Builder.defineMacro(
"__ARM_FEATURE_MVE", hasMVEFloat() ?
"3" :
"1");
969 Builder.defineMacro(
"__ARM_FEATURE_CDE",
"1");
970 Builder.defineMacro(
"__ARM_FEATURE_CDE_COPROC",
974 Builder.defineMacro(
"__ARM_SIZEOF_WCHAR_T",
975 Twine(Opts.WCharSize ? Opts.WCharSize : 4));
977 Builder.defineMacro(
"__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ?
"1" :
"4");
980 if (ArchVersion == 8 && ArchProfile == llvm::ARM::ProfileKind::M)
981 Builder.defineMacro(
"__ARM_FEATURE_CMSE", Opts.Cmse ?
"3" :
"1");
983 if (ArchVersion >= 6 && CPUAttr !=
"6M" && CPUAttr !=
"8M_BASE") {
984 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
985 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
986 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
987 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
992 Builder.defineMacro(
"__ARM_FEATURE_DSP",
"1");
997 if ((ArchVersion == 6 && CPUProfile !=
"M") || ArchVersion > 6) {
998 Builder.defineMacro(
"__ARM_FEATURE_SAT",
"1");
1004 Builder.defineMacro(
"__ARM_FEATURE_QBIT",
"1");
1006 if (Opts.UnsafeFPMath)
1007 Builder.defineMacro(
"__ARM_FP_FAST",
"1");
1011 Builder.defineMacro(
"__ARM_FEATURE_FP16_VECTOR_ARITHMETIC",
"1");
1015 Builder.defineMacro(
"__ARM_FEATURE_FP16_SCALAR_ARITHMETIC",
"1");
1019 Builder.defineMacro(
"__ARM_FEATURE_DOTPROD",
"1");
1022 Builder.defineMacro(
"__ARM_FEATURE_MATMUL_INT8",
"1");
1025 Builder.defineMacro(
"__ARM_FEATURE_PAUTH",
"1");
1028 Builder.defineMacro(
"__ARM_FEATURE_BTI",
"1");
1031 Builder.defineMacro(
"__ARM_FEATURE_BF16",
"1");
1032 Builder.defineMacro(
"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC",
"1");
1033 Builder.defineMacro(
"__ARM_BF16_FORMAT_ALTERNATIVE",
"1");
1036 if (Opts.BranchTargetEnforcement)
1037 Builder.defineMacro(
"__ARM_FEATURE_BTI_DEFAULT",
"1");
1043 Builder.defineMacro(
"__ARM_FEATURE_PAC_DEFAULT", Twine(
Value));
1049 case llvm::ARM::ArchKind::ARMV8_1A:
1052 case llvm::ARM::ArchKind::ARMV8_2A:
1055 case llvm::ARM::ArchKind::ARMV8_3A:
1056 case llvm::ARM::ArchKind::ARMV8_4A:
1057 case llvm::ARM::ArchKind::ARMV8_5A:
1058 case llvm::ARM::ArchKind::ARMV8_6A:
1059 case llvm::ARM::ArchKind::ARMV8_7A:
1060 case llvm::ARM::ArchKind::ARMV8_8A:
1061 case llvm::ARM::ArchKind::ARMV8_9A:
1062 case llvm::ARM::ArchKind::ARMV9A:
1063 case llvm::ARM::ArchKind::ARMV9_1A:
1064 case llvm::ARM::ArchKind::ARMV9_2A:
1065 case llvm::ARM::ArchKind::ARMV9_3A:
1066 case llvm::ARM::ArchKind::ARMV9_4A:
1067 case llvm::ARM::ArchKind::ARMV9_5A:
1068 case llvm::ARM::ArchKind::ARMV9_6A:
1075#define BUILTIN(ID, TYPE, ATTRS) \
1076 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1077#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
1078 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
1079#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
1080 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1081#include "clang/Basic/BuiltinsNEON.def"
1083#define BUILTIN(ID, TYPE, ATTRS) \
1084 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1085#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
1086 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG},
1087#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
1088 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
1089#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
1090 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1091#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
1092 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
1093#include "clang/Basic/BuiltinsARM.def"
1109const char *
const ARMTargetInfo::GCCRegNames[] = {
1111 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
"r8",
"r9",
"r10",
"r11",
1112 "r12",
"sp",
"lr",
"pc",
1115 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
"s8",
"s9",
"s10",
"s11",
1116 "s12",
"s13",
"s14",
"s15",
"s16",
"s17",
"s18",
"s19",
"s20",
"s21",
"s22",
1117 "s23",
"s24",
"s25",
"s26",
"s27",
"s28",
"s29",
"s30",
"s31",
1120 "d0",
"d1",
"d2",
"d3",
"d4",
"d5",
"d6",
"d7",
"d8",
"d9",
"d10",
"d11",
1121 "d12",
"d13",
"d14",
"d15",
"d16",
"d17",
"d18",
"d19",
"d20",
"d21",
"d22",
1122 "d23",
"d24",
"d25",
"d26",
"d27",
"d28",
"d29",
"d30",
"d31",
1125 "q0",
"q1",
"q2",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8",
"q9",
"q10",
"q11",
1126 "q12",
"q13",
"q14",
"q15"};
1133 {{
"a1"},
"r0"}, {{
"a2"},
"r1"}, {{
"a3"},
"r2"}, {{
"a4"},
"r3"},
1134 {{
"v1"},
"r4"}, {{
"v2"},
"r5"}, {{
"v3"},
"r6"}, {{
"v4"},
"r7"},
1135 {{
"v5"},
"r8"}, {{
"v6",
"rfp"},
"r9"}, {{
"sl"},
"r10"}, {{
"fp"},
"r11"},
1136 {{
"ip"},
"r12"}, {{
"r13"},
"sp"}, {{
"r14"},
"lr"}, {{
"r15"},
"pc"},
1170 if (CPUAttr ==
"6T2" || ArchVersion >= 7) {
1177 if (!supportsThumb2())
1189 if (isThumb() && !supportsThumb2())
1196 if (!supportsThumb2())
1211 if (!supportsThumb2())
1223 if (isThumb() && !supportsThumb2())
1234 if (isThumb() && !supportsThumb2()) {
1241 if (isThumb() && !supportsThumb2()) {
1284 switch (*Constraint) {
1287 R = std::string(
"^") + std::string(Constraint, 2);
1291 R = std::string(
"r");
1294 return std::string(1, *Constraint);
1300 StringRef Constraint,
char Modifier,
unsigned Size,
1301 std::string &SuggestedModifier)
const {
1302 bool isOutput = (Constraint[0] ==
'=');
1303 bool isInOut = (Constraint[0] ==
'+');
1306 Constraint = Constraint.ltrim(
"=+&");
1308 switch (Constraint[0]) {
1314 return (isInOut || isOutput || Size <= 64);
1359 Builder.defineMacro(
"__ARMEL__");
1369 Builder.defineMacro(
"__ARMEB__");
1370 Builder.defineMacro(
"__ARM_BIG_ENDIAN");
1382 Builder.defineMacro(
"_M_ARM_NT",
"1");
1383 Builder.defineMacro(
"_M_ARMT",
"_M_ARM");
1384 Builder.defineMacro(
"_M_THUMB",
"_M_ARM");
1386 assert((Triple.getArch() == llvm::Triple::arm ||
1387 Triple.getArch() == llvm::Triple::thumb) &&
1388 "invalid architecture for Windows ARM target info");
1389 unsigned Offset = Triple.getArch() == llvm::Triple::arm ? 4 : 6;
1390 Builder.defineMacro(
"_M_ARM", Triple.getArchName().substr(Offset));
1394 Builder.defineMacro(
"_M_ARM_FP",
"31");
1418 return CCCR_Warning;
1426 TheCXXABI.set(TargetCXXABI::GenericARM);
1433 if (Opts.MSVCCompat)
1441 TheCXXABI.set(TargetCXXABI::Microsoft);
1453 TheCXXABI.set(TargetCXXABI::GenericARM);
1459 Builder.defineMacro(
"_ARM_");
1468 resetDataLayout(
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
1474 Builder.defineMacro(
"_ARM_");
1475 Builder.defineMacro(
"__CYGWIN__");
1476 Builder.defineMacro(
"__CYGWIN32__");
1479 Builder.defineMacro(
"_GNU_SOURCE");
1485 HasAlignMac68kSupport =
true;
1486 if (Triple.isWatchABI()) {
1488 TheCXXABI.set(TargetCXXABI::WatchOS);
1491 UseSignedCharForObjCBool =
false;
1493 TheCXXABI.set(TargetCXXABI::iOS);
1497 const llvm::Triple &Triple,
Defines the Diagnostic-related interfaces.
static constexpr Builtin::Info BuiltinInfo[]
Defines enum values for all the target-independent builtin functions.
Enumerates target-specific builtins in their own namespaces within namespace clang.
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,.
@ 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 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.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
@ AAPCSABIBuiltinVaList
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
unsigned HasUnalignedAccess
unsigned char MaxAtomicPromoteWidth
uint32_t getARMCDECoprocMask() const
For ARM targets returns a mask defining which coprocessors are configured as Custom Datapath.
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
Initialize the map with the default set of target features for the CPU this should include all legal ...
unsigned char MaxAtomicInlineWidth
unsigned ARMCDECoprocMask
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.
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
void getTargetDefinesARMV83A(const LangOptions &Opts, MacroBuilder &Builder) const
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeaturesVec) const override
Initialize the map with the default set of target features for the CPU this should include all legal ...
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features (e.g., +sse4).
bool setABI(const std::string &Name) override
Use the specified ABI.
StringRef getABI() const override
Get the ABI currently in use.
bool setCPU(const std::string &Name) override
Target the specified CPU.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
void getTargetDefinesARMV81A(const LangOptions &Opts, MacroBuilder &Builder) const
bool validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size, std::string &SuggestedModifier) const override
ArrayRef< const char * > getGCCRegNames() const override
bool validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, StringRef &Err) const override
Determine if this TargetInfo supports the given branch protection specification.
bool setFPMath(StringRef Name) override
Use the specified unit for FP math.
std::string convertConstraint(const char *&Constraint) const override
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
void getTargetDefinesARMV82A(const LangOptions &Opts, MacroBuilder &Builder) const
ARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm....
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
bool hasBFloat16Type() const override
Determine whether the _BFloat16 type is supported on this target.
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
bool isBranchProtectionSupportedArch(StringRef Arch) const override
Determine if the Architecture in this TargetInfo supports branch protection.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
ARMbeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
ARMleTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
CygwinARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
DarwinARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
ItaniumWindowsARMleTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
MicrosoftARMleTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
MinGWARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
BuiltinVaListKind getBuiltinVaListKind() const override
void getVisualStudioDefines(const LangOptions &Opts, MacroBuilder &Builder) const
WindowsARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
LLVM_LIBRARY_VISIBILITY void DefineStd(clang::MacroBuilder &Builder, llvm::StringRef MacroName, const clang::LangOptions &Opts)
Define a macro name and standard variants.
void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, const llvm::Triple &Triple, StringRef &PlatformName, VersionTuple &PlatformMinVersion)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
void setRequiresImmediate(int Min, int Max)
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
unsigned short SuitableAlign
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield,...
unsigned char LongLongAlign
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
unsigned char BFloat16Width
unsigned char LongDoubleAlign
unsigned char BFloat16Align
unsigned char DoubleAlign
const llvm::fltSemantics * BFloat16Format
unsigned char DefaultAlignForAttributeAligned