[PATCH 20/28] aarch64: Simplify print_find_next_alias_opcode
Alice Carlotti
alice.carlotti@arm.com
Wed Nov 4 18:46:55 GMT 2026
Create a bucket sorted list of all alias opcodes to determine priority
order. Prioritise opcodes that appear earlier in the opcode table, to
match the prioritisation of non-alias opcodes. Generate the cases in
aarch64_find_next_alias_opcode on the fly, using has_alias_list to track
the tail of each opcodes alias list.
This changes some sequences of aarch64_find_next_alias_opcode results,
but aliases at each priority level do not overlap, so there is no change
in disassembler behaviour. It also reorders the case statments more
generally.
These changes avoid the need to build the alias_info structure, and use
a single efficient bucket sort instead of using bubble sort separately
for each aliased opcode.
diff --git a/opcodes/aarch64-dis-2.c b/opcodes/aarch64-dis-2.c
index fcd7eaf799580e16f44953f495b66b3e8dff0662..41c0703f61ac22d18103cdf827c805fb3b14d08f 100644
--- a/opcodes/aarch64-dis-2.c
+++ b/opcodes/aarch64-dis-2.c
@@ -36382,6 +36382,33 @@ aarch64_find_next_alias_opcode (const aarch64_opcode *opcode)
enum aarch64_opcode_idx value;
switch (key)
{
+ case A64_OPID_13000000_sbfm_Rd_Rn_IMMR_IMMS:
+ value = A64_OPID_13001c00_sxtb_Rd_Rn;
+ break;
+ case A64_OPID_13001c00_sxtb_Rd_Rn:
+ value = A64_OPID_13003c00_sxth_Rd_Rn;
+ break;
+ case A64_OPID_13003c00_sxth_Rd_Rn:
+ value = A64_OPID_93407c00_sxtw_Rd_Rn;
+ break;
+ case A64_OPID_53000000_ubfm_Rd_Rn_IMMR_IMMS:
+ value = A64_OPID_53001c00_uxtb_Rd_Rn;
+ break;
+ case A64_OPID_53001c00_uxtb_Rd_Rn:
+ value = A64_OPID_53003c00_uxth_Rd_Rn;
+ break;
+ case A64_OPID_53003c00_uxth_Rd_Rn:
+ value = A64_OPID_53000000_lsr_Rd_Rn_IMM;
+ break;
+ case A64_OPID_93407c00_sxtw_Rd_Rn:
+ value = A64_OPID_13000000_asr_Rd_Rn_IMM;
+ break;
+ case A64_OPID_33000000_bfm_Rd_Rn_IMMR_IMMS:
+ value = A64_OPID_330003e0_bfc_Rd_IMM_WIDTH;
+ break;
+ case A64_OPID_53000000_lsr_Rd_Rn_IMM:
+ value = A64_OPID_53000000_lsl_Rd_Rn_IMM;
+ break;
case A64_OPID_5a000000_sbc_Rd_Rn_Rm:
value = A64_OPID_5a0003e0_ngc_Rd_Rm;
break;
@@ -36412,9 +36439,6 @@ aarch64_find_next_alias_opcode (const aarch64_opcode *opcode)
case A64_OPID_6b000000_subs_Rd_Rn_Rm_SFT:
value = A64_OPID_6b00001f_cmp_Rn_Rm_SFT;
break;
- case A64_OPID_6b00001f_cmp_Rn_Rm_SFT:
- value = A64_OPID_6b0003e0_negs_Rd_Rm_SFT;
- break;
case A64_OPID_0e003c00_umov_Rd_En:
value = A64_OPID_0e003c00_mov_Rd_En;
break;
@@ -36445,63 +36469,21 @@ aarch64_find_next_alias_opcode (const aarch64_opcode *opcode)
case A64_OPID_5e000400_dup_Sd_En:
value = A64_OPID_5e000400_mov_Sd_En;
break;
- case A64_OPID_13000000_sbfm_Rd_Rn_IMMR_IMMS:
- value = A64_OPID_93407c00_sxtw_Rd_Rn;
- break;
- case A64_OPID_93407c00_sxtw_Rd_Rn:
- value = A64_OPID_13003c00_sxth_Rd_Rn;
- break;
- case A64_OPID_13003c00_sxth_Rd_Rn:
- value = A64_OPID_13001c00_sxtb_Rd_Rn;
- break;
- case A64_OPID_13001c00_sxtb_Rd_Rn:
- value = A64_OPID_13000000_asr_Rd_Rn_IMM;
- break;
case A64_OPID_13000000_asr_Rd_Rn_IMM:
value = A64_OPID_13000000_sbfx_Rd_Rn_IMM_WIDTH;
break;
- case A64_OPID_13000000_sbfx_Rd_Rn_IMM_WIDTH:
- value = A64_OPID_13000000_sbfiz_Rd_Rn_IMM_WIDTH;
- break;
- case A64_OPID_33000000_bfm_Rd_Rn_IMMR_IMMS:
- value = A64_OPID_330003e0_bfc_Rd_IMM_WIDTH;
- break;
case A64_OPID_330003e0_bfc_Rd_IMM_WIDTH:
value = A64_OPID_33000000_bfxil_Rd_Rn_IMM_WIDTH;
break;
- case A64_OPID_33000000_bfxil_Rd_Rn_IMM_WIDTH:
- value = A64_OPID_33000000_bfi_Rd_Rn_IMM_WIDTH;
- break;
- case A64_OPID_53000000_ubfm_Rd_Rn_IMMR_IMMS:
- value = A64_OPID_53000000_lsr_Rd_Rn_IMM;
- break;
- case A64_OPID_53000000_lsr_Rd_Rn_IMM:
- value = A64_OPID_53003c00_uxth_Rd_Rn;
- break;
- case A64_OPID_53003c00_uxth_Rd_Rn:
- value = A64_OPID_53001c00_uxtb_Rd_Rn;
- break;
- case A64_OPID_53001c00_uxtb_Rd_Rn:
- value = A64_OPID_53000000_lsl_Rd_Rn_IMM;
- break;
case A64_OPID_53000000_lsl_Rd_Rn_IMM:
value = A64_OPID_53000000_ubfx_Rd_Rn_IMM_WIDTH;
break;
- case A64_OPID_53000000_ubfx_Rd_Rn_IMM_WIDTH:
- value = A64_OPID_53000000_ubfiz_Rd_Rn_IMM_WIDTH;
- break;
case A64_OPID_1a800400_csinc_Rd_Rn_Rm_COND:
value = A64_OPID_1a9f07e0_cset_Rd_COND1;
break;
- case A64_OPID_1a9f07e0_cset_Rd_COND1:
- value = A64_OPID_1a800400_cinc_Rd_Rn_COND1;
- break;
case A64_OPID_5a800000_csinv_Rd_Rn_Rm_COND:
value = A64_OPID_5a9f03e0_csetm_Rd_COND1;
break;
- case A64_OPID_5a9f03e0_csetm_Rd_COND1:
- value = A64_OPID_5a800000_cinv_Rd_Rn_COND1;
- break;
case A64_OPID_5a800400_csneg_Rd_Rn_Rm_COND:
value = A64_OPID_5a800400_cneg_Rd_Rn_COND1;
break;
@@ -36725,244 +36707,223 @@ aarch64_find_next_alias_opcode (const aarch64_opcode *opcode)
value = A64_OPID_52800000_mov_Rd_IMM_MOV;
break;
case A64_OPID_d500401f_msr_PSTATEFIELD_UIMM4:
- value = A64_OPID_d503407f_smstop_SME_SM_ZA;
- break;
- case A64_OPID_d503407f_smstop_SME_SM_ZA:
- value = A64_OPID_d503417f_smstart_SME_SM_ZA;
+ value = A64_OPID_d503477f_smstart;
break;
- case A64_OPID_d503417f_smstart_SME_SM_ZA:
+ case A64_OPID_d503477f_smstart:
value = A64_OPID_d503467f_smstop;
break;
case A64_OPID_d503467f_smstop:
- value = A64_OPID_d503477f_smstart;
- break;
- case A64_OPID_d503201f_hint_UIMM7:
- value = A64_OPID_d50322df_clrbhb;
- break;
- case A64_OPID_d50322df_clrbhb:
- value = A64_OPID_d50323ff_autibsp;
- break;
- case A64_OPID_d50323ff_autibsp:
- value = A64_OPID_d50323df_autibz;
- break;
- case A64_OPID_d50323df_autibz:
- value = A64_OPID_d50323bf_autiasp;
- break;
- case A64_OPID_d50323bf_autiasp:
- value = A64_OPID_d503239f_autiaz;
- break;
- case A64_OPID_d503239f_autiaz:
- value = A64_OPID_d503237f_pacibsp;
- break;
- case A64_OPID_d503237f_pacibsp:
- value = A64_OPID_d503235f_pacibz;
- break;
- case A64_OPID_d503235f_pacibz:
- value = A64_OPID_d503233f_paciasp;
+ value = A64_OPID_d503417f_smstart_SME_SM_ZA;
break;
- case A64_OPID_d503233f_paciasp:
- value = A64_OPID_d503231f_paciaz;
+ case A64_OPID_d503417f_smstart_SME_SM_ZA:
+ value = A64_OPID_d503407f_smstop_SME_SM_ZA;
break;
- case A64_OPID_d503231f_paciaz:
- value = A64_OPID_d503227f_gcsb_BARRIER_GCSB;
+ case A64_OPID_d503201f_hint_UIMM7:
+ value = A64_OPID_d503251f_chkfeat_X16;
break;
- case A64_OPID_d503227f_gcsb_BARRIER_GCSB:
- value = A64_OPID_d503225f_tsb_BARRIER_PSB;
+ case A64_OPID_d503251f_chkfeat_X16:
+ value = A64_OPID_d503261f_stshh_STSHH_POLICY;
break;
- case A64_OPID_d503225f_tsb_BARRIER_PSB:
- value = A64_OPID_d503223f_psb_BARRIER_PSB;
+ case A64_OPID_d503261f_stshh_STSHH_POLICY:
+ value = A64_OPID_d503269f_stcph;
break;
- case A64_OPID_d503223f_psb_BARRIER_PSB:
- value = A64_OPID_d503221f_esb;
+ case A64_OPID_d503269f_stcph:
+ value = A64_OPID_d503265f_shuh_SHUH_PHINT;
break;
- case A64_OPID_d503221f_esb:
- value = A64_OPID_d50324ff_pacm;
+ case A64_OPID_d503265f_shuh_SHUH_PHINT:
+ value = A64_OPID_d503201f_nop;
break;
- case A64_OPID_d50324ff_pacm:
- value = A64_OPID_d50321df_autib1716;
+ case A64_OPID_d503201f_nop:
+ value = A64_OPID_d503229f_csdb;
break;
- case A64_OPID_d50321df_autib1716:
- value = A64_OPID_d503219f_autia1716;
+ case A64_OPID_d503229f_csdb:
+ value = A64_OPID_d503241f_bti_BTI_TARGET;
break;
- case A64_OPID_d503219f_autia1716:
- value = A64_OPID_d503215f_pacib1716;
+ case A64_OPID_d503241f_bti_BTI_TARGET:
+ value = A64_OPID_d503203f_yield;
break;
- case A64_OPID_d503215f_pacib1716:
- value = A64_OPID_d503211f_pacia1716;
+ case A64_OPID_d503203f_yield:
+ value = A64_OPID_d503205f_wfe;
break;
- case A64_OPID_d503211f_pacia1716:
- value = A64_OPID_d50320ff_xpaclri;
+ case A64_OPID_d503205f_wfe:
+ value = A64_OPID_d503207f_wfi;
break;
- case A64_OPID_d50320ff_xpaclri:
- value = A64_OPID_d50320df_dgh;
+ case A64_OPID_d503207f_wfi:
+ value = A64_OPID_d503209f_sev;
break;
- case A64_OPID_d50320df_dgh:
+ case A64_OPID_d503209f_sev:
value = A64_OPID_d50320bf_sevl;
break;
case A64_OPID_d50320bf_sevl:
- value = A64_OPID_d503209f_sev;
- break;
- case A64_OPID_d503209f_sev:
- value = A64_OPID_d503207f_wfi;
+ value = A64_OPID_d50320df_dgh;
break;
- case A64_OPID_d503207f_wfi:
- value = A64_OPID_d503205f_wfe;
+ case A64_OPID_d50320df_dgh:
+ value = A64_OPID_d50320ff_xpaclri;
break;
- case A64_OPID_d503205f_wfe:
- value = A64_OPID_d503203f_yield;
+ case A64_OPID_d50320ff_xpaclri:
+ value = A64_OPID_d503211f_pacia1716;
break;
- case A64_OPID_d503203f_yield:
- value = A64_OPID_d503241f_bti_BTI_TARGET;
+ case A64_OPID_d503211f_pacia1716:
+ value = A64_OPID_d503215f_pacib1716;
break;
- case A64_OPID_d503241f_bti_BTI_TARGET:
- value = A64_OPID_d503229f_csdb;
+ case A64_OPID_d503215f_pacib1716:
+ value = A64_OPID_d503219f_autia1716;
break;
- case A64_OPID_d503229f_csdb:
- value = A64_OPID_d503201f_nop;
+ case A64_OPID_d503219f_autia1716:
+ value = A64_OPID_d50321df_autib1716;
break;
- case A64_OPID_d503201f_nop:
- value = A64_OPID_d503265f_shuh_SHUH_PHINT;
+ case A64_OPID_d50321df_autib1716:
+ value = A64_OPID_d50324ff_pacm;
break;
- case A64_OPID_d503265f_shuh_SHUH_PHINT:
- value = A64_OPID_d503269f_stcph;
+ case A64_OPID_d50324ff_pacm:
+ value = A64_OPID_d503221f_esb;
break;
- case A64_OPID_d503269f_stcph:
- value = A64_OPID_d503261f_stshh_STSHH_POLICY;
+ case A64_OPID_d503221f_esb:
+ value = A64_OPID_d503223f_psb_BARRIER_PSB;
break;
- case A64_OPID_d503261f_stshh_STSHH_POLICY:
- value = A64_OPID_d503251f_chkfeat_X16;
+ case A64_OPID_d503223f_psb_BARRIER_PSB:
+ value = A64_OPID_d503225f_tsb_BARRIER_PSB;
break;
case A64_OPID_d503309f_dsb_BARRIER:
- value = A64_OPID_d503349f_pssbb;
+ value = A64_OPID_d5033c9f_dfb;
break;
- case A64_OPID_d503349f_pssbb:
+ case A64_OPID_d5033c9f_dfb:
value = A64_OPID_d503309f_ssbb;
break;
case A64_OPID_d503309f_ssbb:
- value = A64_OPID_d5033c9f_dfb;
+ value = A64_OPID_d503349f_pssbb;
break;
case A64_OPID_d5080000_sys_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt:
- value = A64_OPID_d5080000_plbi_SYSREG_PLBI_Rt_SYS;
- break;
- case A64_OPID_d5080000_plbi_SYSREG_PLBI_Rt_SYS:
- value = A64_OPID_d508001f_gsb_GSB;
+ value = A64_OPID_d508779f_gcspushx;
break;
- case A64_OPID_d508001f_gsb_GSB:
- value = A64_OPID_d5080000_gicr_Rd_GICR;
+ case A64_OPID_d508779f_gcspushx:
+ value = A64_OPID_d50877df_gcspopx;
break;
- case A64_OPID_d5080000_gicr_Rd_GICR:
- value = A64_OPID_d5080000_gic_GIC_Rd;
+ case A64_OPID_d50877df_gcspopx:
+ value = A64_OPID_d50877bf_gcspopcx;
break;
- case A64_OPID_d5080000_gic_GIC_Rd:
- value = A64_OPID_d50b72e0_trcit_Rt;
+ case A64_OPID_d50877bf_gcspopcx:
+ value = A64_OPID_d50b7740_gcsss1_Rt;
break;
- case A64_OPID_d50b72e0_trcit_Rt:
- value = A64_OPID_d5097280_brb_BRBOP_Rt_IN_SYS_ALIASES;
+ case A64_OPID_d50b7740_gcsss1_Rt:
+ value = A64_OPID_d50b7700_gcspushm_Rt;
break;
- case A64_OPID_d5097280_brb_BRBOP_Rt_IN_SYS_ALIASES:
- value = A64_OPID_d50b73c0_cosp_SYSREG_SR_Rt;
+ case A64_OPID_d5280000_sysl_Rt_UIMM3_OP1_CRn_CRm_UIMM3_OP2:
+ value = A64_OPID_d52b7760_gcsss2_Rt;
break;
- case A64_OPID_d50b73c0_cosp_SYSREG_SR_Rt:
- value = A64_OPID_d50b73e0_cpp_SYSREG_SR_Rt;
+ case A64_OPID_d52b7760_gcsss2_Rt:
+ value = A64_OPID_d52b7720_gcspopm_Rt;
break;
- case A64_OPID_d50b73e0_cpp_SYSREG_SR_Rt:
- value = A64_OPID_d50b73a0_dvp_SYSREG_SR_Rt;
+ case A64_OPID_d503225f_tsb_BARRIER_PSB:
+ value = A64_OPID_d503227f_gcsb_BARRIER_GCSB;
break;
- case A64_OPID_d50b73a0_dvp_SYSREG_SR_Rt:
- value = A64_OPID_d50b7380_cfp_SYSREG_SR_Rt;
+ case A64_OPID_d50b7700_gcspushm_Rt:
+ value = A64_OPID_d5080000_at_SYSREG_AT_Rt;
break;
- case A64_OPID_d50b7380_cfp_SYSREG_SR_Rt:
- value = A64_OPID_d5080000_tlbi_SYSREG_TLBI_Rt_SYS;
+ case A64_OPID_d5080000_at_SYSREG_AT_Rt:
+ value = A64_OPID_d5080000_dc_SYSREG_DC_Rt;
break;
- case A64_OPID_d5080000_tlbi_SYSREG_TLBI_Rt_SYS:
+ case A64_OPID_d5080000_dc_SYSREG_DC_Rt:
value = A64_OPID_d5080000_ic_SYSREG_IC_Rt_SYS;
break;
case A64_OPID_d5080000_ic_SYSREG_IC_Rt_SYS:
- value = A64_OPID_d5080000_dc_SYSREG_DC_Rt;
+ value = A64_OPID_d5080000_tlbi_SYSREG_TLBI_Rt_SYS;
break;
- case A64_OPID_d5080000_dc_SYSREG_DC_Rt:
- value = A64_OPID_d5080000_at_SYSREG_AT_Rt;
+ case A64_OPID_d5480000_sysp_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt_PAIRREG_OR_XZR:
+ value = A64_OPID_d5480000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR;
break;
- case A64_OPID_d5080000_at_SYSREG_AT_Rt:
- value = A64_OPID_d50b7700_gcspushm_Rt;
+ case A64_OPID_d5080000_tlbi_SYSREG_TLBI_Rt_SYS:
+ value = A64_OPID_d50b7380_cfp_SYSREG_SR_Rt;
break;
- case A64_OPID_d50b7700_gcspushm_Rt:
- value = A64_OPID_d50b7740_gcsss1_Rt;
+ case A64_OPID_d50b7380_cfp_SYSREG_SR_Rt:
+ value = A64_OPID_d50b73a0_dvp_SYSREG_SR_Rt;
break;
- case A64_OPID_d50b7740_gcsss1_Rt:
- value = A64_OPID_d50877bf_gcspopcx;
+ case A64_OPID_d50b73a0_dvp_SYSREG_SR_Rt:
+ value = A64_OPID_d50b73e0_cpp_SYSREG_SR_Rt;
break;
- case A64_OPID_d50877bf_gcspopcx:
- value = A64_OPID_d50877df_gcspopx;
+ case A64_OPID_d50b73e0_cpp_SYSREG_SR_Rt:
+ value = A64_OPID_d50b73c0_cosp_SYSREG_SR_Rt;
break;
- case A64_OPID_d50877df_gcspopx:
- value = A64_OPID_d508779f_gcspushx;
+ case A64_OPID_d50b73c0_cosp_SYSREG_SR_Rt:
+ value = A64_OPID_d5097280_brb_BRBOP_Rt_IN_SYS_ALIASES;
break;
- case A64_OPID_d5480000_sysp_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt_PAIRREG_OR_XZR:
- value = A64_OPID_d5480000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR;
+ case A64_OPID_d503227f_gcsb_BARRIER_GCSB:
+ value = A64_OPID_d503231f_paciaz;
break;
- case A64_OPID_d5280000_sysl_Rt_UIMM3_OP1_CRn_CRm_UIMM3_OP2:
- value = A64_OPID_d52b7720_gcspopm_Rt;
+ case A64_OPID_d503231f_paciaz:
+ value = A64_OPID_d503233f_paciasp;
break;
- case A64_OPID_d52b7720_gcspopm_Rt:
- value = A64_OPID_d52b7760_gcsss2_Rt;
+ case A64_OPID_d503233f_paciasp:
+ value = A64_OPID_d503235f_pacibz;
break;
- case A64_OPID_25004000_and_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
- value = A64_OPID_25004000_mov_SVE_Pd_SVE_Pg4_10_SVE_Pn;
+ case A64_OPID_d503235f_pacibz:
+ value = A64_OPID_d503237f_pacibsp;
break;
- case A64_OPID_25404000_ands_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
- value = A64_OPID_25404000_movs_SVE_Pd_SVE_Pg4_10_SVE_Pn;
+ case A64_OPID_d503237f_pacibsp:
+ value = A64_OPID_d503239f_autiaz;
break;
- case A64_OPID_05208000_cpy_SVE_Zd_SVE_Pg3_SVE_Vn:
- value = A64_OPID_05208000_mov_SVE_Zd_SVE_Pg3_SVE_Vn;
+ case A64_OPID_d503239f_autiaz:
+ value = A64_OPID_d50323bf_autiasp;
break;
- case A64_OPID_0528a000_cpy_SVE_Zd_SVE_Pg3_Rn_SP:
- value = A64_OPID_0528a000_mov_SVE_Zd_SVE_Pg3_Rn_SP;
+ case A64_OPID_d50323bf_autiasp:
+ value = A64_OPID_d50323df_autibz;
break;
- case A64_OPID_05100000_cpy_SVE_Zd_SVE_Pg4_16_SVE_ASIMM:
- value = A64_OPID_05100000_mov_SVE_Zd_SVE_Pg4_16_SVE_ASIMM;
+ case A64_OPID_d50323df_autibz:
+ value = A64_OPID_d50323ff_autibsp;
break;
- case A64_OPID_05203800_dup_SVE_Zd_Rn_SP:
- value = A64_OPID_05203800_mov_SVE_Zd_Rn_SP;
+ case A64_OPID_2539c000_fdup_SVE_Zd_SVE_FPIMM8:
+ value = A64_OPID_2539c000_fmov_SVE_Zd_SVE_FPIMM8;
+ break;
+ case A64_OPID_0510c000_fcpy_SVE_Zd_SVE_Pg4_16_SVE_FPIMM8:
+ value = A64_OPID_0510c000_fmov_SVE_Zd_SVE_Pg4_16_SVE_FPIMM8;
+ break;
+ case A64_OPID_04603000_orr_SVE_Zd_SVE_Zn_SVE_Zm_16:
+ value = A64_OPID_04603000_mov_SVE_Zd_SVE_Zn;
break;
case A64_OPID_05202000_dup_SVE_Zd_SVE_Zn_INDEX:
value = A64_OPID_05202000_mov_SVE_Zd_SVE_VZn;
break;
- case A64_OPID_05202000_mov_SVE_Zd_SVE_VZn:
- value = A64_OPID_05202000_mov_SVE_Zd_SVE_Zn_INDEX;
+ case A64_OPID_05203800_dup_SVE_Zd_Rn_SP:
+ value = A64_OPID_05203800_mov_SVE_Zd_Rn_SP;
break;
- case A64_OPID_2538c000_dup_SVE_Zd_SVE_ASIMM:
- value = A64_OPID_2538c000_mov_SVE_Zd_SVE_ASIMM;
+ case A64_OPID_25804000_orr_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
+ value = A64_OPID_25804000_mov_SVE_Pd_SVE_Pn;
break;
case A64_OPID_05c00000_dupm_SVE_Zd_SVE_LIMM:
value = A64_OPID_05c00000_mov_SVE_Zd_SVE_LIMM_MOV;
break;
- case A64_OPID_25004200_eor_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
- value = A64_OPID_25004200_not_SVE_Pd_SVE_Pg4_10_SVE_Pn;
+ case A64_OPID_2538c000_dup_SVE_Zd_SVE_ASIMM:
+ value = A64_OPID_2538c000_mov_SVE_Zd_SVE_ASIMM;
break;
- case A64_OPID_25404200_eors_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
- value = A64_OPID_25404200_nots_SVE_Pd_SVE_Pg4_10_SVE_Pn;
+ case A64_OPID_05208000_cpy_SVE_Zd_SVE_Pg3_SVE_Vn:
+ value = A64_OPID_05208000_mov_SVE_Zd_SVE_Pg3_SVE_Vn;
break;
- case A64_OPID_0510c000_fcpy_SVE_Zd_SVE_Pg4_16_SVE_FPIMM8:
- value = A64_OPID_0510c000_fmov_SVE_Zd_SVE_Pg4_16_SVE_FPIMM8;
+ case A64_OPID_0520c000_sel_SVE_Zd_SVE_Pg4_10_SVE_Zn_SVE_Zm_16:
+ value = A64_OPID_0520c000_mov_SVE_Zd_SVE_Pg4_10_SVE_Zn;
break;
- case A64_OPID_2539c000_fdup_SVE_Zd_SVE_FPIMM8:
- value = A64_OPID_2539c000_fmov_SVE_Zd_SVE_FPIMM8;
+ case A64_OPID_0528a000_cpy_SVE_Zd_SVE_Pg3_Rn_SP:
+ value = A64_OPID_0528a000_mov_SVE_Zd_SVE_Pg3_Rn_SP;
break;
- case A64_OPID_04603000_orr_SVE_Zd_SVE_Zn_SVE_Zm_16:
- value = A64_OPID_04603000_mov_SVE_Zd_SVE_Zn;
+ case A64_OPID_25004000_and_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
+ value = A64_OPID_25004000_mov_SVE_Pd_SVE_Pg4_10_SVE_Pn;
break;
- case A64_OPID_25804000_orr_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
- value = A64_OPID_25804000_mov_SVE_Pd_SVE_Pn;
+ case A64_OPID_25004210_sel_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
+ value = A64_OPID_25004210_mov_SVE_Pd_SVE_Pg4_10_SVE_Pn;
+ break;
+ case A64_OPID_05100000_cpy_SVE_Zd_SVE_Pg4_16_SVE_ASIMM:
+ value = A64_OPID_05100000_mov_SVE_Zd_SVE_Pg4_16_SVE_ASIMM;
break;
case A64_OPID_25c04000_orrs_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
value = A64_OPID_25c04000_movs_SVE_Pd_SVE_Pn;
break;
- case A64_OPID_0520c000_sel_SVE_Zd_SVE_Pg4_10_SVE_Zn_SVE_Zm_16:
- value = A64_OPID_0520c000_mov_SVE_Zd_SVE_Pg4_10_SVE_Zn;
+ case A64_OPID_25404000_ands_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
+ value = A64_OPID_25404000_movs_SVE_Pd_SVE_Pg4_10_SVE_Pn;
break;
- case A64_OPID_25004210_sel_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
- value = A64_OPID_25004210_mov_SVE_Pd_SVE_Pg4_10_SVE_Pn;
+ case A64_OPID_25004200_eor_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
+ value = A64_OPID_25004200_not_SVE_Pd_SVE_Pg4_10_SVE_Pn;
+ break;
+ case A64_OPID_25404200_eors_SVE_Pd_SVE_Pg4_10_SVE_Pn_SVE_Pm:
+ value = A64_OPID_25404200_nots_SVE_Pd_SVE_Pg4_10_SVE_Pn;
break;
case A64_OPID_c0020000_mova_SVE_Zd_SVE_Pg3_SME_ZA_HV_idx_src:
value = A64_OPID_c0020000_mov_SVE_Zd_SVE_Pg3_SME_ZA_HV_idx_src;
@@ -36994,6 +36955,45 @@ aarch64_find_next_alias_opcode (const aarch64_opcode *opcode)
case A64_OPID_c0040400_mova_SME_ZA_HV_idx_destxN_SME_Znx4:
value = A64_OPID_c0040400_mov_SME_ZA_HV_idx_destxN_SME_Znx4;
break;
+ case A64_OPID_d50323ff_autibsp:
+ value = A64_OPID_d50322df_clrbhb;
+ break;
+ case A64_OPID_d5097280_brb_BRBOP_Rt_IN_SYS_ALIASES:
+ value = A64_OPID_d50b72e0_trcit_Rt;
+ break;
+ case A64_OPID_d50b72e0_trcit_Rt:
+ value = A64_OPID_d5080000_gic_GIC_Rd;
+ break;
+ case A64_OPID_d5080000_gic_GIC_Rd:
+ value = A64_OPID_d5080000_gicr_Rd_GICR;
+ break;
+ case A64_OPID_d5080000_gicr_Rd_GICR:
+ value = A64_OPID_d508001f_gsb_GSB;
+ break;
+ case A64_OPID_d508001f_gsb_GSB:
+ value = A64_OPID_d5080000_plbi_SYSREG_PLBI_Rt_SYS;
+ break;
+ case A64_OPID_6b00001f_cmp_Rn_Rm_SFT:
+ value = A64_OPID_6b0003e0_negs_Rd_Rm_SFT;
+ break;
+ case A64_OPID_13000000_sbfx_Rd_Rn_IMM_WIDTH:
+ value = A64_OPID_13000000_sbfiz_Rd_Rn_IMM_WIDTH;
+ break;
+ case A64_OPID_33000000_bfxil_Rd_Rn_IMM_WIDTH:
+ value = A64_OPID_33000000_bfi_Rd_Rn_IMM_WIDTH;
+ break;
+ case A64_OPID_53000000_ubfx_Rd_Rn_IMM_WIDTH:
+ value = A64_OPID_53000000_ubfiz_Rd_Rn_IMM_WIDTH;
+ break;
+ case A64_OPID_1a9f07e0_cset_Rd_COND1:
+ value = A64_OPID_1a800400_cinc_Rd_Rn_COND1;
+ break;
+ case A64_OPID_5a9f03e0_csetm_Rd_COND1:
+ value = A64_OPID_5a800000_cinv_Rd_Rn_COND1;
+ break;
+ case A64_OPID_05202000_mov_SVE_Zd_SVE_VZn:
+ value = A64_OPID_05202000_mov_SVE_Zd_SVE_Zn_INDEX;
+ break;
default: return NULL;
}
diff --git a/opcodes/aarch64-gen.c b/opcodes/aarch64-gen.c
index 50f241478d5aecd0c2e54b36ac2f2dd6bc5349eb..55788c50e89a5289b50f0461f288f6c537ced367 100644
--- a/opcodes/aarch64-gen.c
+++ b/opcodes/aarch64-gen.c
@@ -277,30 +277,48 @@ validate_table (opcode_node *has_alias_list)
}
}
-/* Create a linked list of opcode table entries. */
-static opcode_node*
-read_table (void)
+/* Create linked lists of opcode table entries sorted by priority then by
+ opcode table order. We build up several linked lists for each relevant set
+ of alias and priority flags, then splice the lists together at the end.
+ *TREE_OPCODES points to the list of opcode_nodes used in the decode tree.
+ *ALIAS_OPCODES contains opcodes used in aarch64_find_next_alias_opcode. */
+static void
+read_table (opcode_node **tree_opcodes, opcode_node **alias_opcodes)
{
- opcode_node *head;
- opcode_node **tail = &head;
+ /* Linked lists for non-alias, P0 alias, P1 alias, P2 alias, P3 alias. */
+ opcode_node *heads[5] = {};
+ opcode_node **tails[5];
+ for (int i = 0; i < 5; i++)
+ tails[i] = &heads[i];
+
for (unsigned int index = 0; ; index++)
{
const struct aarch64_opcode *ent = &aarch64_opcode_table[index];
if (!ent->name)
break;
- /* Skip alias (inc. pseudo) opcode. */
+ /* Pseudo instructions are never used in disassembly. */
+ if (pseudo_opcode_p (ent))
+ continue;
+
+ unsigned int part = 0;
if (alias_opcode_p (ent))
- continue;
+ part = 1 + opcode_priority (ent);
opcode_node *node = new_opcode_node ();
node->opcode = ent->opcode;
node->mask = ent->mask;
node->index = index;
- *tail = node;
- tail = &node->next;
+ *tails[part] = node;
+ tails[part] = &node->next;
}
- return head;
+
+ *tails[2] = heads[1]; /* Append P0 to P1. */
+ *tails[3] = heads[2]; /* Append P1P0 to P2. */
+ *tails[4] = heads[3]; /* Append P2P1P0 to P3. */
+
+ *tree_opcodes = heads[0];
+ *alias_opcodes = heads[4];
}
static inline void
@@ -722,14 +740,15 @@ print_find_real_opcode (opcode_node *has_alias_list)
}
/* Generate aarch64_find_next_alias_opcode in C code to the standard output.
- TABLE points to the alias info table, while NUM indicates the number of
- entries in the table. */
+ HAS_ALIAS_LIST points to the list of aliased opcodes, while alias_opcodes
+ points to the list of alias opcodes sorted by priority. We compute the
+ alias/aliased pairings on the fly, and print each corresponding
+ case statement immediately. */
static void
-print_find_next_alias_opcode (const opcode_node *table, int num)
+print_find_next_alias_opcode (opcode_node *has_alias_list,
+ opcode_node *alias_opcodes)
{
- int i;
-
if (debug)
printf ("Enter print_find_next_alias_opcode\n");
@@ -743,16 +762,16 @@ print_find_next_alias_opcode (const opcode_node *table, int num)
printf (" switch (key)\n");
printf (" {\n");
- for (i = 0; i < num; ++i)
+ for (opcode_node *alias = alias_opcodes; alias; alias = alias->next)
{
- const opcode_node *node = table + i;
- while (node->next)
- {
- printf (" case %s:\n value = %s;\n break;\n",
- opcode_node_labels[node->index],
- opcode_node_labels[node->next->index]);
- node = node->next;
- }
+ opcode_node *aliased = get_aliased_opcode (alias->opcode, alias->mask,
+ has_alias_list);
+ printf (" case %s:\n value = %s;\n break;\n",
+ opcode_node_labels[aliased->index],
+ opcode_node_labels[alias->index]);
+
+ /* Use aliased->index to store the last alias index in the chain. */
+ aliased->index = alias->index;
}
printf (" default: return NULL;\n");
@@ -762,176 +781,6 @@ print_find_next_alias_opcode (const opcode_node *table, int num)
printf ("}\n");
}
-/* Given OPCODE, establish and return a link list of alias nodes in the
- preferred order. */
-
-opcode_node *
-find_alias_opcode (const aarch64_opcode *opcode)
-{
- int i;
- /* Assume maximum of 64 disassemble preference candidates. */
- const int max_num_aliases = 64;
- const aarch64_opcode *ent;
- const aarch64_opcode *preferred[max_num_aliases + 1];
- opcode_node head, **next;
-
- assert (opcode_has_alias (opcode));
-
- i = 0;
- ent = aarch64_opcode_table;
- while (ent->name != NULL)
- {
- /* The mask of an alias opcode must be equal to or a super-set (i.e.
- more constrained) of that of the aliased opcode; so is the base
- opcode value. */
- if (alias_opcode_p (ent)
- && (ent->mask & opcode->mask) == opcode->mask
- && (opcode->mask & ent->opcode) == (opcode->mask & opcode->opcode))
- {
- assert (i < max_num_aliases);
- preferred[i++] = ent;
- if (debug)
- printf ("found %s for %s.", ent->name, opcode->name);
- }
- ++ent;
- }
-
- if (debug)
- {
- int m;
- printf ("un-orderd list: ");
- for (m = 0; m < i; ++m)
- printf ("%s, ", preferred[m]->name);
- printf ("\n");
- }
-
- /* There must be at least one alias. */
- assert (i >= 1);
-
- /* Sort preferred array according to the priority (from the lowest to the
- highest. */
- if (i > 1)
- {
- int j, k;
- for (j = 0; j < i - 1; ++j)
- {
- for (k = 0; k < i - 1 - j; ++k)
- {
- const aarch64_opcode *t;
- t = preferred [k+1];
- if (opcode_priority (t) < opcode_priority (preferred [k]))
- {
- preferred [k+1] = preferred [k];
- preferred [k] = t;
- }
- }
- }
- }
-
- if (debug)
- {
- int m;
- printf ("orderd list: ");
- for (m = 0; m < i; ++m)
- printf ("%s, ", preferred[m]->name);
- printf ("\n");
- }
-
- /* Create a link-list of opcode_node with disassemble preference from
- higher to lower. */
- next = &head.next;
- --i;
- while (i >= 0)
- {
- const aarch64_opcode *alias = preferred [i];
- if (pseudo_opcode_p (alias))
- {
- --i;
- continue;
- }
- opcode_node *node = new_opcode_node ();
-
- if (debug)
- printf ("add %s.\n", alias->name);
-
- node->index = alias - aarch64_opcode_table;
- *next = node;
- next = &node->next;
-
- --i;
- }
- *next = NULL;
-
- return head.next;
-}
-
-/* Create and return alias information.
- Return the address of the created alias info table; return the number
- of table entries in *NUM_PTR. */
-
-opcode_node *
-create_alias_info (int *num_ptr)
-{
- int i, num;
- opcode_node *ret;
- const aarch64_opcode *ent;
-
- /* Calculate the total number of opcodes that have alias. */
- num = 0;
- ent = aarch64_opcode_table;
- while (ent->name != NULL)
- {
- if (opcode_has_alias (ent))
- ++num;
- ++ent;
- }
- assert (num_ptr);
- *num_ptr = num;
-
- /* The array of real opcodes that have alias(es). */
- ret = malloc (sizeof (opcode_node) * num);
-
- /* For each opcode, establish a list of alias nodes in a preferred
- order. */
- for (i = 0, ent = aarch64_opcode_table; i < num; ++i, ++ent)
- {
- opcode_node *node = ret + i;
- while (ent->name != NULL && !opcode_has_alias (ent))
- ++ent;
- assert (ent->name != NULL);
- node->index = ent - aarch64_opcode_table;
- node->next = find_alias_opcode (ent);
- }
- assert (i == num);
-
- return ret;
-}
-
-/* Release the dynamic memory resource allocated for the generation of the
- alias information. */
-
-void
-release_resource_alias_info (opcode_node *alias_info, int num)
-{
- int i = 0;
- opcode_node *node = alias_info;
-
- /* Free opcode_node list. */
- for (; i < num; ++i, ++node)
- {
- opcode_node *list = node->next;
- while (list != NULL)
- {
- opcode_node *next = list->next;
- free (list);
- list = next;
- }
- }
-
- /* Free opcode_node array. */
- free (alias_info);
-}
-
/* As a debugging utility, print out the result of the table division, although
it is not doing much this moment. */
static void
@@ -1471,27 +1320,26 @@ main (int argc, char **argv)
if (gen_disassembler_p)
{
- opcode_node *head = read_table ();
+ opcode_node *tree_opcodes;
+ opcode_node *alias_opcodes;
+ read_table (&tree_opcodes, &alias_opcodes);
if (debug)
- print_opcode_nodes (head);
- struct bittree *decoder_tree = divide_table (head);
+ {
+ print_opcode_nodes (tree_opcodes);
+ print_opcode_nodes (alias_opcodes);
+ }
+ struct bittree *decoder_tree = divide_table (tree_opcodes);
if (debug)
print_divide_result (decoder_tree);
print_decision_tree (decoder_tree);
print_find_next_opcode (decoder_tree);
release_resource_decoder_tree (decoder_tree);
- }
-
- /* Generate alias opcode handling for the assembler or the disassembler. */
- if (gen_disassembler_p)
- {
- int num;
- opcode_node *alias_info = create_alias_info (&num);
-
- print_find_next_alias_opcode (alias_info, num);
- release_resource_alias_info (alias_info, num);
+ /* print_find_next_alias_opcode modifies the indices in has_alias_list
+ destructively, but we don't need them afterwards. */
+ print_find_next_alias_opcode (has_alias_list, alias_opcodes);
+ free_opcode_list (alias_opcodes);
}
if (gen_assembler_p)
More information about the Binutils
mailing list