diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2023-09-26 15:01:21 +0100 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2023-09-26 15:01:21 +0100 |
commit | 4abb672ac1a2a14d32bfee02f2d05ae5e01af637 (patch) | |
tree | 0dfd2e84934d0cfe68521d95b0d4b24f9f112e03 /opcodes | |
parent | fc21e0f029c51687c2b4ca686d0b773ad5efeff4 (diff) | |
download | gdb-4abb672ac1a2a14d32bfee02f2d05ae5e01af637.zip gdb-4abb672ac1a2a14d32bfee02f2d05ae5e01af637.tar.gz gdb-4abb672ac1a2a14d32bfee02f2d05ae5e01af637.tar.bz2 |
aarch64: Restructure feature flag handling
The AArch64 feature-flag code is currently limited to a maximum
of 64 features. This patch reworks it so that the limit can be
increased more easily. The basic idea is:
(1) Turn the ARM_FEATURE_FOO macros into an enum, with the enum
counting bit positions.
(2) Make the feature-list macros take an array index argument
(currently always 0). The macros then return the
aarch64_feature_set contents for that array index.
An N-element array would then be initialised as:
{ MACRO (0), ..., MACRO (N - 1) }
(3) Provide convenience macros for initialising an
aarch64_feature_set for:
- a single feature
- a list of individual features
- an architecture version
- an architecture version + a list of additional features
(2) and (3) use the preprocessor to generate static initialisers.
The main restriction was that uses of the same preprocessor macro
cannot be nested. So if a macro wants to do something for N individual
arguments, it needs to use a chain of N macros to do it. There then
needs to be a way of deriving N, as a preprocessor token suitable for
pasting.
The easiest way of doing that was to precede each list of features
by the number of features in the list. So an aarch64_feature_set
initialiser for three features A, B and C would be written:
AARCH64_FEATURES (3, A, B, C)
This scheme makes it difficult to keep AARCH64_FEATURE_CRYPTO as a
synonym for SHA2+AES, so the patch expands the former to the latter.
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/aarch64-dis.c | 7 | ||||
-rw-r--r-- | opcodes/aarch64-opc.c | 54 | ||||
-rw-r--r-- | opcodes/aarch64-tbl.h | 118 |
3 files changed, 85 insertions, 94 deletions
diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c index 03bcc37..3bf5f50 100644 --- a/opcodes/aarch64-dis.c +++ b/opcodes/aarch64-dis.c @@ -3008,7 +3008,7 @@ determine_disassembling_preference (struct aarch64_inst *inst, continue; } - if (!AARCH64_CPU_HAS_FEATURE (arch_variant, *alias->avariant)) + if (!AARCH64_CPU_HAS_ALL_FEATURES (arch_variant, *alias->avariant)) { DEBUG_TRACE ("skip %s: we're missing features", alias->name); continue; @@ -3969,10 +3969,11 @@ select_aarch64_variant (unsigned mach) switch (mach) { case bfd_mach_aarch64_8R: - arch_variant = AARCH64_ARCH_V8R; + AARCH64_SET_FEATURE (arch_variant, AARCH64_ARCH_V8R); break; default: - arch_variant = AARCH64_ANY & ~(AARCH64_FEATURE_V8R); + arch_variant = (aarch64_feature_set) AARCH64_ALL_FEATURES; + AARCH64_CLEAR_FEATURE (arch_variant, arch_variant, V8R); } } diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c index 41dec5c..df1b511 100644 --- a/opcodes/aarch64-opc.c +++ b/opcodes/aarch64-opc.c @@ -4501,7 +4501,7 @@ aarch64_print_operand (char *buf, size_t size, bfd_vma pc, bool exact_match = (!(sr->flags & (F_REG_READ | F_REG_WRITE)) || (sr->flags & opnd->sysreg.flags) == opnd->sysreg.flags) - && AARCH64_CPU_HAS_FEATURE (features, sr->features); + && AARCH64_CPU_HAS_ALL_FEATURES (features, sr->features); /* Try and find an exact match, But if that fails, return the first partial match that was found. */ @@ -4674,17 +4674,14 @@ aarch64_print_operand (char *buf, size_t size, bfd_vma pc, #define C14 14 #define C15 15 -#define SYSREG(name, encoding, flags, features) \ - { name, encoding, flags, features } - -#define SR_CORE(n,e,f) SYSREG (n,e,f,0) +#define SR_CORE(n,e,f) {n,e,f,AARCH64_NO_FEATURES} #define SR_FEAT(n,e,f,feat) \ - SYSREG ((n), (e), (f) | F_ARCHEXT, AARCH64_FEATURE_##feat) + { (n), (e), (f) | F_ARCHEXT, AARCH64_FEATURE (feat) } #define SR_FEAT2(n,e,f,fe1,fe2) \ - SYSREG ((n), (e), (f) | F_ARCHEXT, \ - AARCH64_FEATURE_##fe1 | AARCH64_FEATURE_##fe2) + { (n), (e), (f) | F_ARCHEXT, \ + AARCH64_FEATURES (2, fe1, fe2) } #define SR_V8_1_A(n,e,f) SR_FEAT2(n,e,f,V8A,V8_1A) #define SR_V8_4_A(n,e,f) SR_FEAT2(n,e,f,V8A,V8_4A) @@ -5736,7 +5733,7 @@ const aarch64_sys_reg aarch64_sys_regs [] = SR_V8_8A ("allint", CPENC (3,0,C4,C3,0), 0), SR_V8_8A ("icc_nmiar1_el1", CPENC (3,0,C12,C9,5), F_REG_READ), - { 0, CPENC (0,0,0,0,0), 0, 0 } + { 0, CPENC (0,0,0,0,0), 0, AARCH64_NO_FEATURES } }; bool @@ -5769,7 +5766,7 @@ const aarch64_sys_reg aarch64_pstatefields [] = SR_SME ("svcrsmza", 0x1b, PSTATE_ENCODE_CRM_AND_IMM(0x6,0x1) | F_REG_MAX_VALUE (1)), SR_V8_8A ("allint", 0x08, F_REG_MAX_VALUE (1)), - { 0, CPENC (0,0,0,0,0), 0, 0 }, + { 0, CPENC (0,0,0,0,0), 0, AARCH64_NO_FEATURES }, }; bool @@ -5954,13 +5951,13 @@ aarch64_sys_ins_reg_has_xt (const aarch64_sys_ins_reg *sys_ins_reg) extern bool aarch64_sys_ins_reg_supported_p (const aarch64_feature_set features, - const char *reg_name, - aarch64_insn reg_value, - uint32_t reg_flags, - aarch64_feature_set reg_features) + const char *reg_name, + aarch64_insn reg_value, + uint32_t reg_flags, + const aarch64_feature_set *reg_features) { /* Armv8-R has no EL3. */ - if (AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8R)) + if (AARCH64_CPU_HAS_FEATURE (features, V8R)) { const char *suffix = strrchr (reg_name, '_'); if (suffix && !strcmp (suffix, "_el3")) @@ -5971,7 +5968,7 @@ aarch64_sys_ins_reg_supported_p (const aarch64_feature_set features, return true; if (reg_features - && AARCH64_CPU_HAS_ALL_FEATURES (features, reg_features)) + && AARCH64_CPU_HAS_ALL_FEATURES (features, *reg_features)) return true; /* ARMv8.4 TLB instructions. */ @@ -6021,17 +6018,17 @@ aarch64_sys_ins_reg_supported_p (const aarch64_feature_set features, || reg_value == CPENS (6, C8, C2, 5) || reg_value == CPENS (6, C8, C5, 1) || reg_value == CPENS (6, C8, C5, 5)) - && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_4A)) + && AARCH64_CPU_HAS_FEATURE (features, V8_4A)) return true; /* DC CVAP. Values are from aarch64_sys_regs_dc. */ if (reg_value == CPENS (3, C7, C12, 1) - && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_2A)) + && AARCH64_CPU_HAS_FEATURE (features, V8_2A)) return true; /* DC CVADP. Values are from aarch64_sys_regs_dc. */ if (reg_value == CPENS (3, C7, C13, 1) - && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_CVADP)) + && AARCH64_CPU_HAS_FEATURE (features, CVADP)) return true; /* DC <dc_op> for ARMv8.5-A Memory Tagging Extension. */ @@ -6053,18 +6050,18 @@ aarch64_sys_ins_reg_supported_p (const aarch64_feature_set features, || reg_value == CPENS (3, C7, C13, 5) || reg_value == CPENS (3, C7, C14, 5) || reg_value == CPENS (3, C7, C4, 4)) - && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_MEMTAG)) + && AARCH64_CPU_HAS_FEATURE (features, MEMTAG)) return true; /* AT S1E1RP, AT S1E1WP. Values are from aarch64_sys_regs_at. */ if ((reg_value == CPENS (0, C7, C9, 0) || reg_value == CPENS (0, C7, C9, 1)) - && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_V8_2A)) + && AARCH64_CPU_HAS_FEATURE (features, V8_2A)) return true; /* CFP/DVP/CPP RCTX : Value are from aarch64_sys_regs_sr. */ if (reg_value == CPENS (3, C7, C3, 0) - && AARCH64_CPU_HAS_FEATURE (features, AARCH64_FEATURE_PREDRES)) + && AARCH64_CPU_HAS_FEATURE (features, PREDRES)) return true; return false; @@ -6372,8 +6369,8 @@ verify_constraints (const struct aarch64_inst *inst, /* Check to see if the MOVPRFX SVE instruction is followed by an SVE instruction for better error messages. */ if (!opcode->avariant - || !(*opcode->avariant & - (AARCH64_FEATURE_SVE | AARCH64_FEATURE_SVE2))) + || (!AARCH64_CPU_HAS_FEATURE (*opcode->avariant, SVE) + && !AARCH64_CPU_HAS_FEATURE (*opcode->avariant, SVE2))) { mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; mismatch_detail->error = _("SVE instruction expected after " @@ -6614,7 +6611,8 @@ aarch64_sve_dupm_mov_immediate_p (uint64_t uvalue, int esize) supports the instruction described by INST. */ bool -aarch64_cpu_supports_inst_p (uint64_t cpu_variant, aarch64_inst *inst) +aarch64_cpu_supports_inst_p (aarch64_feature_set cpu_variant, + aarch64_inst *inst) { if (!inst->opcode->avariant || !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant, *inst->opcode->avariant)) @@ -6622,14 +6620,12 @@ aarch64_cpu_supports_inst_p (uint64_t cpu_variant, aarch64_inst *inst) if (inst->opcode->iclass == sme_fp_sd && inst->operands[0].qualifier == AARCH64_OPND_QLF_S_D - && !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant, - AARCH64_FEATURE_SME_F64F64)) + && !AARCH64_CPU_HAS_FEATURE (cpu_variant, SME_F64F64)) return false; if (inst->opcode->iclass == sme_int_sd && inst->operands[0].qualifier == AARCH64_OPND_QLF_S_D - && !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant, - AARCH64_FEATURE_SME_I16I64)) + && !AARCH64_CPU_HAS_FEATURE (cpu_variant, SME_I16I64)) return false; return true; diff --git a/opcodes/aarch64-tbl.h b/opcodes/aarch64-tbl.h index 3de1e37..dc72b13 100644 --- a/opcodes/aarch64-tbl.h +++ b/opcodes/aarch64-tbl.h @@ -2461,123 +2461,117 @@ error message for MOVPRFX constraint violations. */ static const aarch64_feature_set aarch64_feature_v8 = - AARCH64_FEATURE (AARCH64_FEATURE_V8, 0); + AARCH64_FEATURE (V8); static const aarch64_feature_set aarch64_feature_fp = - AARCH64_FEATURE (AARCH64_FEATURE_FP, 0); + AARCH64_FEATURE (FP); static const aarch64_feature_set aarch64_feature_simd = - AARCH64_FEATURE (AARCH64_FEATURE_SIMD, 0); + AARCH64_FEATURE (SIMD); static const aarch64_feature_set aarch64_feature_crc = - AARCH64_FEATURE (AARCH64_FEATURE_CRC, 0); + AARCH64_FEATURE (CRC); static const aarch64_feature_set aarch64_feature_lse = - AARCH64_FEATURE (AARCH64_FEATURE_LSE, 0); + AARCH64_FEATURE (LSE); static const aarch64_feature_set aarch64_feature_lor = - AARCH64_FEATURE (AARCH64_FEATURE_LOR, 0); + AARCH64_FEATURE (LOR); static const aarch64_feature_set aarch64_feature_rdma = - AARCH64_FEATURE (AARCH64_FEATURE_RDMA, 0); + AARCH64_FEATURE (RDMA); static const aarch64_feature_set aarch64_feature_v8_2a = - AARCH64_FEATURE (AARCH64_FEATURE_V8_2A, 0); + AARCH64_FEATURE (V8_2A); static const aarch64_feature_set aarch64_feature_fp_f16 = - AARCH64_FEATURE (AARCH64_FEATURE_F16 | AARCH64_FEATURE_FP, 0); + AARCH64_FEATURES (2, F16, FP); static const aarch64_feature_set aarch64_feature_simd_f16 = - AARCH64_FEATURE (AARCH64_FEATURE_F16 | AARCH64_FEATURE_SIMD, 0); + AARCH64_FEATURES (2, F16, SIMD); static const aarch64_feature_set aarch64_feature_sve = - AARCH64_FEATURE (AARCH64_FEATURE_SVE, 0); + AARCH64_FEATURE (SVE); static const aarch64_feature_set aarch64_feature_v8_3a = - AARCH64_FEATURE (AARCH64_FEATURE_V8_3A, 0); + AARCH64_FEATURE (V8_3A); static const aarch64_feature_set aarch64_feature_fp_v8_3a = - AARCH64_FEATURE (AARCH64_FEATURE_V8_3A | AARCH64_FEATURE_FP, 0); + AARCH64_FEATURES (2, V8_3A, FP); static const aarch64_feature_set aarch64_feature_pac = - AARCH64_FEATURE (AARCH64_FEATURE_PAC, 0); + AARCH64_FEATURE (PAC); static const aarch64_feature_set aarch64_feature_compnum = - AARCH64_FEATURE (AARCH64_FEATURE_COMPNUM, 0); + AARCH64_FEATURE (COMPNUM); static const aarch64_feature_set aarch64_feature_rcpc = - AARCH64_FEATURE (AARCH64_FEATURE_RCPC, 0); + AARCH64_FEATURE (RCPC); static const aarch64_feature_set aarch64_feature_dotprod = - AARCH64_FEATURE (AARCH64_FEATURE_DOTPROD, 0); + AARCH64_FEATURE (DOTPROD); static const aarch64_feature_set aarch64_feature_sha2 = - AARCH64_FEATURE (AARCH64_FEATURE_V8 | AARCH64_FEATURE_SHA2, 0); + AARCH64_FEATURES (2, V8, SHA2); static const aarch64_feature_set aarch64_feature_aes = - AARCH64_FEATURE (AARCH64_FEATURE_V8 | AARCH64_FEATURE_AES, 0); + AARCH64_FEATURES (2, V8, AES); static const aarch64_feature_set aarch64_feature_v8_4a = - AARCH64_FEATURE (AARCH64_FEATURE_V8_4A, 0); + AARCH64_FEATURE (V8_4A); static const aarch64_feature_set aarch64_feature_sm4 = - AARCH64_FEATURE (AARCH64_FEATURE_SM4 | AARCH64_FEATURE_SIMD - | AARCH64_FEATURE_FP, 0); + AARCH64_FEATURES (3, SM4, SIMD, FP); static const aarch64_feature_set aarch64_feature_sha3 = - AARCH64_FEATURE (AARCH64_FEATURE_SHA2 | AARCH64_FEATURE_SHA3 - | AARCH64_FEATURE_SIMD | AARCH64_FEATURE_FP, 0); + AARCH64_FEATURES (4, SHA2, SHA3, SIMD, FP); static const aarch64_feature_set aarch64_feature_fp_16_v8_2a = - AARCH64_FEATURE (AARCH64_FEATURE_F16_FML | AARCH64_FEATURE_F16 - | AARCH64_FEATURE_FP, 0); + AARCH64_FEATURES (3, F16_FML, F16, FP); static const aarch64_feature_set aarch64_feature_v8_5a = - AARCH64_FEATURE (AARCH64_FEATURE_V8_5A, 0); + AARCH64_FEATURE (V8_5A); static const aarch64_feature_set aarch64_feature_flagmanip = - AARCH64_FEATURE (AARCH64_FEATURE_FLAGMANIP, 0); + AARCH64_FEATURE (FLAGMANIP); static const aarch64_feature_set aarch64_feature_frintts = - AARCH64_FEATURE (AARCH64_FEATURE_FRINTTS, 0); + AARCH64_FEATURE (FRINTTS); static const aarch64_feature_set aarch64_feature_sb = - AARCH64_FEATURE (AARCH64_FEATURE_SB, 0); + AARCH64_FEATURE (SB); static const aarch64_feature_set aarch64_feature_predres = - AARCH64_FEATURE (AARCH64_FEATURE_PREDRES, 0); + AARCH64_FEATURE (PREDRES); static const aarch64_feature_set aarch64_feature_memtag = - AARCH64_FEATURE (AARCH64_FEATURE_MEMTAG, 0); + AARCH64_FEATURE (MEMTAG); static const aarch64_feature_set aarch64_feature_bfloat16 = - AARCH64_FEATURE (AARCH64_FEATURE_BFLOAT16, 0); + AARCH64_FEATURE (BFLOAT16); static const aarch64_feature_set aarch64_feature_bfloat16_sve = - AARCH64_FEATURE (AARCH64_FEATURE_BFLOAT16 | AARCH64_FEATURE_SVE, 0); + AARCH64_FEATURES (2, BFLOAT16, SVE); static const aarch64_feature_set aarch64_feature_tme = - AARCH64_FEATURE (AARCH64_FEATURE_TME, 0); + AARCH64_FEATURE (TME); static const aarch64_feature_set aarch64_feature_sve2 = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2, 0); + AARCH64_FEATURE (SVE2); static const aarch64_feature_set aarch64_feature_sve2aes = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SVE2_AES, 0); + AARCH64_FEATURES (2, SVE2, SVE2_AES); static const aarch64_feature_set aarch64_feature_sve2sha3 = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SVE2_SHA3, 0); + AARCH64_FEATURES (2, SVE2, SVE2_SHA3); static const aarch64_feature_set aarch64_feature_sve2sm4 = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SVE2_SM4, 0); + AARCH64_FEATURES (2, SVE2, SVE2_SM4); static const aarch64_feature_set aarch64_feature_sve2bitperm = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SVE2_BITPERM, 0); + AARCH64_FEATURES (2, SVE2, SVE2_BITPERM); static const aarch64_feature_set aarch64_feature_sme = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SME, 0); + AARCH64_FEATURES (2, SVE2, SME); static const aarch64_feature_set aarch64_feature_sme_f64f64 = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SME - | AARCH64_FEATURE_SME_F64F64, 0); + AARCH64_FEATURES (3, SVE2, SME, SME_F64F64); static const aarch64_feature_set aarch64_feature_sme_i16i64 = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SME - | AARCH64_FEATURE_SME_I16I64, 0); + AARCH64_FEATURES (3, SVE2, SME, SME_I16I64); static const aarch64_feature_set aarch64_feature_sme2 = - AARCH64_FEATURE (AARCH64_FEATURE_SVE2 | AARCH64_FEATURE_SME - | AARCH64_FEATURE_SME2, 0); + AARCH64_FEATURES (3, SVE2, SME, SME2); static const aarch64_feature_set aarch64_feature_sme2_i16i64 = - AARCH64_FEATURE (AARCH64_FEATURE_SME2 | AARCH64_FEATURE_SME_I16I64, 0); + AARCH64_FEATURES (2, SME2, SME_I16I64); static const aarch64_feature_set aarch64_feature_sme2_f64f64 = - AARCH64_FEATURE (AARCH64_FEATURE_SME2 | AARCH64_FEATURE_SME_F64F64, 0); + AARCH64_FEATURES (2, SME2, SME_F64F64); static const aarch64_feature_set aarch64_feature_v8_6a = - AARCH64_FEATURE (AARCH64_FEATURE_V8_6A, 0); + AARCH64_FEATURE (V8_6A); static const aarch64_feature_set aarch64_feature_v8_7a = - AARCH64_FEATURE (AARCH64_FEATURE_V8_7A, 0); + AARCH64_FEATURE (V8_7A); static const aarch64_feature_set aarch64_feature_i8mm = - AARCH64_FEATURE (AARCH64_FEATURE_I8MM, 0); + AARCH64_FEATURE (I8MM); static const aarch64_feature_set aarch64_feature_i8mm_sve = - AARCH64_FEATURE (AARCH64_FEATURE_I8MM | AARCH64_FEATURE_SVE, 0); + AARCH64_FEATURES (2, I8MM, SVE); static const aarch64_feature_set aarch64_feature_f32mm_sve = - AARCH64_FEATURE (AARCH64_FEATURE_F32MM | AARCH64_FEATURE_SVE, 0); + AARCH64_FEATURES (2, F32MM, SVE); static const aarch64_feature_set aarch64_feature_f64mm_sve = - AARCH64_FEATURE (AARCH64_FEATURE_F64MM | AARCH64_FEATURE_SVE, 0); + AARCH64_FEATURES (2, F64MM, SVE); static const aarch64_feature_set aarch64_feature_v8r = - AARCH64_FEATURE (AARCH64_FEATURE_V8R, 0); + AARCH64_FEATURE (V8R); static const aarch64_feature_set aarch64_feature_ls64 = - AARCH64_FEATURE (AARCH64_FEATURE_LS64, 0); + AARCH64_FEATURE (LS64); static const aarch64_feature_set aarch64_feature_flagm = - AARCH64_FEATURE (AARCH64_FEATURE_FLAGM, 0); + AARCH64_FEATURE (FLAGM); static const aarch64_feature_set aarch64_feature_mops = - AARCH64_FEATURE (AARCH64_FEATURE_MOPS, 0); + AARCH64_FEATURE (MOPS); static const aarch64_feature_set aarch64_feature_mops_memtag = - AARCH64_FEATURE (AARCH64_FEATURE_MOPS | AARCH64_FEATURE_MEMTAG, 0); + AARCH64_FEATURES (2, MOPS, MEMTAG); static const aarch64_feature_set aarch64_feature_hbc = - AARCH64_FEATURE (AARCH64_FEATURE_HBC, 0); + AARCH64_FEATURE (HBC); static const aarch64_feature_set aarch64_feature_cssc = - AARCH64_FEATURE (AARCH64_FEATURE_CSSC, 0); + AARCH64_FEATURE (CSSC); #define CORE &aarch64_feature_v8 #define FP &aarch64_feature_fp |