arm: Define __ARM_FEATURE_AES and __ARM_FEATURE_SHA2 when march +crypto is selected

Message ID 20220928121926.13280-1-andrea.corallo@arm.com
State New, archived
Headers
Series arm: Define __ARM_FEATURE_AES and __ARM_FEATURE_SHA2 when march +crypto is selected |

Commit Message

Andrea Corallo Sept. 28, 2022, 12:19 p.m. UTC
  Hi all,

this patch fixes the missing definition of __ARM_FEATURE_AES and
__ARM_FEATURE_SHA2 when AES SHA1 & SHA2 crypto instructions are
available [1] (read when march +crypto is selected).

Okay for master?

Thanks

  Andrea

[1] <https://raw.githubusercontent.com/ARM-software/acle/main/main/acle.md>

/gcc/ChangeLog

2022-09-14  Andrea Corallo  <andrea.corallo@arm.com>

	* config/arm/arm-c.cc (arm_cpu_builtins): Define
	__ARM_FEATURE_AES and __ARM_FEATURE_SHA2.

gcc/testsuite/ChangeLog

2022-09-14  Andrea Corallo  <andrea.corallo@arm.com>

	* gcc.target/arm/attr-crypto.c: Update test.
---
 gcc/config/arm/arm-c.cc                    | 2 ++
 gcc/testsuite/gcc.target/arm/attr-crypto.c | 8 ++++++++
 2 files changed, 10 insertions(+)
  

Comments

Kyrylo Tkachov Sept. 28, 2022, 12:23 p.m. UTC | #1
Hi Andrea,

> -----Original Message-----
> From: Andrea Corallo <andrea.corallo@arm.com>
> Sent: Wednesday, September 28, 2022 1:19 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>; Richard Earnshaw
> <Richard.Earnshaw@arm.com>; Andrea Corallo <Andrea.Corallo@arm.com>
> Subject: [PATCH] arm: Define __ARM_FEATURE_AES and
> __ARM_FEATURE_SHA2 when march +crypto is selected
> 
> Hi all,
> 
> this patch fixes the missing definition of __ARM_FEATURE_AES and
> __ARM_FEATURE_SHA2 when AES SHA1 & SHA2 crypto instructions are
> available [1] (read when march +crypto is selected).
> 
> Okay for master?

Ok.
Thanks,
Kyrill

> 
> Thanks
> 
>   Andrea
> 
> [1] <https://raw.githubusercontent.com/ARM-
> software/acle/main/main/acle.md>
> 
> /gcc/ChangeLog
> 
> 2022-09-14  Andrea Corallo  <andrea.corallo@arm.com>
> 
> 	* config/arm/arm-c.cc (arm_cpu_builtins): Define
> 	__ARM_FEATURE_AES and __ARM_FEATURE_SHA2.
> 
> gcc/testsuite/ChangeLog
> 
> 2022-09-14  Andrea Corallo  <andrea.corallo@arm.com>
> 
> 	* gcc.target/arm/attr-crypto.c: Update test.
> ---
>  gcc/config/arm/arm-c.cc                    | 2 ++
>  gcc/testsuite/gcc.target/arm/attr-crypto.c | 8 ++++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/gcc/config/arm/arm-c.cc b/gcc/config/arm/arm-c.cc
> index a8697b8c62f..86c56bf2680 100644
> --- a/gcc/config/arm/arm-c.cc
> +++ b/gcc/config/arm/arm-c.cc
> @@ -202,6 +202,8 @@ arm_cpu_builtins (struct cpp_reader* pfile)
>    def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT",
> TARGET_ARM_QBIT);
>    def_or_undef_macro (pfile, "__ARM_FEATURE_SAT", TARGET_ARM_SAT);
>    def_or_undef_macro (pfile, "__ARM_FEATURE_CRYPTO",
> TARGET_CRYPTO);
> +  def_or_undef_macro (pfile, "__ARM_FEATURE_AES", TARGET_CRYPTO);
> +  def_or_undef_macro (pfile, "__ARM_FEATURE_SHA2", TARGET_CRYPTO);
> 
>    def_or_undef_macro (pfile, "__ARM_FEATURE_UNALIGNED",
> unaligned_access);
> 
> diff --git a/gcc/testsuite/gcc.target/arm/attr-crypto.c
> b/gcc/testsuite/gcc.target/arm/attr-crypto.c
> index cbd13a757d8..05e458f36b6 100644
> --- a/gcc/testsuite/gcc.target/arm/attr-crypto.c
> +++ b/gcc/testsuite/gcc.target/arm/attr-crypto.c
> @@ -16,6 +16,14 @@
>  #error __ARM_FEATURE_CRYPTO not defined.
>  #endif
> 
> +#ifndef __ARM_FEATURE_AES
> +#error __ARM_FEATURE_AES not defined.
> +#endif
> +
> +#ifndef __ARM_FEATURE_SHA2
> +#error __ARM_FEATURE_SHA2 not defined.
> +#endif
> +
>  #ifndef __ARM_NEON
>  #error __ARM_NEON not defined.
>  #endif
> --
> 2.25.1
  
Andrea Corallo Sept. 28, 2022, 1:26 p.m. UTC | #2
Kyrylo Tkachov <Kyrylo.Tkachov@arm.com> writes:

> Hi Andrea,
>
>> -----Original Message-----
>> From: Andrea Corallo <andrea.corallo@arm.com>
>> Sent: Wednesday, September 28, 2022 1:19 PM
>> To: gcc-patches@gcc.gnu.org
>> Cc: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>; Richard Earnshaw
>> <Richard.Earnshaw@arm.com>; Andrea Corallo <Andrea.Corallo@arm.com>
>> Subject: [PATCH] arm: Define __ARM_FEATURE_AES and
>> __ARM_FEATURE_SHA2 when march +crypto is selected
>> 
>> Hi all,
>> 
>> this patch fixes the missing definition of __ARM_FEATURE_AES and
>> __ARM_FEATURE_SHA2 when AES SHA1 & SHA2 crypto instructions are
>> available [1] (read when march +crypto is selected).
>> 
>> Okay for master?
>
> Ok.
> Thanks,
> Kyrill

Into trunk as 5e9c4ed903c.

Thanks!

  Andrea
  

Patch

diff --git a/gcc/config/arm/arm-c.cc b/gcc/config/arm/arm-c.cc
index a8697b8c62f..86c56bf2680 100644
--- a/gcc/config/arm/arm-c.cc
+++ b/gcc/config/arm/arm-c.cc
@@ -202,6 +202,8 @@  arm_cpu_builtins (struct cpp_reader* pfile)
   def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT", TARGET_ARM_QBIT);
   def_or_undef_macro (pfile, "__ARM_FEATURE_SAT", TARGET_ARM_SAT);
   def_or_undef_macro (pfile, "__ARM_FEATURE_CRYPTO", TARGET_CRYPTO);
+  def_or_undef_macro (pfile, "__ARM_FEATURE_AES", TARGET_CRYPTO);
+  def_or_undef_macro (pfile, "__ARM_FEATURE_SHA2", TARGET_CRYPTO);
 
   def_or_undef_macro (pfile, "__ARM_FEATURE_UNALIGNED", unaligned_access);
 
diff --git a/gcc/testsuite/gcc.target/arm/attr-crypto.c b/gcc/testsuite/gcc.target/arm/attr-crypto.c
index cbd13a757d8..05e458f36b6 100644
--- a/gcc/testsuite/gcc.target/arm/attr-crypto.c
+++ b/gcc/testsuite/gcc.target/arm/attr-crypto.c
@@ -16,6 +16,14 @@ 
 #error __ARM_FEATURE_CRYPTO not defined.
 #endif
 
+#ifndef __ARM_FEATURE_AES
+#error __ARM_FEATURE_AES not defined.
+#endif
+
+#ifndef __ARM_FEATURE_SHA2
+#error __ARM_FEATURE_SHA2 not defined.
+#endif
+
 #ifndef __ARM_NEON
 #error __ARM_NEON not defined.
 #endif