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::ARMV8MBaseline:
233 case llvm::ARM::ArchKind::ARMV8MMainline:
235 case llvm::ARM::ArchKind::ARMV8R:
237 case llvm::ARM::ArchKind::ARMV8_1MMainline:
242StringRef ARMTargetInfo::getCPUProfile()
const {
243 switch (ArchProfile) {
244 case llvm::ARM::ProfileKind::A:
246 case llvm::ARM::ProfileKind::R:
248 case llvm::ARM::ProfileKind::M:
257 :
TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(
true), LDREX(0),
259 bool IsFreeBSD = Triple.isOSFreeBSD();
260 bool IsOpenBSD = Triple.isOSOpenBSD();
261 bool IsNetBSD = Triple.isOSNetBSD();
262 bool IsHaiku = Triple.isOSHaiku();
263 bool IsOHOS = Triple.isOHOSFamily();
269 (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD ||
274 SizeType = (Triple.isOSDarwin() || Triple.isOSBinFormatMachO() || IsOpenBSD ||
280 if ((Triple.isOSDarwin() || Triple.isOSBinFormatMachO()) &&
281 !Triple.isWatchABI())
294 if (Triple.isOSBinFormatMachO()) {
297 if (Triple.getEnvironment() == llvm::Triple::EABI ||
298 Triple.getOS() == llvm::Triple::UnknownOS ||
299 ArchProfile == llvm::ARM::ProfileKind::M) {
301 }
else if (Triple.isWatchABI()) {
306 }
else if (Triple.isOSWindows()) {
311 switch (Triple.getEnvironment()) {
312 case llvm::Triple::Android:
313 case llvm::Triple::GNUEABI:
314 case llvm::Triple::GNUEABIHF:
315 case llvm::Triple::MuslEABI:
316 case llvm::Triple::MuslEABIHF:
317 case llvm::Triple::OpenHOS:
320 case llvm::Triple::EABIHF:
321 case llvm::Triple::EABI:
324 case llvm::Triple::GNU:
330 else if (IsFreeBSD || IsOpenBSD || IsHaiku || IsOHOS)
346 if (IsAAPCS && !Triple.isAndroid())
355 if (Triple.getOS() == llvm::Triple::Linux ||
356 Triple.getOS() == llvm::Triple::UnknownOS)
358 ?
"llvm.arm.gnu.eabi.mcount"
373 if (Name ==
"apcs-gnu" || Name ==
"aapcs16") {
374 setABIAPCS(Name ==
"aapcs16");
377 if (Name ==
"aapcs" || Name ==
"aapcs-vfp" || Name ==
"aapcs-linux") {
385 llvm::ARM::ArchKind CPUArch = llvm::ARM::parseCPUArch(Arch);
386 if (CPUArch == llvm::ARM::ArchKind::INVALID)
387 CPUArch = llvm::ARM::parseArch(
getTriple().getArchName());
389 if (CPUArch == llvm::ARM::ArchKind::INVALID)
392 StringRef ArchFeature = llvm::ARM::getArchName(CPUArch);
394 llvm::Triple(ArchFeature,
getTriple().getVendorName(),
397 StringRef SubArch = llvm::ARM::getSubArch(CPUArch);
398 llvm::ARM::ProfileKind Profile = llvm::ARM::parseArchProfile(SubArch);
399 return a.isArmT32() && (Profile == llvm::ARM::ProfileKind::M);
404 StringRef &Err)
const {
405 llvm::ARM::ParsedBranchProtection PBP;
406 if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err))
413 llvm::StringSwitch<LangOptions::SignReturnAddressScopeKind>(PBP.Scope)
419 if (PBP.Key ==
"b_key")
431 const std::vector<std::string> &FeaturesVec)
const {
433 std::string ArchFeature;
434 std::vector<StringRef> TargetFeatures;
435 llvm::ARM::ArchKind Arch = llvm::ARM::parseArch(
getTriple().getArchName());
439 llvm::ARM::ArchKind CPUArch = llvm::ARM::parseCPUArch(CPU);
440 if (CPUArch == llvm::ARM::ArchKind::INVALID)
442 if (CPUArch != llvm::ARM::ArchKind::INVALID) {
443 ArchFeature = (
"+" + llvm::ARM::getArchName(CPUArch)).str();
444 TargetFeatures.push_back(ArchFeature);
450 for (llvm::ARM::ArchKind I = llvm::ARM::convertV9toV8(CPUArch);
451 I != llvm::ARM::ArchKind::INVALID; --I)
452 Features[llvm::ARM::getSubArch(I)] =
true;
453 if (CPUArch > llvm::ARM::ArchKind::ARMV8A &&
454 CPUArch <= llvm::ARM::ArchKind::ARMV9_3A)
455 for (llvm::ARM::ArchKind I = CPUArch; I != llvm::ARM::ArchKind::INVALID;
457 Features[llvm::ARM::getSubArch(I)] =
true;
461 llvm::ARM::FPUKind FPUKind = llvm::ARM::getDefaultFPU(CPU, Arch);
462 llvm::ARM::getFPUFeatures(FPUKind, TargetFeatures);
465 uint64_t Extensions = llvm::ARM::getDefaultExtensions(CPU, Arch);
466 llvm::ARM::getExtensionFeatures(Extensions, TargetFeatures);
468 for (
auto Feature : TargetFeatures)
469 if (Feature[0] ==
'+')
470 Features[Feature.drop_front(1)] =
true;
475 Features[
"thumb-mode"] =
true;
477 Features[
"thumb-mode"] =
false;
481 std::vector<std::string> UpdatedFeaturesVec;
482 for (
const auto &Feature : FeaturesVec) {
485 if (Feature ==
"+soft-float-abi")
488 StringRef FixedFeature;
489 if (Feature ==
"+arm")
490 FixedFeature =
"-thumb-mode";
491 else if (Feature ==
"+thumb")
492 FixedFeature =
"+thumb-mode";
494 FixedFeature = Feature;
495 UpdatedFeaturesVec.push_back(FixedFeature.str());
523 FPRegsDisabled =
false;
527 for (
const auto &Feature : Features) {
528 if (Feature ==
"+soft-float") {
530 }
else if (Feature ==
"+vfp2sp" || Feature ==
"+vfp2") {
533 if (Feature ==
"+vfp2")
535 }
else if (Feature ==
"+vfp3sp" || Feature ==
"+vfp3d16sp" ||
536 Feature ==
"+vfp3" || Feature ==
"+vfp3d16") {
539 if (Feature ==
"+vfp3" || Feature ==
"+vfp3d16")
541 }
else if (Feature ==
"+vfp4sp" || Feature ==
"+vfp4d16sp" ||
542 Feature ==
"+vfp4" || Feature ==
"+vfp4d16") {
544 HW_FP |= HW_FP_SP | HW_FP_HP;
545 if (Feature ==
"+vfp4" || Feature ==
"+vfp4d16")
547 }
else if (Feature ==
"+fp-armv8sp" || Feature ==
"+fp-armv8d16sp" ||
548 Feature ==
"+fp-armv8" || Feature ==
"+fp-armv8d16") {
550 HW_FP |= HW_FP_SP | HW_FP_HP;
551 if (Feature ==
"+fp-armv8" || Feature ==
"+fp-armv8d16")
553 }
else if (Feature ==
"+neon") {
556 }
else if (Feature ==
"+hwdiv") {
558 }
else if (Feature ==
"+hwdiv-arm") {
560 }
else if (Feature ==
"+crc") {
562 }
else if (Feature ==
"+crypto") {
564 }
else if (Feature ==
"+sha2") {
566 }
else if (Feature ==
"+aes") {
568 }
else if (Feature ==
"+dsp") {
570 }
else if (Feature ==
"+fp64") {
572 }
else if (Feature ==
"+8msecext") {
573 if (CPUProfile !=
"M" || ArchVersion != 8) {
574 Diags.
Report(diag::err_target_unsupported_mcmse) << CPU;
577 }
else if (Feature ==
"+strict-align") {
579 }
else if (Feature ==
"+fp16") {
581 }
else if (Feature ==
"+fullfp16") {
583 }
else if (Feature ==
"+dotprod") {
585 }
else if (Feature ==
"+mve") {
587 }
else if (Feature ==
"+mve.fp") {
590 MVE |= MVE_INT | MVE_FP;
591 HW_FP |= HW_FP_SP | HW_FP_HP;
592 }
else if (Feature ==
"+i8mm") {
594 }
else if (Feature.size() == strlen(
"+cdecp0") && Feature >=
"+cdecp0" &&
595 Feature <=
"+cdecp7") {
596 unsigned Coproc = Feature.back() -
'0';
598 }
else if (Feature ==
"+bf16") {
600 }
else if (Feature ==
"-fpregs") {
601 FPRegsDisabled =
true;
602 }
else if (Feature ==
"+pacbti") {
605 }
else if (Feature ==
"+fullbf16") {
612 switch (ArchVersion) {
614 if (ArchProfile == llvm::ARM::ProfileKind::M)
616 else if (ArchKind == llvm::ARM::ArchKind::ARMV6K)
617 LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
622 if (ArchProfile == llvm::ARM::ProfileKind::M)
623 LDREX = LDREX_W | LDREX_H | LDREX_B;
625 LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
629 LDREX = LDREX_D | LDREX_W | LDREX_H | LDREX_B;
632 if (!(FPU & NeonFPU) && FPMath == FP_Neon) {
633 Diags.
Report(diag::err_target_unsupported_fpmath) <<
"neon";
637 if (FPMath == FP_Neon)
638 Features.push_back(
"+neonfp");
639 else if (FPMath == FP_VFP)
640 Features.push_back(
"-neonfp");
646 return llvm::StringSwitch<bool>(Feature)
648 .Case(
"aarch32",
true)
649 .Case(
"softfloat", SoftFloat)
650 .Case(
"thumb", isThumb())
651 .Case(
"neon", (FPU & NeonFPU) && !SoftFloat)
652 .Case(
"vfp", FPU && !SoftFloat)
653 .Case(
"hwdiv", HWDiv & HWDivThumb)
654 .Case(
"hwdiv-arm", HWDiv & HWDivARM)
655 .Case(
"mve", hasMVE())
665 return Name ==
"generic" ||
666 llvm::ARM::parseCPUArch(Name) != llvm::ARM::ArchKind::INVALID;
670 llvm::ARM::fillValidCPUArchList(Values);
674 if (Name !=
"generic")
675 setArchInfo(llvm::ARM::parseCPUArch(Name));
677 if (ArchKind == llvm::ARM::ArchKind::INVALID)
685 if (Name ==
"neon") {
688 }
else if (Name ==
"vfp" || Name ==
"vfp2" || Name ==
"vfp3" ||
698 Builder.defineMacro(
"__ARM_FEATURE_QRDMX",
"1");
710 Builder.defineMacro(
"__ARM_FEATURE_COMPLEX",
"1");
717 Builder.defineMacro(
"__arm");
718 Builder.defineMacro(
"__arm__");
720 if (
getTriple().getOS() == llvm::Triple::UnknownOS &&
721 (
getTriple().getEnvironment() == llvm::Triple::EABI ||
722 getTriple().getEnvironment() == llvm::Triple::EABIHF) &&
724 Builder.defineMacro(
"_GNU_SOURCE");
728 Builder.defineMacro(
"__REGISTER_PREFIX__",
"");
733 Builder.defineMacro(
"__ARM_ARCH_7K__",
"2");
735 if (!CPUAttr.empty())
736 Builder.defineMacro(
"__ARM_ARCH_" + CPUAttr +
"__");
740 Builder.defineMacro(
"__ARM_ARCH", Twine(ArchVersion));
742 if (ArchVersion >= 8) {
747 Builder.defineMacro(
"__ARM_FEATURE_CRYPTO",
"1");
749 Builder.defineMacro(
"__ARM_FEATURE_SHA2",
"1");
751 Builder.defineMacro(
"__ARM_FEATURE_AES",
"1");
754 Builder.defineMacro(
"__ARM_FEATURE_CRC32",
"1");
756 Builder.defineMacro(
"__ARM_FEATURE_NUMERIC_MAXMIN",
"1");
758 Builder.defineMacro(
"__ARM_FEATURE_DIRECTED_ROUNDING",
"1");
764 if (CPUProfile.empty() || ArchProfile != llvm::ARM::ProfileKind::M)
765 Builder.defineMacro(
"__ARM_ARCH_ISA_ARM",
"1");
771 if (supportsThumb2())
772 Builder.defineMacro(
"__ARM_ARCH_ISA_THUMB",
"2");
773 else if (supportsThumb())
774 Builder.defineMacro(
"__ARM_ARCH_ISA_THUMB",
"1");
778 Builder.defineMacro(
"__ARM_32BIT_STATE",
"1");
783 if (!CPUProfile.empty())
784 Builder.defineMacro(
"__ARM_ARCH_PROFILE",
"'" + CPUProfile +
"'");
788 Builder.defineMacro(
"__ARM_FEATURE_UNALIGNED",
"1");
792 Builder.defineMacro(
"__ARM_FEATURE_LDREX",
"0x" + Twine::utohexstr(LDREX));
795 if (ArchVersion == 5 || (ArchVersion == 6 && CPUProfile !=
"M") ||
797 Builder.defineMacro(
"__ARM_FEATURE_CLZ",
"1");
801 Builder.defineMacro(
"__ARM_FP",
"0x" + Twine::utohexstr(HW_FP));
804 Builder.defineMacro(
"__ARM_ACLE",
"200");
807 Builder.defineMacro(
"__ARM_FP16_FORMAT_IEEE",
"1");
808 Builder.defineMacro(
"__ARM_FP16_ARGS",
"1");
811 if (ArchVersion >= 7 && (FPU & VFP4FPU))
812 Builder.defineMacro(
"__ARM_FEATURE_FMA",
"1");
819 if (5 <= ArchVersion && ArchVersion <= 8 && !
getTriple().isOSWindows())
820 Builder.defineMacro(
"__THUMB_INTERWORK__");
822 if (ABI ==
"aapcs" || ABI ==
"aapcs-linux" || ABI ==
"aapcs-vfp") {
826 Builder.defineMacro(
"__ARM_EABI__");
827 Builder.defineMacro(
"__ARM_PCS",
"1");
830 if ((!SoftFloat && !SoftFloatABI) || ABI ==
"aapcs-vfp" || ABI ==
"aapcs16")
831 Builder.defineMacro(
"__ARM_PCS_VFP",
"1");
833 if (SoftFloat || (SoftFloatABI && !FPU))
834 Builder.defineMacro(
"__SOFTFP__");
838 Builder.defineMacro(
"__ARM_ROPI",
"1");
840 Builder.defineMacro(
"__ARM_RWPI",
"1");
843 uint64_t FeatureCoprocBF = 0;
847 case llvm::ARM::ArchKind::ARMV4:
848 case llvm::ARM::ArchKind::ARMV4T:
850 FeatureCoprocBF = isThumb() ? 0 : FEATURE_COPROC_B1;
852 case llvm::ARM::ArchKind::ARMV5T:
853 FeatureCoprocBF = isThumb() ? 0 : FEATURE_COPROC_B1 | FEATURE_COPROC_B2;
855 case llvm::ARM::ArchKind::ARMV5TE:
856 case llvm::ARM::ArchKind::ARMV5TEJ:
859 FEATURE_COPROC_B1 | FEATURE_COPROC_B2 | FEATURE_COPROC_B3;
861 case llvm::ARM::ArchKind::ARMV6:
862 case llvm::ARM::ArchKind::ARMV6K:
863 case llvm::ARM::ArchKind::ARMV6KZ:
864 case llvm::ARM::ArchKind::ARMV6T2:
865 if (!isThumb() || ArchKind == llvm::ARM::ArchKind::ARMV6T2)
866 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
867 FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
869 case llvm::ARM::ArchKind::ARMV7A:
870 case llvm::ARM::ArchKind::ARMV7R:
871 case llvm::ARM::ArchKind::ARMV7M:
872 case llvm::ARM::ArchKind::ARMV7S:
873 case llvm::ARM::ArchKind::ARMV7EM:
874 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
875 FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
877 case llvm::ARM::ArchKind::ARMV8A:
878 case llvm::ARM::ArchKind::ARMV8R:
879 case llvm::ARM::ArchKind::ARMV8_1A:
880 case llvm::ARM::ArchKind::ARMV8_2A:
881 case llvm::ARM::ArchKind::ARMV8_3A:
882 case llvm::ARM::ArchKind::ARMV8_4A:
883 case llvm::ARM::ArchKind::ARMV8_5A:
884 case llvm::ARM::ArchKind::ARMV8_6A:
885 case llvm::ARM::ArchKind::ARMV8_7A:
886 case llvm::ARM::ArchKind::ARMV8_8A:
887 case llvm::ARM::ArchKind::ARMV8_9A:
888 case llvm::ARM::ArchKind::ARMV9A:
889 case llvm::ARM::ArchKind::ARMV9_1A:
890 case llvm::ARM::ArchKind::ARMV9_2A:
891 case llvm::ARM::ArchKind::ARMV9_3A:
892 case llvm::ARM::ArchKind::ARMV9_4A:
893 case llvm::ARM::ArchKind::ARMV9_5A:
895 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B3;
897 case llvm::ARM::ArchKind::ARMV8MMainline:
898 case llvm::ARM::ArchKind::ARMV8_1MMainline:
899 FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
900 FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
903 Builder.defineMacro(
"__ARM_FEATURE_COPROC",
904 "0x" + Twine::utohexstr(FeatureCoprocBF));
906 if (ArchKind == llvm::ARM::ArchKind::XSCALE)
907 Builder.defineMacro(
"__XSCALE__");
910 Builder.defineMacro(
"__THUMBEL__");
911 Builder.defineMacro(
"__thumb__");
912 if (supportsThumb2())
913 Builder.defineMacro(
"__thumb2__");
917 if ((CPUProfile !=
"M" && ArchVersion >= 6) || (CPUProfile ==
"M" && DSP))
918 Builder.defineMacro(
"__ARM_FEATURE_SIMD32",
"1");
921 if (((HWDiv & HWDivThumb) && isThumb()) ||
922 ((HWDiv & HWDivARM) && !isThumb())) {
923 Builder.defineMacro(
"__ARM_FEATURE_IDIV",
"1");
924 Builder.defineMacro(
"__ARM_ARCH_EXT_IDIV__",
"1");
928 Builder.defineMacro(
"__APCS_32__");
933 Builder.defineMacro(
"__VFP_FP__");
935 if (FPUModeIsVFP((FPUMode)FPU)) {
937 Builder.defineMacro(
"__ARM_VFPV2__");
939 Builder.defineMacro(
"__ARM_VFPV3__");
941 Builder.defineMacro(
"__ARM_VFPV4__");
943 Builder.defineMacro(
"__ARM_FPV5__");
950 if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) {
951 Builder.defineMacro(
"__ARM_NEON",
"1");
952 Builder.defineMacro(
"__ARM_NEON__");
955 Builder.defineMacro(
"__ARM_NEON_FP",
956 "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
960 Builder.defineMacro(
"__ARM_FEATURE_MVE", hasMVEFloat() ?
"3" :
"1");
964 Builder.defineMacro(
"__ARM_FEATURE_CDE",
"1");
965 Builder.defineMacro(
"__ARM_FEATURE_CDE_COPROC",
969 Builder.defineMacro(
"__ARM_SIZEOF_WCHAR_T",
970 Twine(Opts.WCharSize ? Opts.WCharSize : 4));
972 Builder.defineMacro(
"__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ?
"1" :
"4");
975 if (ArchVersion == 8 && ArchProfile == llvm::ARM::ProfileKind::M)
976 Builder.defineMacro(
"__ARM_FEATURE_CMSE", Opts.Cmse ?
"3" :
"1");
978 if (ArchVersion >= 6 && CPUAttr !=
"6M" && CPUAttr !=
"8M_BASE") {
979 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
980 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
981 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
982 Builder.defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
987 Builder.defineMacro(
"__ARM_FEATURE_DSP",
"1");
992 if ((ArchVersion == 6 && CPUProfile !=
"M") || ArchVersion > 6) {
993 Builder.defineMacro(
"__ARM_FEATURE_SAT",
"1");
999 Builder.defineMacro(
"__ARM_FEATURE_QBIT",
"1");
1001 if (Opts.UnsafeFPMath)
1002 Builder.defineMacro(
"__ARM_FP_FAST",
"1");
1006 Builder.defineMacro(
"__ARM_FEATURE_FP16_VECTOR_ARITHMETIC",
"1");
1010 Builder.defineMacro(
"__ARM_FEATURE_FP16_SCALAR_ARITHMETIC",
"1");
1014 Builder.defineMacro(
"__ARM_FEATURE_DOTPROD",
"1");
1017 Builder.defineMacro(
"__ARM_FEATURE_MATMUL_INT8",
"1");
1020 Builder.defineMacro(
"__ARM_FEATURE_PAUTH",
"1");
1023 Builder.defineMacro(
"__ARM_FEATURE_BTI",
"1");
1026 Builder.defineMacro(
"__ARM_FEATURE_BF16",
"1");
1027 Builder.defineMacro(
"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC",
"1");
1028 Builder.defineMacro(
"__ARM_BF16_FORMAT_ALTERNATIVE",
"1");
1031 if (Opts.BranchTargetEnforcement)
1032 Builder.defineMacro(
"__ARM_FEATURE_BTI_DEFAULT",
"1");
1038 Builder.defineMacro(
"__ARM_FEATURE_PAC_DEFAULT", Twine(
Value));
1044 case llvm::ARM::ArchKind::ARMV8_1A:
1047 case llvm::ARM::ArchKind::ARMV8_2A:
1050 case llvm::ARM::ArchKind::ARMV8_3A:
1051 case llvm::ARM::ArchKind::ARMV8_4A:
1052 case llvm::ARM::ArchKind::ARMV8_5A:
1053 case llvm::ARM::ArchKind::ARMV8_6A:
1054 case llvm::ARM::ArchKind::ARMV8_7A:
1055 case llvm::ARM::ArchKind::ARMV8_8A:
1056 case llvm::ARM::ArchKind::ARMV8_9A:
1057 case llvm::ARM::ArchKind::ARMV9A:
1058 case llvm::ARM::ArchKind::ARMV9_1A:
1059 case llvm::ARM::ArchKind::ARMV9_2A:
1060 case llvm::ARM::ArchKind::ARMV9_3A:
1061 case llvm::ARM::ArchKind::ARMV9_4A:
1062 case llvm::ARM::ArchKind::ARMV9_5A:
1069#define BUILTIN(ID, TYPE, ATTRS) \
1070 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1071#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
1072 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
1073#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
1074 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1075#include "clang/Basic/BuiltinsNEON.def"
1077#define BUILTIN(ID, TYPE, ATTRS) \
1078 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1079#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
1080 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG},
1081#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \
1082 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES},
1083#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
1084 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
1085#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
1086 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
1087#include "clang/Basic/BuiltinsARM.def"
1103const char *
const ARMTargetInfo::GCCRegNames[] = {
1105 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
"r8",
"r9",
"r10",
"r11",
1106 "r12",
"sp",
"lr",
"pc",
1109 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
"s8",
"s9",
"s10",
"s11",
1110 "s12",
"s13",
"s14",
"s15",
"s16",
"s17",
"s18",
"s19",
"s20",
"s21",
"s22",
1111 "s23",
"s24",
"s25",
"s26",
"s27",
"s28",
"s29",
"s30",
"s31",
1114 "d0",
"d1",
"d2",
"d3",
"d4",
"d5",
"d6",
"d7",
"d8",
"d9",
"d10",
"d11",
1115 "d12",
"d13",
"d14",
"d15",
"d16",
"d17",
"d18",
"d19",
"d20",
"d21",
"d22",
1116 "d23",
"d24",
"d25",
"d26",
"d27",
"d28",
"d29",
"d30",
"d31",
1119 "q0",
"q1",
"q2",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8",
"q9",
"q10",
"q11",
1120 "q12",
"q13",
"q14",
"q15"};
1127 {{
"a1"},
"r0"}, {{
"a2"},
"r1"}, {{
"a3"},
"r2"}, {{
"a4"},
"r3"},
1128 {{
"v1"},
"r4"}, {{
"v2"},
"r5"}, {{
"v3"},
"r6"}, {{
"v4"},
"r7"},
1129 {{
"v5"},
"r8"}, {{
"v6",
"rfp"},
"r9"}, {{
"sl"},
"r10"}, {{
"fp"},
"r11"},
1130 {{
"ip"},
"r12"}, {{
"r13"},
"sp"}, {{
"r14"},
"lr"}, {{
"r15"},
"pc"},
1164 if (CPUAttr ==
"6T2" || ArchVersion >= 7) {
1171 if (!supportsThumb2())
1183 if (isThumb() && !supportsThumb2())
1190 if (!supportsThumb2())
1205 if (!supportsThumb2())
1217 if (isThumb() && !supportsThumb2())
1228 if (isThumb() && !supportsThumb2()) {
1235 if (isThumb() && !supportsThumb2()) {
1278 switch (*Constraint) {
1281 R = std::string(
"^") + std::string(Constraint, 2);
1285 R = std::string(
"r");
1288 return std::string(1, *Constraint);
1294 StringRef Constraint,
char Modifier,
unsigned Size,
1295 std::string &SuggestedModifier)
const {
1296 bool isOutput = (Constraint[0] ==
'=');
1297 bool isInOut = (Constraint[0] ==
'+');
1300 Constraint = Constraint.ltrim(
"=+&");
1302 switch (Constraint[0]) {
1308 return (isInOut || isOutput || Size <= 64);
1353 Builder.defineMacro(
"__ARMEL__");
1363 Builder.defineMacro(
"__ARMEB__");
1364 Builder.defineMacro(
"__ARM_BIG_ENDIAN");
1376 Builder.defineMacro(
"_M_ARM_NT",
"1");
1377 Builder.defineMacro(
"_M_ARMT",
"_M_ARM");
1378 Builder.defineMacro(
"_M_THUMB",
"_M_ARM");
1380 assert((Triple.getArch() == llvm::Triple::arm ||
1381 Triple.getArch() == llvm::Triple::thumb) &&
1382 "invalid architecture for Windows ARM target info");
1383 unsigned Offset = Triple.getArch() == llvm::Triple::arm ? 4 : 6;
1384 Builder.defineMacro(
"_M_ARM", Triple.getArchName().substr(Offset));
1388 Builder.defineMacro(
"_M_ARM_FP",
"31");
1412 return CCCR_Warning;
1420 TheCXXABI.set(TargetCXXABI::GenericARM);
1427 if (Opts.MSVCCompat)
1435 TheCXXABI.set(TargetCXXABI::Microsoft);
1447 TheCXXABI.set(TargetCXXABI::GenericARM);
1453 Builder.defineMacro(
"_ARM_");
1462 resetDataLayout(
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
1468 Builder.defineMacro(
"_ARM_");
1469 Builder.defineMacro(
"__CYGWIN__");
1470 Builder.defineMacro(
"__CYGWIN32__");
1473 Builder.defineMacro(
"_GNU_SOURCE");
1479 HasAlignMac68kSupport =
true;
1480 if (Triple.isWatchABI()) {
1482 TheCXXABI.set(TargetCXXABI::WatchOS);
1485 UseSignedCharForObjCBool =
false;
1487 TheCXXABI.set(TargetCXXABI::iOS);
1491 const llvm::Triple &Triple,
1500 Triple.getEnvironmentName()),
1508 Builder.defineMacro(
"__RENDERSCRIPT__");
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 IsRenderScriptTarget
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
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
RenderScript32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
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)
void DefineStd(MacroBuilder &Builder, StringRef MacroName, const LangOptions &Opts)
DefineStd - 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.
Diagnostic wrappers for TextAPI types for error reporting.
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