llvm.org GIT mirror llvm / 6634844
[ARM][AArch64] Armv8.4-A Enablement Initial patch adding assembly support for Armv8.4-A. Besides adding v8.4 as a supported architecture to the usual places, this also adds target features for the different crypto algorithms. Armv8.4-A introduced new crypto algorithms, made them optional, and allows different combinations: - none of the v8.4 crypto functions are supported, which is independent of the implementation of the Armv8.0 SHA1 and SHA2 instructions. - the v8.4 SHA512 and SHA3 support is implemented, in this case the Armv8.0 SHA1 and SHA2 instructions must also be implemented. - the v8.4 SM3 and SM4 support is implemented, which is independent of the implementation of the Armv8.0 SHA1 and SHA2 instructions. - all of the v8.4 crypto functions are supported, in this case the Armv8.0 SHA1 and SHA2 instructions must also be implemented. The v8.4 crypto instructions are added to AArch64 only, and not AArch32, and are made optional extensions to Armv8.2-A. The user-facing Clang options will map on these new target features, their naming will be compatible with GCC and added in follow-up patches. The Armv8.4-A instruction sets can be downloaded here: https://developer.arm.com/products/architecture/a-profile/exploration-tools Differential Revision: https://reviews.llvm.org/D48625 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335953 91177308-0d34-0410-b5e6-96231b3b80d8 Sjoerd Meijer 1 year, 4 months ago
12 changed file(s) with 116 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
100100 enum SubArchType {
101101 NoSubArch,
102102
103 ARMSubArch_v8_4a,
103104 ARMSubArch_v8_3a,
104105 ARMSubArch_v8_2a,
105106 ARMSubArch_v8_1a,
3434 (AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
3535 AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
3636 AArch64::AEK_RDM | AArch64::AEK_RCPC))
37 AARCH64_ARCH("armv8.4-a", ARMV8_4A, "8.4-A", "v8.4a",
38 ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
39 (AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
40 AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
41 AArch64::AEK_RDM | AArch64::AEK_RCPC))
3742 #undef AARCH64_ARCH
3843
3944 #ifndef AARCH64_ARCH_EXT_NAME
4651 AARCH64_ARCH_EXT_NAME("lse", AArch64::AEK_LSE, "+lse", "-lse")
4752 AARCH64_ARCH_EXT_NAME("rdm", AArch64::AEK_RDM, "+rdm", "-rdm")
4853 AARCH64_ARCH_EXT_NAME("crypto", AArch64::AEK_CRYPTO, "+crypto","-crypto")
54 AARCH64_ARCH_EXT_NAME("sm4", AArch64::AEK_SM4, "+sm4", "-sm4")
55 AARCH64_ARCH_EXT_NAME("sha3", AArch64::AEK_SHA3, "+sha3", "-sha3")
56 AARCH64_ARCH_EXT_NAME("sha2", AArch64::AEK_SHA2, "+sha2", "-sha2")
57 AARCH64_ARCH_EXT_NAME("aes", AArch64::AEK_AES, "+aes", "-aes")
4958 AARCH64_ARCH_EXT_NAME("dotprod", AArch64::AEK_DOTPROD, "+dotprod","-dotprod")
5059 AARCH64_ARCH_EXT_NAME("fp", AArch64::AEK_FP, "+fp-armv8", "-fp-armv8")
5160 AARCH64_ARCH_EXT_NAME("simd", AArch64::AEK_SIMD, "+neon", "-neon")
100100 ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
101101 (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
102102 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS))
103 ARM_ARCH("armv8.4-a", ARMV8_4A, "8.4-A", "v8.4a",
104 ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
105 (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
106 ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS))
103107 ARM_ARCH("armv8-r", ARMV8R, "8-R", "v8r", ARMBuildAttrs::CPUArch::v8_R,
104108 FK_NEON_FP_ARMV8,
105109 (ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
129133 ARM_ARCH_EXT_NAME("none", ARM::AEK_NONE, nullptr, nullptr)
130134 ARM_ARCH_EXT_NAME("crc", ARM::AEK_CRC, "+crc", "-crc")
131135 ARM_ARCH_EXT_NAME("crypto", ARM::AEK_CRYPTO, "+crypto","-crypto")
136 ARM_ARCH_EXT_NAME("sha2", ARM::AEK_SHA2, "+sha2", "-sha2")
137 ARM_ARCH_EXT_NAME("aes", ARM::AEK_AES, "+aes", "-aes")
132138 ARM_ARCH_EXT_NAME("dotprod", ARM::AEK_DOTPROD, "+dotprod","-dotprod")
133139 ARM_ARCH_EXT_NAME("dsp", ARM::AEK_DSP, "+dsp", "-dsp")
134140 ARM_ARCH_EXT_NAME("fp", ARM::AEK_FP, nullptr, nullptr)
8585 AEK_RAS = 1 << 12,
8686 AEK_SVE = 1 << 13,
8787 AEK_DOTPROD = 1 << 14,
88 AEK_SHA2 = 1 << 15,
89 AEK_AES = 1 << 16,
8890 // Unsupported extensions.
8991 AEK_OS = 0x8000000,
9092 AEK_IWMMXT = 0x10000000,
170172 AEK_SVE = 1 << 9,
171173 AEK_DOTPROD = 1 << 10,
172174 AEK_RCPC = 1 << 11,
173 AEK_RDM = 1 << 12
175 AEK_RDM = 1 << 12,
176 AEK_SM4 = 1 << 13,
177 AEK_SHA3 = 1 << 14,
178 AEK_SHA2 = 1 << 15,
179 AEK_AES = 1 << 16,
174180 };
175181
176182 StringRef getCanonicalArchName(StringRef Arch);
479479 Features.push_back("+v8.2a");
480480 if (AK == AArch64::ArchKind::ARMV8_3A)
481481 Features.push_back("+v8.3a");
482 if (AK == AArch64::ArchKind::ARMV8_4A)
483 Features.push_back("+v8.4a");
482484
483485 return AK != AArch64::ArchKind::INVALID;
484486 }
584586 .Case("v8.1a", "v8.1-a")
585587 .Case("v8.2a", "v8.2-a")
586588 .Case("v8.3a", "v8.3-a")
589 .Case("v8.4a", "v8.4-a")
587590 .Case("v8r", "v8-r")
588591 .Case("v8m.base", "v8-m.base")
589592 .Case("v8m.main", "v8-m.main")
751754 case ARM::ArchKind::ARMV8_1A:
752755 case ARM::ArchKind::ARMV8_2A:
753756 case ARM::ArchKind::ARMV8_3A:
757 case ARM::ArchKind::ARMV8_4A:
754758 return ARM::ProfileKind::A;
755759 case ARM::ArchKind::ARMV2:
756760 case ARM::ArchKind::ARMV2A:
813817 case ARM::ArchKind::ARMV8_1A:
814818 case ARM::ArchKind::ARMV8_2A:
815819 case ARM::ArchKind::ARMV8_3A:
820 case ARM::ArchKind::ARMV8_4A:
816821 case ARM::ArchKind::ARMV8R:
817822 case ARM::ArchKind::ARMV8MBaseline:
818823 case ARM::ArchKind::ARMV8MMainline:
589589 return Triple::ARMSubArch_v8_2a;
590590 case ARM::ArchKind::ARMV8_3A:
591591 return Triple::ARMSubArch_v8_3a;
592 case ARM::ArchKind::ARMV8_4A:
593 return Triple::ARMSubArch_v8_4a;
592594 case ARM::ArchKind::ARMV8R:
593595 return Triple::ARMSubArch_v8r;
594596 case ARM::ArchKind::ARMV8MBaseline:
2525 def FeatureNEON : SubtargetFeature<"neon", "HasNEON", "true",
2626 "Enable Advanced SIMD instructions", [FeatureFPARMv8]>;
2727
28 def FeatureSM4 : SubtargetFeature<
29 "sm4", "HasSM4", "true",
30 "Enable SM3 and SM4 support", [FeatureNEON]>;
31
32 def FeatureSHA2 : SubtargetFeature<
33 "sha2", "HasSHA2", "true",
34 "Enable SHA1 and SHA256 support", [FeatureNEON]>;
35
36 def FeatureSHA3 : SubtargetFeature<
37 "sha3", "HasSHA3", "true",
38 "Enable SHA512 and SHA3 support", [FeatureNEON, FeatureSHA2]>;
39
40 def FeatureAES : SubtargetFeature<
41 "aes", "HasAES", "true",
42 "Enable AES support", [FeatureNEON]>;
43
44 // Crypto has been split up and any combination is now valid (see the
45 // crypto defintions above). Also, crypto is now context sensitive:
46 // it has a different meaning for e.g. Armv8.4 than it has for Armv8.2.
47 // Therefore, we rely on Clang, the user interacing tool, to pass on the
48 // appropriate crypto options. But here in the backend, crypto has very little
49 // meaning anymore. We kept the Crypto defintion here for backward
50 // compatibility, and now imply features SHA2 and AES, which was the
51 // "traditional" meaning of Crypto.
2852 def FeatureCrypto : SubtargetFeature<"crypto", "HasCrypto", "true",
29 "Enable cryptographic instructions", [FeatureNEON]>;
53 "Enable cryptographic instructions", [FeatureNEON, FeatureSHA2, FeatureAES]>;
3054
3155 def FeatureCRC : SubtargetFeature<"crc", "HasCRC", "true",
3256 "Enable ARMv8 CRC-32 checksum instructions">;
183207
184208 def HasV8_3aOps : SubtargetFeature<"v8.3a", "HasV8_3aOps", "true",
185209 "Support ARM v8.3a instructions", [HasV8_2aOps, FeatureRCPC]>;
210
211 def HasV8_4aOps : SubtargetFeature<"v8.4a", "HasV8_4aOps", "true",
212 "Support ARM v8.4a instructions", [HasV8_3aOps, FeatureDotProd]>;
186213
187214 //===----------------------------------------------------------------------===//
188215 // Register File Description
6565 bool HasV8_1aOps = false;
6666 bool HasV8_2aOps = false;
6767 bool HasV8_3aOps = false;
68 bool HasV8_4aOps = false;
6869
6970 bool HasFPARMv8 = false;
7071 bool HasNEON = false;
7778 bool HasPerfMon = false;
7879 bool HasFullFP16 = false;
7980 bool HasSPE = false;
81
82 // ARMv8.4 Crypto extensions
83 bool HasSM4 = true;
84 bool HasSHA3 = true;
85
86 bool HasSHA2 = true;
87 bool HasAES = true;
88
8089 bool HasLSLFast = false;
8190 bool HasSVE = false;
8291 bool HasRCPC = false;
200209 bool hasV8_1aOps() const { return HasV8_1aOps; }
201210 bool hasV8_2aOps() const { return HasV8_2aOps; }
202211 bool hasV8_3aOps() const { return HasV8_3aOps; }
212 bool hasV8_4aOps() const { return HasV8_4aOps; }
203213
204214 bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
205215
227237 bool hasLSE() const { return HasLSE; }
228238 bool hasRAS() const { return HasRAS; }
229239 bool hasRDM() const { return HasRDM; }
240 bool hasSM4() const { return HasSM4; }
241 bool hasSHA3() const { return HasSHA3; }
242 bool hasSHA2() const { return HasSHA2; }
243 bool hasAES() const { return HasAES; }
230244 bool balanceFPOps() const { return BalanceFPOps; }
231245 bool predictableSelectIsExpensive() const {
232246 return PredictableSelectIsExpensive;
108108 "Enable support for ARMv8-M "
109109 "Security Extensions">;
110110
111 def FeatureSHA2 : SubtargetFeature<"sha2", "HasSHA2", "true",
112 "Enable SHA1 and SHA256 support", [FeatureNEON]>;
113
114 def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
115 "Enable AES support", [FeatureNEON]>;
116
111117 def FeatureCrypto : SubtargetFeature<"crypto", "HasCrypto", "true",
112118 "Enable support for "
113119 "Cryptography extensions",
114 [FeatureNEON]>;
120 [FeatureNEON, FeatureSHA2, FeatureAES]>;
115121
116122 def FeatureCRC : SubtargetFeature<"crc", "HasCRC", "true",
117123 "Enable support for CRC instructions">;
417423 def HasV8_3aOps : SubtargetFeature<"v8.3a", "HasV8_3aOps", "true",
418424 "Support ARM v8.3a instructions",
419425 [HasV8_2aOps]>;
426
427 def HasV8_4aOps : SubtargetFeature<"v8.4a", "HasV8_4aOps", "true",
428 "Support ARM v8.4a instructions",
429 [HasV8_3aOps, FeatureDotProd]>;
420430
421431 //===----------------------------------------------------------------------===//
422432 // ARM Processor subtarget features.
623633 FeatureCRC,
624634 FeatureRAS]>;
625635
636 def ARMv84a : Architecture<"armv8.4-a", "ARMv84a", [HasV8_4aOps,
637 FeatureAClass,
638 FeatureDB,
639 FeatureFPARMv8,
640 FeatureNEON,
641 FeatureDSP,
642 FeatureTrustZone,
643 FeatureMP,
644 FeatureVirtualization,
645 FeatureCrypto,
646 FeatureCRC,
647 FeatureRAS,
648 FeatureDotProd]>;
649
626650 def ARMv8r : Architecture<"armv8-r", "ARMv8r", [HasV8Ops,
627651 FeatureRClass,
628652 FeatureDB,
252252 AssemblerPredicate<"HasV8_2aOps", "armv8.2a">;
253253 def HasV8_3a : Predicate<"Subtarget->hasV8_3aOps()">,
254254 AssemblerPredicate<"HasV8_3aOps", "armv8.3a">;
255 def HasV8_4a : Predicate<"Subtarget->hasV8_4aOps()">,
256 AssemblerPredicate<"HasV8_4aOps", "armv8.4a">;
255257 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
256258 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
257259 AssemblerPredicate<"FeatureVFP2", "VFP2">;
266268 AssemblerPredicate<"FeatureFPARMv8", "FPARMv8">;
267269 def HasNEON : Predicate<"Subtarget->hasNEON()">,
268270 AssemblerPredicate<"FeatureNEON", "NEON">;
271 def HasSHA2 : Predicate<"Subtarget->hasSHA2()">,
272 AssemblerPredicate<"FeatureSHA2", "sha2">;
273 def HasAES : Predicate<"Subtarget->hasAES()">,
274 AssemblerPredicate<"FeatureAES", "aes">;
269275 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
270276 AssemblerPredicate<"FeatureCrypto", "crypto">;
271277 def HasDotProd : Predicate<"Subtarget->hasDotProd()">,
104104 ARMv81a,
105105 ARMv82a,
106106 ARMv83a,
107 ARMv84a,
107108 ARMv8a,
108109 ARMv8mBaseline,
109110 ARMv8mMainline,
150151 bool HasV8_1aOps = false;
151152 bool HasV8_2aOps = false;
152153 bool HasV8_3aOps = false;
154 bool HasV8_4aOps = false;
153155 bool HasV8MBaselineOps = false;
154156 bool HasV8MMainlineOps = false;
155157
297299
298300 /// Has8MSecExt - if true, processor supports ARMv8-M Security Extensions
299301 bool Has8MSecExt = false;
302
303 /// HasSHA2 - if true, processor supports SHA1 and SHA256
304 bool HasSHA2 = false;
305
306 /// HasAES - if true, processor supports AES
307 bool HasAES = false;
300308
301309 /// HasCrypto - if true, processor supports Cryptography extensions
302310 bool HasCrypto = false;
512520 bool hasV8_1aOps() const { return HasV8_1aOps; }
513521 bool hasV8_2aOps() const { return HasV8_2aOps; }
514522 bool hasV8_3aOps() const { return HasV8_3aOps; }
523 bool hasV8_4aOps() const { return HasV8_4aOps; }
515524 bool hasV8MBaselineOps() const { return HasV8MBaselineOps; }
516525 bool hasV8MMainlineOps() const { return HasV8MMainlineOps; }
517526
537546 bool hasVFP4() const { return HasVFPv4; }
538547 bool hasFPARMv8() const { return HasFPARMv8; }
539548 bool hasNEON() const { return HasNEON; }
549 bool hasSHA2() const { return HasSHA2; }
550 bool hasAES() const { return HasAES; }
540551 bool hasCrypto() const { return HasCrypto; }
541552 bool hasDotProd() const { return HasDotProd; }
542553 bool hasCRC() const { return HasCRC; }
858858 case ARM::ArchKind::ARMV8A:
859859 case ARM::ArchKind::ARMV8_1A:
860860 case ARM::ArchKind::ARMV8_2A:
861 case ARM::ArchKind::ARMV8_3A:
862 case ARM::ArchKind::ARMV8_4A:
861863 setAttributeItem(CPU_arch_profile, ApplicationProfile, false);
862864 setAttributeItem(ARM_ISA_use, Allowed, false);
863865 setAttributeItem(THUMB_ISA_use, AllowThumb32, false);