[PATCH] D102406: [ARM][AArch64] Correct __ARM_FEATURE_CRYPTO macro and crypto feature

David Candler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 13 08:20:58 PDT 2021


dcandler created this revision.
dcandler added reviewers: t.p.northover, lenary.
Herald added subscribers: danielkiss, kristof.beyls.
dcandler requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch contains a couple of minor corrections to my previous
crypto patch:

Since both AArch32 and AArch64 are now correctly setting the aes and
sha2 features individually, it is not necessary to continue to check
the crypto feature when defining feature macros.

In the AArch32 driver, the feature vector is only modified when the
crypto feature is actually in the vector. If crypto is not present,
there is no need to split it and explicitly define crypto/sha2/aes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102406

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp


Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -636,6 +636,10 @@
   // FIXME: this needs reimplementation after the TargetParser rewrite
   bool HasSHA2 = false;
   bool HasAES = false;
+  const auto ItCrypto =
+      llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
+        return F.contains("crypto");
+      });
   const auto ItSHA2 =
       llvm::find_if(llvm::reverse(Features), [](const StringRef F) {
         return F.contains("crypto") || F.contains("sha2");
@@ -650,7 +654,7 @@
     HasSHA2 = ItSHA2->take_front() == "+";
   if (FoundAES)
     HasAES = ItAES->take_front() == "+";
-  if (FoundSHA2 || FoundAES) {
+  if (ItCrypto != Features.rend()) {
     if (HasSHA2 && HasAES)
       Features.push_back("+crypto");
     else
Index: clang/lib/Basic/Targets/ARM.cpp
===================================================================
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -649,7 +649,7 @@
     // ACLE 6.5.7 Crypto Extension
     // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained
     // feature macros for AES and SHA2
-    if (Crypto || (SHA2 && AES))
+    if (SHA2 && AES)
       Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
     if (SHA2)
       Builder.defineMacro("__ARM_FEATURE_SHA2", "1");
Index: clang/lib/Basic/Targets/AArch64.cpp
===================================================================
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -289,7 +289,7 @@
 
   // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
   // macros for AES, SHA2, SHA3 and SM4
-  if (HasCrypto || (HasAES && HasSHA2))
+  if (HasAES && HasSHA2)
     Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
 
   if (HasAES)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102406.345155.patch
Type: text/x-patch
Size: 1917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210513/677acb7c/attachment.bin>


More information about the cfe-commits mailing list