[PR testsuite/116860] Testsuite adjustment for recently added tests
[official-gcc.git] / gcc / config / aarch64 / aarch64-feature-deps.h
blob55a0dbfae6107388d97528b637f9120cc6b933a1
1 /* Feature dependency helpers for AArch64.
2 Copyright (C) 2022-2025 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 GCC is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef AARCH64_FEATURE_DEPS_H
21 #define AARCH64_FEATURE_DEPS_H 1
23 namespace {
24 namespace feature_deps {
26 /* Together, these definitions of get_flags take a list of
27 feature names (representing functions that are defined below)
28 and return the set of associated flags. */
29 constexpr aarch64_feature_flags get_flags () { return 0; }
31 template<typename T1, typename ...Ts>
32 constexpr aarch64_feature_flags
33 get_flags (T1 i, Ts... args)
35 return i ().flag | get_flags (args...);
38 /* Like get_flags, but return the transitive closure of those features
39 and the ones that they rely on. */
40 constexpr aarch64_feature_flags get_enable () { return 0; }
42 template<typename T1, typename ...Ts>
43 constexpr aarch64_feature_flags
44 get_enable (T1 i, Ts... args)
46 return i ().enable | get_enable (args...);
49 /* Define info<FEATURE> such that it has the following static constant
50 variables:
52 - flag: the aarch64_feature_flags bit associated with FEATURE
54 - enable: the transitive closure of the features that FEATURE requires,
55 plus FLAG itself
57 - explicit_on: the transitive closure of the features that an
58 explicit +FEATURE enables, including FLAG itself. This is
59 always a superset of ENABLE, except that the CRYPTO alias bit is
60 explicitly unset for consistency.
62 Also define a function FEATURE () that returns an info<FEATURE>
63 (which is an empty structure, since all members are static).
65 Building up the list feature-by-feature ensures that the definition
66 files are in topological order. */
67 template<aarch64_feature> struct info;
69 #define HANDLE(IDENT, REQUIRES, EXPLICIT_ON) \
70 template<> struct info<aarch64_feature::IDENT> { \
71 static constexpr auto flag = AARCH64_FL_##IDENT; \
72 static constexpr auto enable = flag | get_enable REQUIRES; \
73 static constexpr auto explicit_on \
74 = (enable | get_enable EXPLICIT_ON) & ~AARCH64_FL_CRYPTO; \
75 }; \
76 constexpr aarch64_feature_flags info<aarch64_feature::IDENT>::flag; \
77 constexpr aarch64_feature_flags info<aarch64_feature::IDENT>::enable; \
78 constexpr aarch64_feature_flags info<aarch64_feature::IDENT>::explicit_on; \
79 constexpr info<aarch64_feature::IDENT> IDENT () \
80 { \
81 return info<aarch64_feature::IDENT> (); \
83 #define AARCH64_OPT_EXTENSION(A, IDENT, REQUIRES, EXPLICIT_ON, E, F) \
84 HANDLE (IDENT, REQUIRES, EXPLICIT_ON)
85 #define AARCH64_ARCH(A, B, IDENT, D, REQUIRES) HANDLE (IDENT, REQUIRES, ())
86 #include "config/aarch64/aarch64-option-extensions.def"
87 #include "config/aarch64/aarch64-arches.def"
88 #undef HANDLE
90 /* Return the set of all features that would need to be disabled if
91 the features in MASK are disabled.
93 Note that the size of the expression varies linearly with the number
94 of features, which means that invoking this function once per feature
95 is quadratic in the number of features. However, collecting the same
96 information at compiler start-up is likely to be quadratic too, so
97 we're better off paying the cost once per compiler build rather than
98 once per compiler run. */
99 constexpr aarch64_feature_flags
100 get_flags_off (aarch64_feature_flags mask)
102 return (aarch64_feature_flags (0)
103 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) \
104 | (feature_deps::IDENT ().enable & mask ? AARCH64_FL_##IDENT \
105 : aarch64_feature_flags (0))
106 #include "config/aarch64/aarch64-option-extensions.def"
110 /* Define root_off_<IDENT> variables for each feature, giving the set of
111 features that must be turned off by +noIDENT. This set is not transitively
112 closed; use get_flags_off to complete the closure. */
113 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, EXPLICIT_OFF, F) \
114 constexpr auto root_off_##IDENT \
115 = AARCH64_FL_##IDENT | get_flags EXPLICIT_OFF;
116 #include "config/aarch64/aarch64-option-extensions.def"
118 /* Define cpu_<NAME> variables for each CPU, giving the transitive
119 closure of all the features that the CPU supports. The CRYPTO bit is just
120 an alias, so explicitly unset it for consistency. */
121 #define AARCH64_CORE(A, CORE_IDENT, C, ARCH_IDENT, FEATURES, F, G, H, I) \
122 constexpr auto cpu_##CORE_IDENT \
123 = (ARCH_IDENT ().enable | get_enable FEATURES) & ~AARCH64_FL_CRYPTO;
124 #include "config/aarch64/aarch64-cores.def"
126 /* Define fmv_deps_<NAME> variables for each FMV feature, giving the transitive
127 closure of all the features that the FMV feature enables. */
128 #define AARCH64_FMV_FEATURE(A, FEAT_NAME, OPT_FLAGS) \
129 constexpr auto fmv_deps_##FEAT_NAME = get_enable OPT_FLAGS;
130 #include "config/aarch64/aarch64-option-extensions.def"
136 #endif