[PATCH 28/28] aarch64: Narrow the opcode masks for SYS/SYSP/SYSL aliases
Alice Carlotti
alice.carlotti@arm.com
Wed Nov 4 18:49:13 GMT 2026
This does not affect assembly/disassembly because the bits are also checked
as part of an operand, but it allows the decode tree to eliminate a few
more opcode entries directly. Note that DC has an irregularly-shaped
encoding space, so we still end up with a chain of 11 opcodes in the
decode tree.
diff --git a/opcodes/aarch64-dis-2.c b/opcodes/aarch64-dis-2.c
index adb563b4f980cc352b26911c804e35d5ec698e25..5a5adf3e54d9de0b9e29d8ccbc1e74284a933d81 100644
--- a/opcodes/aarch64-dis-2.c
+++ b/opcodes/aarch64-dis-2.c
@@ -27613,50 +27613,90 @@ aarch64_opcode_lookup_1 (uint32_t word)
}
else
{
- if (((word >> 5) & 0x1) == 0)
+ if (((word >> 13) & 0x1) == 0)
{
- if (((word >> 6) & 0x1) == 0)
+ if (((word >> 14) & 0x1) == 0)
{
- if (((word >> 7) & 0x1) == 0)
- {
- /* 33222222222211111111110000000000
- 10987654321098765432109876543210
- 11010101000x1xxxxxxxxxxx000xxxxx. */
- return A64_OPID_d50b7700_gcspushm_Rt;
- }
- else
- {
- /* 33222222222211111111110000000000
- 10987654321098765432109876543210
- 11010101000x1xxxxxxxxxxx100xxxxx. */
- return A64_OPID_d508779f_gcspushx;
- }
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxx00xxxxxxxxxxxxx. */
+ return A64_OPID_d5088000_tlbi_SYSREG_TLBI_Rt_SYS;
+ }
+ else
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxx10xxxxxxxxxxxxx. */
+ return A64_OPID_d508c000_gic_GIC_Rd;
+ }
+ }
+ else
+ {
+ if (((word >> 12) & 0x1) == 0)
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxxx10xxxxxxxxxxxx. */
+ return A64_OPID_d508a000_plbi_SYSREG_PLBI_Rt_SYS;
}
else
{
- if (((word >> 7) & 0x1) == 0)
+ if (((word >> 9) & 0x1) == 0)
{
/* 33222222222211111111110000000000
10987654321098765432109876543210
- 11010101000x1xxxxxxxxxxx010xxxxx. */
- return A64_OPID_d50b7740_gcsss1_Rt;
+ 11010101000x1xxxxx11xx0xxxxxxxxx. */
+ return A64_OPID_d5087800_at_SYSREG_AT_Rt;
}
else
{
- /* 33222222222211111111110000000000
- 10987654321098765432109876543210
- 11010101000x1xxxxxxxxxxx110xxxxx. */
- return A64_OPID_d50877df_gcspopx;
+ if (((word >> 5) & 0x1) == 0)
+ {
+ if (((word >> 6) & 0x1) == 0)
+ {
+ if (((word >> 7) & 0x1) == 0)
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxxx11xx1x000xxxxx. */
+ return A64_OPID_d50b7700_gcspushm_Rt;
+ }
+ else
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxxx11xx1x100xxxxx. */
+ return A64_OPID_d508779f_gcspushx;
+ }
+ }
+ else
+ {
+ if (((word >> 7) & 0x1) == 0)
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxxx11xx1x010xxxxx. */
+ return A64_OPID_d50b7740_gcsss1_Rt;
+ }
+ else
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxxx11xx1x110xxxxx. */
+ return A64_OPID_d50877df_gcspopx;
+ }
+ }
+ }
+ else
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101000x1xxxxx11xx1xxx1xxxxx. */
+ return A64_OPID_d50877bf_gcspopcx;
+ }
}
}
}
- else
- {
- /* 33222222222211111111110000000000
- 10987654321098765432109876543210
- 11010101000x1xxxxxxxxxxxxx1xxxxx. */
- return A64_OPID_d50877bf_gcspopcx;
- }
}
}
}
@@ -27723,7 +27763,7 @@ aarch64_opcode_lookup_1 (uint32_t word)
/* 33222222222211111111110000000000
10987654321098765432109876543210
x10101x1x100xxxxxxxxxxxxxxxxxxxx. */
- return A64_OPID_d5480000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR;
+ return A64_OPID_d5488000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR;
}
else
{
@@ -27768,19 +27808,29 @@ aarch64_opcode_lookup_1 (uint32_t word)
}
else
{
- if (((word >> 6) & 0x1) == 0)
+ if (((word >> 10) & 0x1) == 0)
{
/* 33222222222211111111110000000000
10987654321098765432109876543210
- 11010101x01x1xxxxxxxxxxxx0xxxxxx. */
- return A64_OPID_d52b7720_gcspopm_Rt;
+ 11010101x01x1xxxxxxxx0xxxxxxxxxx. */
+ return A64_OPID_d528c300_gicr_Rd_GICR;
}
else
{
- /* 33222222222211111111110000000000
- 10987654321098765432109876543210
- 11010101x01x1xxxxxxxxxxxx1xxxxxx. */
- return A64_OPID_d52b7760_gcsss2_Rt;
+ if (((word >> 6) & 0x1) == 0)
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101x01x1xxxxxxxx1xxx0xxxxxx. */
+ return A64_OPID_d52b7720_gcspopm_Rt;
+ }
+ else
+ {
+ /* 33222222222211111111110000000000
+ 10987654321098765432109876543210
+ 11010101x01x1xxxxxxxx1xxx1xxxxxx. */
+ return A64_OPID_d52b7760_gcsss2_Rt;
+ }
}
}
}
@@ -37081,25 +37131,25 @@ aarch64_find_next_opcode (const aarch64_opcode *opcode)
value = A64_OPID_d5000000_msr_SYSREG_Rt;
break;
case A64_OPID_d508779f_gcspushx:
- value = A64_OPID_d5080000_at_SYSREG_AT_Rt;
+ value = A64_OPID_d5087000_dc_SYSREG_DC_Rt;
break;
case A64_OPID_d50877df_gcspopx:
- value = A64_OPID_d5080000_at_SYSREG_AT_Rt;
+ value = A64_OPID_d5087000_dc_SYSREG_DC_Rt;
break;
case A64_OPID_d50877bf_gcspopcx:
- value = A64_OPID_d5080000_at_SYSREG_AT_Rt;
+ value = A64_OPID_d5087000_dc_SYSREG_DC_Rt;
break;
case A64_OPID_d50b7740_gcsss1_Rt:
- value = A64_OPID_d5080000_at_SYSREG_AT_Rt;
+ value = A64_OPID_d5087000_dc_SYSREG_DC_Rt;
break;
case A64_OPID_d50b7700_gcspushm_Rt:
- value = A64_OPID_d5080000_at_SYSREG_AT_Rt;
+ value = A64_OPID_d5087000_dc_SYSREG_DC_Rt;
break;
case A64_OPID_d52b7760_gcsss2_Rt:
- value = A64_OPID_d5280000_gicr_Rd_GICR;
+ value = A64_OPID_d5280000_sysl_Rt_UIMM3_OP1_CRn_CRm_UIMM3_OP2;
break;
case A64_OPID_d52b7720_gcspopm_Rt:
- value = A64_OPID_d5280000_gicr_Rd_GICR;
+ value = A64_OPID_d5280000_sysl_Rt_UIMM3_OP1_CRn_CRm_UIMM3_OP2;
break;
case A64_OPID_d503227f_gcsb_BARRIER_GCSB:
value = A64_OPID_d503201f_hint_UIMM7;
@@ -37107,19 +37157,19 @@ aarch64_find_next_opcode (const aarch64_opcode *opcode)
case A64_OPID_d5080000_sys_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt:
value = A64_OPID_d5000000_msr_SYSREG_Rt;
break;
- case A64_OPID_d5080000_at_SYSREG_AT_Rt:
- value = A64_OPID_d5080000_dc_SYSREG_DC_Rt;
+ case A64_OPID_d5087800_at_SYSREG_AT_Rt:
+ value = A64_OPID_d5087000_dc_SYSREG_DC_Rt;
break;
- case A64_OPID_d5080000_dc_SYSREG_DC_Rt:
- value = A64_OPID_d5080000_ic_SYSREG_IC_Rt_SYS;
+ case A64_OPID_d5087000_dc_SYSREG_DC_Rt:
+ value = A64_OPID_d5087000_ic_SYSREG_IC_Rt_SYS;
break;
- case A64_OPID_d5080000_ic_SYSREG_IC_Rt_SYS:
- value = A64_OPID_d5080000_tlbi_SYSREG_TLBI_Rt_SYS;
- break;
- case A64_OPID_d5080000_tlbi_SYSREG_TLBI_Rt_SYS:
+ case A64_OPID_d5087000_ic_SYSREG_IC_Rt_SYS:
value = A64_OPID_d50b7380_cfp_SYSREG_SR_Rt;
break;
- case A64_OPID_d5480000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR:
+ case A64_OPID_d5088000_tlbi_SYSREG_TLBI_Rt_SYS:
+ value = A64_OPID_d5080000_sys_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt;
+ break;
+ case A64_OPID_d5488000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR:
value = A64_OPID_d5480000_sysp_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt_PAIRREG_OR_XZR;
break;
case A64_OPID_d5031000_wfet_Rd:
@@ -37474,18 +37524,18 @@ aarch64_find_next_opcode (const aarch64_opcode *opcode)
value = A64_OPID_d503201f_hint_UIMM7;
break;
case A64_OPID_d50b72e0_trcit_Rt:
- value = A64_OPID_d5080000_gic_GIC_Rd;
+ value = A64_OPID_d5080000_sys_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt;
break;
- case A64_OPID_d5080000_gic_GIC_Rd:
- value = A64_OPID_d508001f_gsb_GSB;
+ case A64_OPID_d508c000_gic_GIC_Rd:
+ value = A64_OPID_d508c01f_gsb_GSB;
break;
- case A64_OPID_d5280000_gicr_Rd_GICR:
+ case A64_OPID_d528c300_gicr_Rd_GICR:
value = A64_OPID_d5280000_sysl_Rt_UIMM3_OP1_CRn_CRm_UIMM3_OP2;
break;
- case A64_OPID_d508001f_gsb_GSB:
- value = A64_OPID_d5080000_plbi_SYSREG_PLBI_Rt_SYS;
+ case A64_OPID_d508c01f_gsb_GSB:
+ value = A64_OPID_d5080000_sys_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt;
break;
- case A64_OPID_d5080000_plbi_SYSREG_PLBI_Rt_SYS:
+ case A64_OPID_d508a000_plbi_SYSREG_PLBI_Rt_SYS:
value = A64_OPID_d5080000_sys_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt;
break;
default: return NULL;
diff --git a/opcodes/aarch64-tbl-2.h b/opcodes/aarch64-tbl-2.h
index 405b5afbe95768848df5682186d0da310aeb66e0..933e5cd8488a317361f9ae32d231618e014e28e5 100644
--- a/opcodes/aarch64-tbl-2.h
+++ b/opcodes/aarch64-tbl-2.h
@@ -1428,11 +1428,11 @@ enum aarch64_opcode_idx
A64_OPID_d503227f_gcsb_BARRIER_GCSB,
A64_OPID_d5080000_sys_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt,
A64_OPID_d5480000_sysp_UIMM3_OP1_CRn_CRm_UIMM3_OP2_Rt_PAIRREG_OR_XZR,
- A64_OPID_d5080000_at_SYSREG_AT_Rt,
- A64_OPID_d5080000_dc_SYSREG_DC_Rt,
- A64_OPID_d5080000_ic_SYSREG_IC_Rt_SYS,
- A64_OPID_d5080000_tlbi_SYSREG_TLBI_Rt_SYS,
- A64_OPID_d5480000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR,
+ A64_OPID_d5087800_at_SYSREG_AT_Rt,
+ A64_OPID_d5087000_dc_SYSREG_DC_Rt,
+ A64_OPID_d5087000_ic_SYSREG_IC_Rt_SYS,
+ A64_OPID_d5088000_tlbi_SYSREG_TLBI_Rt_SYS,
+ A64_OPID_d5488000_tlbip_SYSREG_TLBIP_Rt_SYS_PAIRREG_OR_XZR,
A64_OPID_d5031000_wfet_Rd,
A64_OPID_d5031020_wfit_Rd,
A64_OPID_d50b7380_cfp_SYSREG_SR_Rt,
@@ -3876,9 +3876,9 @@ enum aarch64_opcode_idx
A64_OPID_c121e800_fmul_SME_Zdnx4_SME_Znx4_SME_Zm_17,
A64_OPID_c120e400_fmul_SME_Zdnx2_SME_Znx2_SME_Zmx2,
A64_OPID_c121e400_fmul_SME_Zdnx4_SME_Znx4_SME_Zmx4,
- A64_OPID_d5080000_gic_GIC_Rd,
- A64_OPID_d5280000_gicr_Rd_GICR,
- A64_OPID_d508001f_gsb_GSB,
+ A64_OPID_d508c000_gic_GIC_Rd,
+ A64_OPID_d528c300_gicr_Rd_GICR,
+ A64_OPID_d508c01f_gsb_GSB,
A64_OPID_81600008_bftmopa_SME_ZAda_1b_SME_Znx2_SVE_Zm_16_SME_Zk_INDEX,
A64_OPID_81400000_bftmopa_SME_ZAda_2b_SME_Znx2_SVE_Zm_16_SME_Zk_INDEX,
A64_OPID_81400008_ftmopa_SME_ZAda_1b_SME_Znx2_SVE_Zm_16_SME_Zk_INDEX,
@@ -4066,7 +4066,7 @@ enum aarch64_opcode_idx
A64_OPID_d5900000_tchangef_Rd_UIMM7_NOT_BALANCED_17,
A64_OPID_d5840000_tchangeb_Rd_Rn_NOT_BALANCED_17,
A64_OPID_d5940000_tchangeb_Rd_UIMM7_NOT_BALANCED_17,
- A64_OPID_d5080000_plbi_SYSREG_PLBI_Rt_SYS,
+ A64_OPID_d508a000_plbi_SYSREG_PLBI_Rt_SYS,
A64_OPID_d4e00000_tenter_UIMM7_NOT_BALANCED_17,
A64_OPID_d6ff03e0_texit_NOT_BALANCED_10,
A64_OPID_MAX,
diff --git a/opcodes/aarch64-tbl.h b/opcodes/aarch64-tbl.h
index 0cad4b801af2c91881659d5473232e1c69e008b0..f8a04e01c5c04638fd518865467614a0bbd81cc2 100644
--- a/opcodes/aarch64-tbl.h
+++ b/opcodes/aarch64-tbl.h
@@ -5226,11 +5226,11 @@ const struct aarch64_opcode aarch64_opcode_table[] =
CORE_INSN ("gcsb", 0xd503227f, 0xffffffff, ic_system, 0, OP1 (BARRIER_GCSB), QL_NIL1, F_ALIAS),
CORE_INSN ("sys", 0xd5080000, 0xfff80000, ic_system, 0, OP5 (UIMM3_OP1, CRn, CRm, UIMM3_OP2, Rt), QL_SYS, F_HAS_ALIAS | F_OPD4_OPT | F_DEFAULT (0x1F)),
D128_INSN ("sysp", 0xd5480000, 0xfff80000, OP6 (UIMM3_OP1, CRn, CRm, UIMM3_OP2, Rt, PAIRREG_OR_XZR), QL_SYSP, F_HAS_ALIAS | F_OPD4_OPT | F_OPD_PAIR_OPT | F_DEFAULT (0x1f)),
- CORE_INSN ("at", 0xd5080000, 0xfff80000, ic_system, 0, OP2 (SYSREG_AT, Rt), QL_SRC_X, F_ALIAS),
- CORE_INSN ("dc", 0xd5080000, 0xfff80000, ic_system, 0, OP2 (SYSREG_DC, Rt), QL_SRC_X, F_ALIAS),
- CORE_INSN ("ic", 0xd5080000, 0xfff80000, ic_system, 0, OP2 (SYSREG_IC, Rt_SYS), QL_SRC_X, F_ALIAS | F_OPD1_OPT | F_DEFAULT (0x1F)),
- CORE_INSN ("tlbi",0xd5080000, 0xfff80000, ic_system, 0, OP2 (SYSREG_TLBI, Rt_SYS), QL_SRC_X, F_ALIAS | F_OPD1_OPT | F_DEFAULT (0x1F)),
- D128_TLBID_INSN ("tlbip",0xd5480000, 0xfff80000, OP3 (SYSREG_TLBIP, Rt_SYS, PAIRREG_OR_XZR), QL_SRC_X2, F_ALIAS| F_OPD1_OPT | F_OPD_PAIR_OPT | F_DEFAULT (0x1f)),
+ CORE_INSN ("at", 0xd5087800, 0xfff8fe00, ic_system, 0, OP2 (SYSREG_AT, Rt), QL_SRC_X, F_ALIAS),
+ CORE_INSN ("dc", 0xd5087000, 0xfff8f000, ic_system, 0, OP2 (SYSREG_DC, Rt), QL_SRC_X, F_ALIAS),
+ CORE_INSN ("ic", 0xd5087000, 0xfff8f000, ic_system, 0, OP2 (SYSREG_IC, Rt_SYS), QL_SRC_X, F_ALIAS | F_OPD1_OPT | F_DEFAULT (0x1F)),
+ CORE_INSN ("tlbi",0xd5088000, 0xfff8e000, ic_system, 0, OP2 (SYSREG_TLBI, Rt_SYS), QL_SRC_X, F_ALIAS | F_OPD1_OPT | F_DEFAULT (0x1F)),
+ D128_TLBID_INSN ("tlbip",0xd5488000, 0xfff8e000, OP3 (SYSREG_TLBIP, Rt_SYS, PAIRREG_OR_XZR), QL_SRC_X2, F_ALIAS| F_OPD1_OPT | F_OPD_PAIR_OPT | F_DEFAULT (0x1f)),
WFXT_INSN ("wfet", 0xd5031000, 0xffffffe0, ic_system, OP1 (Rd), QL_I1X, 0),
WFXT_INSN ("wfit", 0xd5031020, 0xffffffe0, ic_system, OP1 (Rd), QL_I1X, 0),
PREDRES_INSN ("cfp", 0xd50b7380, 0xffffffe0, ic_system, OP2 (SYSREG_SR, Rt), QL_SRC_X, F_ALIAS),
@@ -7783,9 +7783,9 @@ const struct aarch64_opcode aarch64_opcode_table[] =
SME2p2_INSN ("fmul", 0xc121e400, 0xff21fc63, sme_size_22_hsd, OP3 (SME_Zdnx4, SME_Znx4, SME_Zmx4), OP_SVE_VVV_HSD, 0, 0),
/* Generalised Interrupt Controller v5 instructions. */
- GCIE_INSN ("gic", 0xd5080000, 0xfff80000, OP2 (GIC, Rd), QL_SRC_X, F_ALIAS),
- GCIE_INSN ("gicr", 0xd5280000, 0xfff80000, OP2 (Rd, GICR), QL_DST_X, F_ALIAS),
- GCIE_INSN ("gsb", 0xd508001f, 0xfff8001f, OP1 (GSB), QL_IMM_NIL, F_ALIAS),
+ GCIE_INSN ("gic", 0xd508c000, 0xfff8f000, OP2 (GIC, Rd), QL_SRC_X, F_ALIAS),
+ GCIE_INSN ("gicr", 0xd528c300, 0xffffff00, OP2 (Rd, GICR), QL_DST_X, F_ALIAS),
+ GCIE_INSN ("gsb", 0xd508c01f, 0xffffff1f, OP1 (GSB), QL_IMM_NIL, F_ALIAS),
/* SME TMOP instructions. */
SME_TMOP_B16B16_INSN ("bftmopa", 0x81600008, 0xffe0e00e, sme_misc, OP4 (SME_ZAda_1b, SME_Znx2, SVE_Zm_16, SME_Zk_INDEX), OP_SVE_HHHU, 0, 0),
@@ -7993,7 +7993,7 @@ const struct aarch64_opcode aarch64_opcode_table[] =
POE2_INSN("tchangef", 0xd5900000, 0xfffdf000, aarch64_misc, OP3 (Rd, UIMM7, NOT_BALANCED_17), QL_X1NIL2, F_OPD2_OPT | F_DEFAULT (0x0)),
POE2_INSN("tchangeb", 0xd5840000, 0xfffdfc00, aarch64_misc, OP3 (Rd, Rn, NOT_BALANCED_17), QL_X2NIL, F_OPD2_OPT | F_DEFAULT (0x0)),
POE2_INSN("tchangeb", 0xd5940000, 0xfffdf000, aarch64_misc, OP3 (Rd, UIMM7, NOT_BALANCED_17), QL_X1NIL2, F_OPD2_OPT | F_DEFAULT (0x0)),
- POE2_INSN("plbi", 0xd5080000, 0xfff80000, ic_system, OP2 (SYSREG_PLBI, Rt_SYS), QL_SRC_X, F_ALIAS | F_OPD1_OPT | F_DEFAULT (0x1F)),
+ POE2_INSN("plbi", 0xd508a000, 0xfff8f000, ic_system, OP2 (SYSREG_PLBI, Rt_SYS), QL_SRC_X, F_ALIAS | F_OPD1_OPT | F_DEFAULT (0x1F)),
/* TEV instructions. */
TEV_INSN("tenter", 0xd4e00000, 0xfffdf01f, aarch64_misc, OP2 (UIMM7, NOT_BALANCED_17), QL_PRFM_PCREL, F_OPD1_OPT | F_DEFAULT (0x0)),
More information about the Binutils
mailing list