From 3ef1c4468d46e587b9538635d2c0223e95811807 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 11 Jul 2023 08:16:00 +0200 Subject: [PATCH] x86: fold legacy/VEX {,V}MOV{H,L}* entries By changing decode order to do ModR/M.mod last (rather than VEX.L), the VEX entries (which are already reused by EVEX decoding) can be folded with their legacy counterparts as well. Note how this change of decode order also allows removing two auxiliary #define-s, which were introduced during earlier folding (because of that unhelpful order of steps). --- opcodes/i386-dis-evex.h | 4 +- opcodes/i386-dis.c | 98 ++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 68 deletions(-) diff --git a/opcodes/i386-dis-evex.h b/opcodes/i386-dis-evex.h index 43dc4334fd7..93bb3222e12 100644 --- a/opcodes/i386-dis-evex.h +++ b/opcodes/i386-dis-evex.h @@ -23,11 +23,11 @@ static const struct dis386 evex_table[][256] = { { PREFIX_TABLE (PREFIX_0F10) }, { PREFIX_TABLE (PREFIX_0F11) }, { PREFIX_TABLE (PREFIX_VEX_0F12) }, - { MOD_TABLE (MOD_VEX_0F13) }, + { VEX_LEN_TABLE (VEX_LEN_0F13) }, { "%XEvunpcklpX", { XM, Vex, EXx }, PREFIX_OPCODE }, { "%XEvunpckhpX", { XM, Vex, EXx }, PREFIX_OPCODE }, { PREFIX_TABLE (PREFIX_VEX_0F16) }, - { MOD_TABLE (MOD_VEX_0F17) }, + { VEX_LEN_TABLE (VEX_LEN_0F17) }, /* 18 */ { Bad_Opcode }, { Bad_Opcode }, diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 1e83912d089..acc8152ea53 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -931,12 +931,6 @@ enum MOD_0F38FB_PREFIX_1, MOD_0F3A0F_PREFIX_1, - MOD_VEX_0F12_PREFIX_0, - MOD_VEX_0F12_PREFIX_2, - MOD_VEX_0F13, - MOD_VEX_0F16_PREFIX_0, - MOD_VEX_0F16_PREFIX_2, - MOD_VEX_0F17, MOD_VEX_0F2B, MOD_VEX_0F41_L_1, MOD_VEX_0F42_L_1, @@ -1362,14 +1356,12 @@ enum enum { - VEX_LEN_0F12_P_0_M_0 = 0, - VEX_LEN_0F12_P_0_M_1, -#define VEX_LEN_0F12_P_2_M_0 VEX_LEN_0F12_P_0_M_0 - VEX_LEN_0F13_M_0, - VEX_LEN_0F16_P_0_M_0, - VEX_LEN_0F16_P_0_M_1, -#define VEX_LEN_0F16_P_2_M_0 VEX_LEN_0F16_P_0_M_0 - VEX_LEN_0F17_M_0, + VEX_LEN_0F12_P_0 = 0, + VEX_LEN_0F12_P_2, + VEX_LEN_0F13, + VEX_LEN_0F16_P_0, + VEX_LEN_0F16_P_2, + VEX_LEN_0F17, VEX_LEN_0F41, VEX_LEN_0F42, VEX_LEN_0F44, @@ -3665,17 +3657,17 @@ static const struct dis386 prefix_table[][4] = { /* PREFIX_VEX_0F12 */ { - { MOD_TABLE (MOD_VEX_0F12_PREFIX_0) }, + { VEX_LEN_TABLE (VEX_LEN_0F12_P_0) }, { "%XEvmov%XSldup", { XM, EXEvexXNoBcst }, 0 }, - { MOD_TABLE (MOD_VEX_0F12_PREFIX_2) }, + { VEX_LEN_TABLE (VEX_LEN_0F12_P_2) }, { "%XEvmov%XDdup", { XM, EXymmq }, 0 }, }, /* PREFIX_VEX_0F16 */ { - { MOD_TABLE (MOD_VEX_0F16_PREFIX_0) }, + { VEX_LEN_TABLE (VEX_LEN_0F16_P_0) }, { "%XEvmov%XShdup", { XM, EXEvexXNoBcst }, 0 }, - { MOD_TABLE (MOD_VEX_0F16_PREFIX_2) }, + { VEX_LEN_TABLE (VEX_LEN_0F16_P_2) }, }, /* PREFIX_VEX_0F2A */ @@ -5965,11 +5957,11 @@ static const struct dis386 vex_table[][256] = { { PREFIX_TABLE (PREFIX_0F10) }, { PREFIX_TABLE (PREFIX_0F11) }, { PREFIX_TABLE (PREFIX_VEX_0F12) }, - { MOD_TABLE (MOD_VEX_0F13) }, + { VEX_LEN_TABLE (VEX_LEN_0F13) }, { "vunpcklpX", { XM, Vex, EXx }, PREFIX_OPCODE }, { "vunpckhpX", { XM, Vex, EXx }, PREFIX_OPCODE }, { PREFIX_TABLE (PREFIX_VEX_0F16) }, - { MOD_TABLE (MOD_VEX_0F17) }, + { VEX_LEN_TABLE (VEX_LEN_0F17) }, /* 18 */ { Bad_Opcode }, { Bad_Opcode }, @@ -6819,34 +6811,34 @@ static const struct dis386 vex_table[][256] = { #include "i386-dis-evex.h" static const struct dis386 vex_len_table[][2] = { - /* VEX_LEN_0F12_P_0_M_0 / VEX_LEN_0F12_P_2_M_0 */ + /* VEX_LEN_0F12_P_0 */ { - { "%XEvmovlpYX", { XM, Vex, EXq }, 0 }, + { MOD_TABLE (MOD_0F12_PREFIX_0) }, }, - /* VEX_LEN_0F12_P_0_M_1 */ + /* VEX_LEN_0F12_P_2 */ { - { "%XEvmovhlpY%XS", { XM, Vex, EXq }, 0 }, + { MOD_TABLE (MOD_0F12_PREFIX_2) }, }, - /* VEX_LEN_0F13_M_0 */ + /* VEX_LEN_0F13 */ { - { "%XEvmovlpYX", { EXq, XM }, PREFIX_OPCODE }, + { MOD_TABLE (MOD_0F13) }, }, - /* VEX_LEN_0F16_P_0_M_0 / VEX_LEN_0F16_P_2_M_0 */ + /* VEX_LEN_0F16_P_0 */ { - { "%XEvmovhpYX", { XM, Vex, EXq }, 0 }, + { MOD_TABLE (MOD_0F16_PREFIX_0) }, }, - /* VEX_LEN_0F16_P_0_M_1 */ + /* VEX_LEN_0F16_P_2 */ { - { "%XEvmovlhpY%XS", { XM, Vex, EXq }, 0 }, + { MOD_TABLE (MOD_0F16_PREFIX_2) }, }, - /* VEX_LEN_0F17_M_0 */ + /* VEX_LEN_0F17 */ { - { "%XEvmovhpYX", { EXq, XM }, PREFIX_OPCODE }, + { MOD_TABLE (MOD_0F17) }, }, /* VEX_LEN_0F41 */ @@ -8039,29 +8031,29 @@ static const struct dis386 mod_table[][2] = { }, { /* MOD_0F12_PREFIX_0 */ - { "movlpX", { XM, EXq }, 0 }, - { "movhlps", { XM, EXq }, 0 }, + { "%XEVmovlpYX", { XM, Vex, EXq }, 0 }, + { "%XEVmovhlpY%XS", { XM, Vex, EXq }, 0 }, }, { /* MOD_0F12_PREFIX_2 */ - { "movlpX", { XM, EXq }, 0 }, + { "%XEVmovlpYX", { XM, Vex, EXq }, 0 }, }, { /* MOD_0F13 */ - { "movlpX", { EXq, XM }, PREFIX_OPCODE }, + { "%XEVmovlpYX", { EXq, XM }, PREFIX_OPCODE }, }, { /* MOD_0F16_PREFIX_0 */ - { "movhpX", { XM, EXq }, 0 }, - { "movlhps", { XM, EXq }, 0 }, + { "%XEVmovhpYX", { XM, Vex, EXq }, 0 }, + { "%XEVmovlhpY%XS", { XM, Vex, EXq }, 0 }, }, { /* MOD_0F16_PREFIX_2 */ - { "movhpX", { XM, EXq }, 0 }, + { "%XEVmovhpYX", { XM, Vex, EXq }, 0 }, }, { /* MOD_0F17 */ - { "movhpX", { EXq, XM }, PREFIX_OPCODE }, + { "%XEVmovhpYX", { EXq, XM }, PREFIX_OPCODE }, }, { /* MOD_0F18_REG_0 */ @@ -8301,32 +8293,6 @@ static const struct dis386 mod_table[][2] = { { Bad_Opcode }, { REG_TABLE (REG_0F3A0F_PREFIX_1_MOD_3) }, }, - { - /* MOD_VEX_0F12_PREFIX_0 */ - { VEX_LEN_TABLE (VEX_LEN_0F12_P_0_M_0) }, - { VEX_LEN_TABLE (VEX_LEN_0F12_P_0_M_1) }, - }, - { - /* MOD_VEX_0F12_PREFIX_2 */ - { VEX_LEN_TABLE (VEX_LEN_0F12_P_2_M_0) }, - }, - { - /* MOD_VEX_0F13 */ - { VEX_LEN_TABLE (VEX_LEN_0F13_M_0) }, - }, - { - /* MOD_VEX_0F16_PREFIX_0 */ - { VEX_LEN_TABLE (VEX_LEN_0F16_P_0_M_0) }, - { VEX_LEN_TABLE (VEX_LEN_0F16_P_0_M_1) }, - }, - { - /* MOD_VEX_0F16_PREFIX_2 */ - { VEX_LEN_TABLE (VEX_LEN_0F16_P_2_M_0) }, - }, - { - /* MOD_VEX_0F17 */ - { VEX_LEN_TABLE (VEX_LEN_0F17_M_0) }, - }, { /* MOD_VEX_0F2B */ { "%XEvmovntpX", { Mx, XM }, PREFIX_OPCODE }, -- 2.30.2