Skip to content

Commit b53781c

Browse files
aarch64: Make AARCH64_FL_CRYPTO always unset
This feature flag bit only exists to support the +crypto alias. Outside of option processing this bit needs to be set or unset consistently. This patch goes with the latter option. gcc/ChangeLog: * common/config/aarch64/aarch64-common.cc: Assert that CRYPTO bit is not set. * config/aarch64/aarch64-feature-deps.h (info<FEAT>.explicit_on): Unset CRYPTO bit. (cpu_##CORE_IDENT): Ditto. gcc/testsuite/ChangeLog: * gcc.target/aarch64/crypto-alias-1.c: New test.
1 parent c6ef35b commit b53781c

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

gcc/common/config/aarch64/aarch64-common.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,10 @@ aarch64_get_extension_string_for_isa_flags
613613
{
614614
std::string outstr = "";
615615

616+
/* The CRYPTO bit should only be used to support the +crypto alias
617+
during option processing, and should be cleared at all other times.
618+
Verify this property for the supplied flags bitmask. */
619+
gcc_assert (!(AARCH64_FL_CRYPTO & aarch64_isa_flags));
616620
aarch64_feature_flags current_flags = default_arch_flags;
617621

618622
/* As a special case, do not assume that the assembler will enable CRC

gcc/config/aarch64/aarch64-feature-deps.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ get_enable (T1 i, Ts... args)
5656
5757
- explicit_on: the transitive closure of the features that an
5858
explicit +FEATURE enables, including FLAG itself. This is
59-
always a superset of ENABLE
59+
always a superset of ENABLE, except that the CRYPTO alias bit is
60+
explicitly unset for consistency.
6061
6162
Also define a function FEATURE () that returns an info<FEATURE>
6263
(which is an empty structure, since all members are static).
@@ -69,7 +70,8 @@ template<aarch64_feature> struct info;
6970
template<> struct info<aarch64_feature::IDENT> { \
7071
static constexpr auto flag = AARCH64_FL_##IDENT; \
7172
static constexpr auto enable = flag | get_enable REQUIRES; \
72-
static constexpr auto explicit_on = enable | get_enable EXPLICIT_ON; \
73+
static constexpr auto explicit_on \
74+
= (enable | get_enable EXPLICIT_ON) & ~AARCH64_FL_CRYPTO; \
7375
}; \
7476
constexpr aarch64_feature_flags info<aarch64_feature::IDENT>::flag; \
7577
constexpr aarch64_feature_flags info<aarch64_feature::IDENT>::enable; \
@@ -114,9 +116,11 @@ get_flags_off (aarch64_feature_flags mask)
114116
#include "config/aarch64/aarch64-option-extensions.def"
115117

116118
/* Define cpu_<NAME> variables for each CPU, giving the transitive
117-
closure of all the features that the CPU supports. */
119+
closure of all the features that the CPU supports. The CRYPTO bit is just
120+
an alias, so explicitly unset it for consistency. */
118121
#define AARCH64_CORE(A, CORE_IDENT, C, ARCH_IDENT, FEATURES, F, G, H, I) \
119-
constexpr auto cpu_##CORE_IDENT = ARCH_IDENT ().enable | get_enable FEATURES;
122+
constexpr auto cpu_##CORE_IDENT \
123+
= (ARCH_IDENT ().enable | get_enable FEATURES) & ~AARCH64_FL_CRYPTO;
120124
#include "config/aarch64/aarch64-cores.def"
121125

122126
/* Define fmv_deps_<NAME> variables for each FMV feature, giving the transitive
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-mcpu=ampere1" } */
3+
4+
__attribute__ ((__always_inline__))
5+
__attribute__ ((target ("arch=armv8-a+crypto")))
6+
inline int bar()
7+
{
8+
return 5;
9+
}
10+
11+
int foo()
12+
{
13+
return bar();
14+
}

0 commit comments

Comments
 (0)