[PATCH 1/2] aarch64: use macro trickery to automate feature array size replication
Jan Beulich
jbeulich@suse.com
Fri Jun 6 13:08:59 GMT 2025
On 06.06.2025 14:27, Richard Earnshaw wrote:
> --- a/include/opcode/aarch64.h
> +++ b/include/opcode/aarch64.h
> @@ -290,13 +290,44 @@ enum aarch64_feature_bit {
> AARCH64_NUM_FEATURES
> };
>
> +typedef uint64_t aarch64_feature_word;
> +#define AARCH64_BITS_PER_FEATURE_WORD 64
> +
> +/* Maximum number of features that we can currently support. If you
> + need to increase this value you will need to increase the number of
> + replication statements in AA64_REPLICATE below. */
> +#define AARCH64_MAX_FEATURES (AARCH64_BITS_PER_FEATURE_WORD * 2)
Maybe you can get away without this (and hence without any need to keep
two things in sync)?
> +static_assert (AARCH64_MAX_FEATURES > AARCH64_NUM_FEATURES,
(As an aside - isn't >= sufficient here?)
> + "Insufficent capacity in AARCH64_MAX_FEATURES");
> +
> +#define AA64_REPLICATE(SEP, BODY, ...) \
> + BODY (0, __VA_ARGS__) SEP \
> + BODY (1, __VA_ARGS__)
Move the static_assert() further down and use
#define XYZ_BODY(x, ...) [x] = (x)
static_assert (AARCH64_BITS_PER_FEATURE_WORD
* sizeof ((char[]){ AA64_REPLICATE (REP_COMMA, XYZ_BODY) })
>= AARCH64_NUM_FEATURES,
"Insufficient repetitions in AA64_REPLICATE()");
Jan
More information about the Binutils
mailing list