This patch makes the constructor of bbitmap explicit and deals with the
fallout throughout the codebase.
The goal of this is to avoid the re-occurrence of bugs such as PR123206.
In particular, it prevents implicit conversions from other types
(integers, booleans, pointers (!), etc.) in bbitmap context; instead one
must directly construct a bbitmap to use it in such a context.
Doing this revealed a bug in bbitmap: the destructive bitwise operators
(|=, &=, ^=) all returned this (a pointer) which was being implicitly
converted to a bbitmap. To verify this, I added some selftests for
these operators which indeed failed. Of course this latent bug becomes
a compile error when the ctor is marked explicit, which is much nicer.
This patch fixes that bug.
To see another benefit of this change, consider PR123206 on AArch64. The
previous patch marks the aarch64_pragma_builtins table as constexpr,
which gives errors such as this in the presence of the bug:
aarch64-builtins.cc:1736:1: error: the value of ‘global_options’ is not usable
in a constant expression
but with this change, we get clearer error messages which give more of
the context:
$GCC/gcc/config/aarch64/aarch64.h:242:39: error: cannot convert ‘bool’ to
‘aarch64_feature_flags’ {aka ‘bbitmap<2>’}
242 | #define TARGET_SIMD (TARGET_BASE_SIMD && TARGET_NON_STREAMING)
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
| |
| bool
$GCC/gcc/config/aarch64/aarch64-simd-pragma-builtins.def:200:48: note: in
expansion of macro ‘TARGET_SIMD’
200 | #define REQUIRED_EXTENSIONS nonstreaming_only (TARGET_SIMD)
| ^~~~~~~~~~~
$GCC/gcc/config/aarch64/aarch64-builtins.cc:1720:33: note: in expansion of
macro ‘REQUIRED_EXTENSIONS’
1720 | aarch64_required_extensions::REQUIRED_EXTENSIONS, FLAG_##F},
| ^~~~~~~~~~~~~~~~~~~
$GCC/gcc/config/aarch64/aarch64-simd-pragma-builtins.def:51:3: note: in
expansion of macro ‘ENTRY’
51 | ENTRY (N, ternary, T0, T1, T2, T3, U, F)
| ^~~~~
$GCC/gcc/config/aarch64/aarch64-simd-pragma-builtins.def:201:1: note: in
expansion of macro ‘ENTRY_TERNARY’
201 | ENTRY_TERNARY (vbsl_mf8, mf8, u8, mf8, mf8, UNSPEC_BSL, QUIET)
| ^~~~~~~~~~~~~
The main downside of this patch is that it makes usage of
aarch64_feature_flags slightly less ergonomic; contexts that previously
passed an integer constant 0 now need an object of type
aarch64_feature_flags. I've defined a macro AARCH64_FL_NONE to slightly
reduce the amount of typing needed (compared to aarch64_feature_flags (0)),
but it does make some of the code a little more verbose.
IMO the trade-off is worth it to avoid further mishaps such as the PR in
question (and the buggy bbitmap operators), but I would like to hear
others' thoughts on it, too.
Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk?
I'm happy to split this up or defer completely until next stage 1, if
folks prefer.
Thanks,
Alex
gcc/ChangeLog:
PR target/123206
* Makefile.in (OBJS): Add new bbitmap-selftest.o.
* bbitmap.h (bbitmap): Make ctor explict, fix destructive operators to
dereference 'this' on return.
* common/config/aarch64/aarch64-common.cc (all_extensions): Replace
uses of
literal 0 with AARCH64_FL_NONE.
(all_architectures): Likewise.
(all_cores): Likewise.
(aarch64_get_extension_string_for_isa_flags): Likewise, and also switch
from
using assignment to braced initialization for aarch64_feature_flags.
* config/aarch64/aarch64-builtins.cc
(aarch64_check_required_extensions):
Likewise.
(aarch64_general_required_extensions): Likewise, and avoid comparing
against literal 0.
* config/aarch64/aarch64-feature-deps.h (get_flags): Use AARCH64_FL_NONE
instead of literal 0.
(get_enable): Likewise.
(alias_prefer_over_flags_##IDENT): Likewise.
* config/aarch64/aarch64-protos.h (struct aarch64_target_switcher):
Likewise.
(struct aarch64_required_extensions): Likewise.
* config/aarch64/aarch64-simd-pragma-builtins.def: Likewise.
* config/aarch64/aarch64-sve-builtins-base.def: Likewise.
* config/aarch64/aarch64-sve-builtins-sme.def: Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.def: Likewise.
* config/aarch64/aarch64-sve-builtins.cc (DEF_NEON_SVE_FUNCTION):
Likewise.
(function_builder::get_attributes): Don't compare aarch64_feature_flags
values
against literal 0.
* config/aarch64/aarch64-sve-builtins.h
(function_expander::get_contiguous_base): Replace 0 with
AARCH64_FL_NONE.
* config/aarch64/aarch64.cc (all_cores): Likewise.
(aarch64_override_options): Likewise, plus use of braced initialization
instead of assignment.
(aarch64_process_target_attr): Use braced initialization for
isa_temp.
(aarch64_valid_sysreg_name_p): Avoid comparison of
aarch64_feature_flags against literal 0.
(aarch64_retrieve_sysreg): Likewise.
* config/aarch64/aarch64.h (AARCH64_FL_NONE): New.
(TARGET_STREAMING_COMPATIBLE): Avoid comparison of
aarch64_feature_flags value against literal 0.
* config/aarch64/driver-aarch64.cc (aarch64_cpu_data): Replace
use of 0 with AARCH64_FL_NONE.
(aarch64_arches): Likewise.
(host_detect_local_cpu): Use braced initialization for
aarch64_feature_flags.
* selftest-run-tests.cc (selftest::run_tests): Add bbitmap_cc_tests.
* selftest.h (bbitmap_cc_tests): New.
* bbitmap-selftests.cc: New file.
---
gcc/Makefile.in | 1 +
gcc/bbitmap-selftests.cc | 69 +++++++++++++++++++
gcc/bbitmap.h | 8 +--
gcc/common/config/aarch64/aarch64-common.cc | 16 +++--
gcc/config/aarch64/aarch64-builtins.cc | 12 ++--
gcc/config/aarch64/aarch64-feature-deps.h | 7 +-
gcc/config/aarch64/aarch64-protos.h | 10 +--
.../aarch64/aarch64-simd-pragma-builtins.def | 2 +-
.../aarch64/aarch64-sve-builtins-base.def | 4 +-
.../aarch64/aarch64-sve-builtins-sme.def | 4 +-
.../aarch64/aarch64-sve-builtins-sve2.def | 4 +-
gcc/config/aarch64/aarch64-sve-builtins.cc | 8 +--
gcc/config/aarch64/aarch64-sve-builtins.h | 2 +-
gcc/config/aarch64/aarch64.cc | 18 ++---
gcc/config/aarch64/aarch64.h | 4 +-
gcc/config/aarch64/driver-aarch64.cc | 10 +--
gcc/selftest-run-tests.cc | 1 +
gcc/selftest.h | 1 +
18 files changed, 129 insertions(+), 52 deletions(-)
create mode 100644 gcc/bbitmap-selftests.cc
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index abf98aabac8..9d7b94ce883 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1421,6 +1421,7 @@ OBJS = \
auto-profile.o \
bb-reorder.o \
bitmap.o \
+ bbitmap-selftests.o \
builtins.o \
caller-save.o \
calls.o \
diff --git a/gcc/bbitmap-selftests.cc b/gcc/bbitmap-selftests.cc
new file mode 100644
index 00000000000..7a48c90c27b
--- /dev/null
+++ b/gcc/bbitmap-selftests.cc
@@ -0,0 +1,69 @@
+/* Tests for bbitmap data structure.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "selftest.h"
+#include "bbitmap.h"
+
+#if CHECKING_P
+
+namespace selftest {
+
+void bbitmap_test_or_eq ()
+{
+ using bm = bbitmap<2>;
+ bm b {0};
+ b |= bm::from_index (1);
+ ASSERT_EQ (b, bm::from_index (1));
+ ASSERT_NE (b, bm::from_index (2));
+
+ // Check the retun value from operator|=.
+ ASSERT_EQ (b |= bm::from_index (1), bm::from_index (1));
+}
+
+void bbitmap_test_and_eq ()
+{
+ using bm = bbitmap<2>;
+ const bm z {0};
+
+ bm b = bm::from_index (1);
+ ASSERT_EQ (b &= bm::from_index (2), z);
+}
+
+void bbitmap_test_xor_eq ()
+{
+ using bm = bbitmap<2>;
+ const bm z {0};
+ bm b{0};
+ ASSERT_EQ (b ^= bm::from_index (1), bm::from_index (1));
+ ASSERT_EQ (b ^= bm::from_index (1), z);
+}
+
+void bbitmap_cc_tests ()
+{
+ bbitmap_test_or_eq ();
+ bbitmap_test_and_eq ();
+ bbitmap_test_xor_eq ();
+}
+
+} // namespace selftest
+
+#endif // CHECKING_P
diff --git a/gcc/bbitmap.h b/gcc/bbitmap.h
index e8da6cf5937..3aa19856188 100644
--- a/gcc/bbitmap.h
+++ b/gcc/bbitmap.h
@@ -138,7 +138,7 @@ public:
uint64_t val[N];
template<typename... Rest>
- constexpr bbitmap(Rest ...rest) : val{(uint64_t) rest...} {}
+ constexpr explicit bbitmap (Rest ...rest) : val{(uint64_t) rest...} {}
constexpr bbitmap<N> operator|(const bbitmap<N> other) const
{
@@ -151,7 +151,7 @@ public:
for (int i = 0; i < N; i++)
val[i] |= other.val[i];
- return this;
+ return *this;
}
constexpr bbitmap<N> operator&(const bbitmap<N> other) const
@@ -165,7 +165,7 @@ public:
for (int i = 0; i < N; i++)
val[i] &= other.val[i];
- return this;
+ return *this;
}
constexpr bbitmap<N> operator^(const bbitmap<N> other) const
@@ -179,7 +179,7 @@ public:
for (int i = 0; i < N; i++)
val[i] ^= other.val[i];
- return this;
+ return *this;
}
constexpr bbitmap<N> operator~() const
diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
index ae467f140e3..b661da91f96 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -180,7 +180,9 @@ static constexpr aarch64_extension_info all_extensions[] =
feature_deps::IDENT ().enable, \
feature_deps::alias_prefer_over_flags_##IDENT},
#include "config/aarch64/aarch64-option-extensions.def"
- {NULL, 0, 0, 0, 0, 0}
+#define Z AARCH64_FL_NONE
+ {NULL, Z, Z, Z, Z, Z}
+#undef Z
};
struct aarch64_arch_info
@@ -196,7 +198,7 @@ static constexpr aarch64_arch_info all_architectures[] =
#define AARCH64_ARCH(NAME, B, ARCH_IDENT, D, E) \
{NAME, AARCH64_ARCH_##ARCH_IDENT, feature_deps::ARCH_IDENT ().enable},
#include "config/aarch64/aarch64-arches.def"
- {NULL, aarch64_no_arch, 0}
+ {NULL, aarch64_no_arch, AARCH64_FL_NONE}
};
struct aarch64_processor_info
@@ -215,7 +217,7 @@ static constexpr aarch64_processor_info all_cores[] =
{NAME, AARCH64_CPU_##CORE_IDENT, AARCH64_ARCH_##ARCH_IDENT, \
feature_deps::cpu_##CORE_IDENT},
#include "config/aarch64/aarch64-cores.def"
- {NULL, aarch64_no_cpu, aarch64_no_arch, 0}
+ {NULL, aarch64_no_cpu, aarch64_no_arch, AARCH64_FL_NONE}
};
/* Return the set of feature flags that are required to be enabled when the
@@ -654,14 +656,14 @@ aarch64_get_extension_string_for_isa_flags
However, assemblers with Armv8-R AArch64 support should not have this
issue, so we don't need this fix when targeting Armv8-R. */
auto explicit_flags = (!(current_flags & AARCH64_FL_V8R)
- ? AARCH64_FL_CRC : 0);
+ ? AARCH64_FL_CRC : AARCH64_FL_NONE);
/* Add the features in isa_flags & ~current_flags using the smallest
possible number of extensions. We can do this by iterating over the
array in reverse order, since the array is sorted topologically.
But in order to make the output more readable, it seems better
to add the strings in definition order. */
- aarch64_feature_flags added = 0;
+ aarch64_feature_flags added {0};
for (unsigned int i = ARRAY_SIZE (all_extensions); i-- > 0; )
{
auto &opt = all_extensions[i];
@@ -698,7 +700,7 @@ aarch64_get_extension_string_for_isa_flags
detection because one way or another we can't tell if it's available
or not. */
- aarch64_feature_flags removed = 0;
+ aarch64_feature_flags removed {0};
for (auto &opt : all_extensions)
if (!opt.flags_alias_preferred_over
&& (opt.flag_canonical & current_flags & ~isa_flags))
@@ -721,7 +723,7 @@ aarch64_get_extension_string_for_isa_flags
to use the alias. */
&& (removed & alias.flags_alias_preferred_over)
/* Check this doesn't turn off more flags than we need. */
- && (alias.flags_off & isa_flags) == 0)
+ && !bool (alias.flags_off & isa_flags))
{
removed &= ~alias.flags_off;
removed |= alias.flag_canonical;
diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index 07c78ac0630..1f08634e28d 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -2685,10 +2685,10 @@ aarch64_check_required_extensions (location_t location, tree fndecl,
aarch64_required_extensions
required_extensions)
{
- aarch64_feature_flags sm_state_extensions = 0;
+ aarch64_feature_flags sm_state_extensions {0};
if (!TARGET_STREAMING)
{
- if (required_extensions.sm_off == 0)
+ if (!bool (required_extensions.sm_off))
{
error_at (location, "ACLE function %qD can only be called when"
" SME streaming mode is enabled", fndecl);
@@ -2698,7 +2698,7 @@ aarch64_check_required_extensions (location_t location, tree fndecl,
}
if (!TARGET_NON_STREAMING)
{
- if (required_extensions.sm_on == 0)
+ if (!bool (required_extensions.sm_on))
{
error_at (location, "ACLE function %qD cannot be called when"
" SME streaming mode is enabled", fndecl);
@@ -2707,11 +2707,11 @@ aarch64_check_required_extensions (location_t location, tree fndecl,
sm_state_extensions |= required_extensions.sm_on & ~AARCH64_FL_SM_ON;
}
- if ((sm_state_extensions & ~aarch64_isa_flags) == 0)
+ if (!bool (sm_state_extensions & ~aarch64_isa_flags))
return true;
auto missing_extensions = sm_state_extensions & ~aarch64_asm_isa_flags;
- if (missing_extensions == 0)
+ if (!bool (missing_extensions))
{
/* All required extensions are enabled in aarch64_asm_isa_flags, so the
error must be the use of general-regs-only. */
@@ -2771,7 +2771,7 @@ aarch64_general_required_extensions (unsigned int code)
if (auto builtin_data = aarch64_get_pragma_builtin (code))
return builtin_data->required_extensions;
}
- return ext::streaming_compatible (0);
+ return ext::streaming_compatible (AARCH64_FL_NONE);
}
/* Checks calls to intrinsics that are defined using
diff --git a/gcc/config/aarch64/aarch64-feature-deps.h b/gcc/config/aarch64/aarch64-feature-deps.h
index 6dd3ac57380..e0c156701fb 100644
--- a/gcc/config/aarch64/aarch64-feature-deps.h
+++ b/gcc/config/aarch64/aarch64-feature-deps.h
@@ -26,7 +26,7 @@ namespace feature_deps {
/* Together, these definitions of get_flags take a list of
feature names (representing functions that are defined below)
and return the set of associated flags. */
-constexpr aarch64_feature_flags get_flags () { return 0; }
+constexpr aarch64_feature_flags get_flags () { return AARCH64_FL_NONE; }
template<typename T1, typename ...Ts>
constexpr aarch64_feature_flags
@@ -37,7 +37,7 @@ get_flags (T1 i, Ts... args)
/* Like get_flags, but return the transitive closure of those features
and the ones that they rely on. */
-constexpr aarch64_feature_flags get_enable () { return 0; }
+constexpr aarch64_feature_flags get_enable () { return AARCH64_FL_NONE; }
template<typename T1, typename ...Ts>
constexpr aarch64_feature_flags
@@ -139,7 +139,8 @@ get_flags_off (aarch64_feature_flags mask)
PREFER_FLAGS, G) \
constexpr auto alias_prefer_over_flags_##IDENT = get_flags PREFER_FLAGS;
#define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) \
- constexpr aarch64_feature_flags alias_prefer_over_flags_##IDENT = 0;
+ constexpr aarch64_feature_flags alias_prefer_over_flags_##IDENT \
+ = AARCH64_FL_NONE;
#include "config/aarch64/aarch64-option-extensions.def"
}
}
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 48d3a3de235..0a829ded2bd 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -747,7 +747,7 @@ const unsigned int AARCH64_BUILTIN_CLASS = (1 << AARCH64_BUILTIN_SHIFT) - 1;
class aarch64_target_switcher
{
public:
- aarch64_target_switcher (aarch64_feature_flags flags = 0);
+ aarch64_target_switcher (aarch64_feature_flags flags = AARCH64_FL_NONE);
~aarch64_target_switcher ();
private:
@@ -768,8 +768,8 @@ struct aarch64_required_extensions
inline CONSTEXPR aarch64_required_extensions
and_also (aarch64_feature_flags flags)
{
- return { sm_off ? sm_off | flags : 0,
- sm_on ? sm_on | flags : 0 };
+ return { sm_off ? sm_off | flags : AARCH64_FL_NONE,
+ sm_on ? sm_on | flags : AARCH64_FL_NONE };
}
/* Return a requirement that is as restrictive as possible while still being
@@ -789,7 +789,7 @@ struct aarch64_required_extensions
static inline CONSTEXPR aarch64_required_extensions
nonstreaming_only (aarch64_feature_flags flags)
{
- return { AARCH64_FL_SM_OFF | flags, 0 };
+ return { AARCH64_FL_SM_OFF | flags, AARCH64_FL_NONE };
}
/* Likewise, and also require SVE. */
@@ -835,7 +835,7 @@ struct aarch64_required_extensions
static inline CONSTEXPR aarch64_required_extensions
streaming_only (aarch64_feature_flags flags)
{
- return { 0, AARCH64_FL_SM_ON | flags };
+ return { AARCH64_FL_NONE, AARCH64_FL_SM_ON | flags };
}
/* The ISA requirements in non-streaming mode, or 0 if the operation
diff --git a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
index 41bafb2a96e..2faaf29431a 100644
--- a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
+++ b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
@@ -203,7 +203,7 @@ ENTRY_TERNARY (vbslq_mf8, mf8q, u8q, mf8q, mf8q, UNSPEC_BSL, QUIET)
#undef REQUIRED_EXTENSIONS
// combine
-#define REQUIRED_EXTENSIONS nonstreaming_only (0)
+#define REQUIRED_EXTENSIONS nonstreaming_only (AARCH64_FL_NONE)
ENTRY_BINARY (vcombine_mf8, mf8q, mf8, mf8, UNSPEC_COMBINE, QUIET)
#undef REQUIRED_EXTENSIONS
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.def b/gcc/config/aarch64/aarch64-sve-builtins-base.def
index 9914e060f4d..58c73b0183e 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-base.def
+++ b/gcc/config/aarch64/aarch64-sve-builtins-base.def
@@ -20,7 +20,7 @@
/* Code organization: See block comment at the top of
aarch64-sve-builtins.def. */
-#define REQUIRED_EXTENSIONS ssve (0)
+#define REQUIRED_EXTENSIONS ssve (AARCH64_FL_NONE)
DEF_SVE_FUNCTION (svabd, binary_opt_n, all_arith, mxz)
DEF_SVE_FUNCTION (svabs, unary, all_float_and_signed, mxz)
DEF_SVE_FUNCTION (svacge, compare_opt_n, all_float, implicit)
@@ -268,7 +268,7 @@ DEF_SVE_FUNCTION (svzip2, binary, all_data, none)
DEF_SVE_FUNCTION (svzip2, binary_pred, all_pred, none)
#undef REQUIRED_EXTENSIONS
-#define REQUIRED_EXTENSIONS nonstreaming_sve (0)
+#define REQUIRED_EXTENSIONS nonstreaming_sve (AARCH64_FL_NONE)
DEF_SVE_FUNCTION (svadda, fold_left, all_float, implicit)
DEF_SVE_FUNCTION (svadrb, adr_offset, none, none)
DEF_SVE_FUNCTION (svadrd, adr_index, none, none)
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-sme.def b/gcc/config/aarch64/aarch64-sve-builtins-sme.def
index 4feb4795287..c9c3c8c1560 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-sme.def
+++ b/gcc/config/aarch64/aarch64-sve-builtins-sme.def
@@ -40,7 +40,7 @@
DEF_SME_ZA_FUNCTION_GS_FPM (NAME, SHAPE, TYPES, none, PREDS, unused)
#endif
-#define REQUIRED_EXTENSIONS streaming_compatible (0)
+#define REQUIRED_EXTENSIONS streaming_compatible (AARCH64_FL_NONE)
DEF_SME_FUNCTION (arm_has_sme, bool_inherent, none, none)
DEF_SME_FUNCTION (arm_in_streaming_mode, bool_inherent, none, none)
#undef REQUIRED_EXTENSIONS
@@ -57,7 +57,7 @@ DEF_SME_ZA_FUNCTION (svzero, inherent_za, za, none)
DEF_SME_ZA_FUNCTION (svzero_mask, inherent_mask_za, za, none)
#undef REQUIRED_EXTENSIONS
-#define REQUIRED_EXTENSIONS streaming_only (0)
+#define REQUIRED_EXTENSIONS streaming_only (AARCH64_FL_NONE)
DEF_SME_ZA_FUNCTION (svaddha, unary_za_m, za_s_integer, za_m)
DEF_SME_ZA_FUNCTION (svaddva, unary_za_m, za_s_integer, za_m)
DEF_SME_ZA_FUNCTION (svld1_hor, load_za, all_za, none)
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-sve2.def b/gcc/config/aarch64/aarch64-sve-builtins-sve2.def
index 19249a58875..e6427f88eef 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-sve2.def
+++ b/gcc/config/aarch64/aarch64-sve-builtins-sve2.def
@@ -20,7 +20,7 @@
/* Code organization: See block comment at the top of
aarch64-sve-builtins.def. */
-#define REQUIRED_EXTENSIONS sve_and_sme (AARCH64_FL_SVE2, 0)
+#define REQUIRED_EXTENSIONS sve_and_sme (AARCH64_FL_SVE2, AARCH64_FL_NONE)
DEF_SVE_FUNCTION (svaba, ternary_opt_n, all_integer, none)
DEF_SVE_FUNCTION (svabalb, ternary_long_opt_n, hsd_integer, none)
DEF_SVE_FUNCTION (svabalt, ternary_long_opt_n, hsd_integer, none)
@@ -252,7 +252,7 @@ DEF_SVE_FUNCTION (svzipq1, binary, all_data, none)
DEF_SVE_FUNCTION (svzipq2, binary, all_data, none)
#undef REQUIRED_EXTENSIONS
-#define REQUIRED_EXTENSIONS sve_and_sme (AARCH64_FL_SVE2p1, 0)
+#define REQUIRED_EXTENSIONS sve_and_sme (AARCH64_FL_SVE2p1, AARCH64_FL_NONE)
DEF_SVE_FUNCTION (svclamp, clamp, all_integer, none)
DEF_SVE_FUNCTION (svpsel_lane, select_pred, all_pred_count, none)
DEF_SVE_FUNCTION (svrevd, unary, all_data, mxz)
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc
index d25e5437ba8..28b2c73ccb9 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -1001,8 +1001,8 @@ static CONSTEXPR const function_group_info function_groups[] = {
static CONSTEXPR const function_group_info neon_sve_function_groups[] = {
#define DEF_NEON_SVE_FUNCTION(NAME, SHAPE, TYPES, GROUPS, PREDS) \
{ #NAME, &neon_sve_bridge_functions::NAME, &shapes::SHAPE, types_##TYPES, \
- groups_##GROUPS, preds_##PREDS, aarch64_required_extensions::ssve (0), \
- FPM_unused },
+ groups_##GROUPS, preds_##PREDS, \
+ aarch64_required_extensions::ssve (AARCH64_FL_NONE), FPM_unused },
#include "aarch64-neon-sve-bridge-builtins.def"
};
@@ -1474,9 +1474,9 @@ function_builder::get_attributes (const function_instance &instance,
{
tree attrs = NULL_TREE;
- if (required_extensions.sm_off == 0)
+ if (!bool (required_extensions.sm_off))
attrs = add_attribute ("arm", "streaming", NULL_TREE, attrs);
- else if (required_extensions.sm_on != 0)
+ else if (bool (required_extensions.sm_on))
attrs = add_attribute ("arm", "streaming_compatible", NULL_TREE, attrs);
attrs = add_shared_state_attribute ("in", true, false,
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h
index f9e8c4cd729..15a4fe92e9f 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.h
+++ b/gcc/config/aarch64/aarch64-sve-builtins.h
@@ -698,7 +698,7 @@ public:
rtx convert_to_pmode (rtx);
rtx get_contiguous_base (machine_mode, unsigned int = 1, unsigned int = 2,
- aarch64_feature_flags = 0);
+ aarch64_feature_flags = AARCH64_FL_NONE);
rtx get_fallback_value (machine_mode, unsigned int,
unsigned int, unsigned int &);
rtx get_reg_target ();
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index e443dce6644..bc99cdcde47 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -481,7 +481,7 @@ static CONSTEXPR const processor all_architectures[] =
{NAME, AARCH64_CPU_##CORE, AARCH64_CPU_##CORE, AARCH64_ARCH_##ARCH_IDENT, \
feature_deps::ARCH_IDENT ().enable, NULL},
#include "aarch64-arches.def"
- {NULL, aarch64_no_cpu, aarch64_no_cpu, aarch64_no_arch, 0, NULL}
+ {NULL, aarch64_no_cpu, aarch64_no_cpu, aarch64_no_arch, AARCH64_FL_NONE, NULL}
};
/* Processor cores implementing AArch64. */
@@ -491,7 +491,7 @@ static const struct processor all_cores[] =
{NAME, AARCH64_CPU_##IDENT, AARCH64_CPU_##SCHED, AARCH64_ARCH_##ARCH, \
feature_deps::cpu_##IDENT, &COSTS##_tunings},
#include "aarch64-cores.def"
- {NULL, aarch64_no_cpu, aarch64_no_cpu, aarch64_no_arch, 0, NULL}
+ {NULL, aarch64_no_cpu, aarch64_no_cpu, aarch64_no_arch, AARCH64_FL_NONE, NULL}
};
/* Internal representation of system registers. */
typedef struct {
@@ -521,7 +521,7 @@ typedef struct {
#define AARCH64_FEATURES(N, ...) \
AARCH64_OR_FEATURES_##N (0, __VA_ARGS__)
-#define AARCH64_NO_FEATURES 0
+#define AARCH64_NO_FEATURES AARCH64_FL_NONE
/* Flags associated with the properties of system registers. It mainly serves
to mark particular registers as read or write only. */
@@ -19999,9 +19999,9 @@ static const struct aarch_branch_protect_type aarch64_branch_protect_types[] =
static void
aarch64_override_options (void)
{
- aarch64_feature_flags cpu_isa = 0;
- aarch64_feature_flags arch_isa = 0;
- aarch64_set_asm_isa_flags (0);
+ aarch64_feature_flags cpu_isa {0};
+ aarch64_feature_flags arch_isa {0};
+ aarch64_set_asm_isa_flags (AARCH64_FL_NONE);
aarch64_cpu cpu = aarch64_no_cpu;
aarch64_arch arch = aarch64_no_arch;
@@ -20789,7 +20789,7 @@ aarch64_process_target_attr (tree args)
{
/* Check if token is possibly an arch extension without
leading '+'. */
- aarch64_feature_flags isa_temp = 0;
+ aarch64_feature_flags isa_temp {0};
auto with_plus = std::string ("+") + token;
enum aarch_parse_opt_result ext_res
= aarch64_parse_extension (with_plus.c_str (), &isa_temp, nullptr);
@@ -32763,7 +32763,7 @@ aarch64_valid_sysreg_name_p (const char *regname)
return aarch64_is_implem_def_reg (regname);
return (!aarch64_enable_sysreg_guarding
- || ((~aarch64_isa_flags & sysreg->arch_reqs) == 0));
+ || !bool (~aarch64_isa_flags & sysreg->arch_reqs));
}
/* Return the generic sysreg specification for a valid system register
@@ -32787,7 +32787,7 @@ aarch64_retrieve_sysreg (const char *regname, bool write_p, bool is128op)
|| (!write_p && (sysreg->properties & F_REG_WRITE)))
return NULL;
if (aarch64_enable_sysreg_guarding
- && ((~aarch64_isa_flags & sysreg->arch_reqs) != 0))
+ && bool (~aarch64_isa_flags & sysreg->arch_reqs))
return NULL;
return sysreg->encoding;
}
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 1dd942f377f..104eaa73c58 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -168,6 +168,8 @@ enum class aarch64_feature : unsigned char {
#include "aarch64-arches.def"
};
+constexpr auto AARCH64_FL_NONE = aarch64_feature_flags (0);
+
/* Define unique flags for each of the above. */
#define HANDLE(IDENT) \
constexpr auto AARCH64_FL_##IDENT ATTRIBUTE_UNUSED \
@@ -223,7 +225,7 @@ constexpr auto AARCH64_FL_DEFAULT_ISA_MODE ATTRIBUTE_UNUSED
/* The current function has a streaming-compatible body. */
#define TARGET_STREAMING_COMPATIBLE \
- ((aarch64_isa_flags & AARCH64_FL_SM_STATE) == 0)
+ (!bool (aarch64_isa_flags & AARCH64_FL_SM_STATE))
/* PSTATE.ZA is enabled in the current function body. */
#define TARGET_ZA AARCH64_HAVE_ISA (ZA_ON)
diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc
index a8888640e21..d746c98fa50 100644
--- a/gcc/config/aarch64/driver-aarch64.cc
+++ b/gcc/config/aarch64/driver-aarch64.cc
@@ -68,7 +68,7 @@ struct aarch64_core_data
static CONSTEXPR const aarch64_core_data aarch64_cpu_data[] =
{
#include "aarch64-cores.def"
- { NULL, NULL, INVALID_IMP, INVALID_CORE, ALL_VARIANTS, 0 }
+ { NULL, NULL, INVALID_IMP, INVALID_CORE, ALL_VARIANTS, AARCH64_FL_NONE }
};
@@ -86,7 +86,7 @@ struct aarch64_arch_driver_info
static CONSTEXPR const aarch64_arch_driver_info aarch64_arches[] =
{
#include "aarch64-arches.def"
- {NULL, NULL, 0}
+ {NULL, NULL, AARCH64_FL_NONE}
};
@@ -275,9 +275,9 @@ host_detect_local_cpu (int argc, const char **argv)
unsigned int variants[3] = { ALL_VARIANTS, ALL_VARIANTS, ALL_VARIANTS };
unsigned int n_variants = 0;
bool processed_exts = false;
- aarch64_feature_flags extension_flags = 0;
- aarch64_feature_flags unchecked_extension_flags = 0;
- aarch64_feature_flags default_flags = 0;
+ aarch64_feature_flags extension_flags {0};
+ aarch64_feature_flags unchecked_extension_flags {0};
+ aarch64_feature_flags default_flags {0};
std::string buf;
size_t sep_pos = -1;
char *fcpu_info;
diff --git a/gcc/selftest-run-tests.cc b/gcc/selftest-run-tests.cc
index 7ead010360f..31a876a39b6 100644
--- a/gcc/selftest-run-tests.cc
+++ b/gcc/selftest-run-tests.cc
@@ -60,6 +60,7 @@ selftest::run_tests ()
selftest_cc_tests ();
/* Low-level data structures. */
+ bbitmap_cc_tests ();
bitmap_cc_tests ();
sbitmap_cc_tests ();
dumpfile_cc_tests ();
diff --git a/gcc/selftest.h b/gcc/selftest.h
index 462786dab2f..95c8a78a6ac 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -217,6 +217,7 @@ class test_runner
/* Declarations for specific families of tests (by source file), in
alphabetical order. */
extern void attribs_cc_tests ();
+extern void bbitmap_cc_tests ();
extern void bitmap_cc_tests ();
extern void cgraph_cc_tests ();
extern void convert_cc_tests ();