From be3d663386f1a4e93f4e79419111b56755caec7a Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 28 Apr 2023 08:19:19 +0200 Subject: [PATCH] x86: rework AMX multiplication insn disassembly Consistently do 64-bit first, ModR/M second, VEX.L third, VEX.W fourth, and prefix last, resulting in fewer table entries. Note that in the course of the re-work wrong M_0 suffixes are also corrected to be M_1 (partly infixes now). Since it ended up confusing while testing the change, also adjust the test name in x86-64-amx-bad.d (to be distinct from x86-64-amx.d's). --- gas/testsuite/gas/i386/x86-64-amx-bad.d | 2 +- opcodes/i386-dis.c | 152 +++++++----------------- 2 files changed, 43 insertions(+), 111 deletions(-) diff --git a/gas/testsuite/gas/i386/x86-64-amx-bad.d b/gas/testsuite/gas/i386/x86-64-amx-bad.d index f3d7fbe5097..947e299b610 100644 --- a/gas/testsuite/gas/i386/x86-64-amx-bad.d +++ b/gas/testsuite/gas/i386/x86-64-amx-bad.d @@ -1,6 +1,6 @@ #as: #objdump: -drw -#name: x86_64 AMX insns +#name: x86_64 Illegal AMX insns #source: x86-64-amx-bad.s .*: +file format .* diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 100ec43b189..eb16fd92671 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -978,13 +978,9 @@ enum MOD_VEX_0F384B_X86_64_P_2_W_0, MOD_VEX_0F384B_X86_64_P_3_W_0, MOD_VEX_0F385A, - MOD_VEX_0F385C_X86_64_P_1_W_0, - MOD_VEX_0F385C_X86_64_P_3_W_0, - MOD_VEX_0F385E_X86_64_P_0_W_0, - MOD_VEX_0F385E_X86_64_P_1_W_0, - MOD_VEX_0F385E_X86_64_P_2_W_0, - MOD_VEX_0F385E_X86_64_P_3_W_0, - MOD_VEX_0F386C_X86_64_W_0, + MOD_VEX_0F385C_X86_64, + MOD_VEX_0F385E_X86_64, + MOD_VEX_0F386C_X86_64, MOD_VEX_0F388C, MOD_VEX_0F388E, MOD_VEX_0F3A30_L_0, @@ -1185,9 +1181,9 @@ enum PREFIX_VEX_0F384B_X86_64, PREFIX_VEX_0F3850_W_0, PREFIX_VEX_0F3851_W_0, - PREFIX_VEX_0F385C_X86_64, - PREFIX_VEX_0F385E_X86_64, - PREFIX_VEX_0F386C_X86_64_W_0_M_1_L_0, + PREFIX_VEX_0F385C_X86_64_M_1_L_0_W_0, + PREFIX_VEX_0F385E_X86_64_M_1_L_0_W_0, + PREFIX_VEX_0F386C_X86_64_M_1_L_0_W_0, PREFIX_VEX_0F3872, PREFIX_VEX_0F38B0_W_0, PREFIX_VEX_0F38B1_W_0, @@ -1436,13 +1432,9 @@ enum VEX_LEN_0F384B_X86_64_P_2_W_0_M_0, VEX_LEN_0F384B_X86_64_P_3_W_0_M_0, VEX_LEN_0F385A_M_0, - VEX_LEN_0F385C_X86_64_P_1_W_0_M_0, - VEX_LEN_0F385C_X86_64_P_3_W_0_M_0, - VEX_LEN_0F385E_X86_64_P_0_W_0_M_0, - VEX_LEN_0F385E_X86_64_P_1_W_0_M_0, - VEX_LEN_0F385E_X86_64_P_2_W_0_M_0, - VEX_LEN_0F385E_X86_64_P_3_W_0_M_0, - VEX_LEN_0F386C_X86_64_W_0_M_1, + VEX_LEN_0F385C_X86_64_M_1, + VEX_LEN_0F385E_X86_64_M_1, + VEX_LEN_0F386C_X86_64_M_1, VEX_LEN_0F38DB, VEX_LEN_0F38F2, VEX_LEN_0F38F3, @@ -1604,13 +1596,9 @@ enum VEX_W_0F3858, VEX_W_0F3859, VEX_W_0F385A_M_0_L_0, - VEX_W_0F385C_X86_64_P_1, - VEX_W_0F385C_X86_64_P_3, - VEX_W_0F385E_X86_64_P_0, - VEX_W_0F385E_X86_64_P_1, - VEX_W_0F385E_X86_64_P_2, - VEX_W_0F385E_X86_64_P_3, - VEX_W_0F386C_X86_64, + VEX_W_0F385C_X86_64_M_1_L_0, + VEX_W_0F385E_X86_64_M_1_L_0, + VEX_W_0F386C_X86_64_M_1_L_0, VEX_W_0F3872_P_1, VEX_W_0F3878, VEX_W_0F3879, @@ -4149,23 +4137,23 @@ static const struct dis386 prefix_table[][4] = { { "%XVvpdpbusds", { XM, Vex, EXx }, 0 }, { "vpdpbssds", { XM, Vex, EXx }, 0 }, }, - /* PREFIX_VEX_0F385C_X86_64 */ + /* PREFIX_VEX_0F385C_X86_64_M_1_L_0_W_0 */ { { Bad_Opcode }, - { VEX_W_TABLE (VEX_W_0F385C_X86_64_P_1) }, + { "tdpbf16ps", { TMM, EXtmm, VexTmm }, 0 }, { Bad_Opcode }, - { VEX_W_TABLE (VEX_W_0F385C_X86_64_P_3) }, + { "tdpfp16ps", { TMM, EXtmm, VexTmm }, 0 }, }, - /* PREFIX_VEX_0F385E_X86_64 */ + /* PREFIX_VEX_0F385E_X86_64_M_1_L_0_W_0 */ { - { VEX_W_TABLE (VEX_W_0F385E_X86_64_P_0) }, - { VEX_W_TABLE (VEX_W_0F385E_X86_64_P_1) }, - { VEX_W_TABLE (VEX_W_0F385E_X86_64_P_2) }, - { VEX_W_TABLE (VEX_W_0F385E_X86_64_P_3) }, + { "tdpbuud", {TMM, EXtmm, VexTmm }, 0 }, + { "tdpbsud", {TMM, EXtmm, VexTmm }, 0 }, + { "tdpbusd", {TMM, EXtmm, VexTmm }, 0 }, + { "tdpbssd", {TMM, EXtmm, VexTmm }, 0 }, }, - /* PREFIX_VEX_0F386C_X86_64_W_0_M_1_L_0 */ + /* PREFIX_VEX_0F386C_X86_64_M_1_L_0_W_0 */ { { "tcmmrlfp16ps", { TMM, EXtmm, VexTmm }, 0 }, { Bad_Opcode }, @@ -4530,19 +4518,19 @@ static const struct dis386 x86_64_table[][2] = { /* X86_64_VEX_0F385C */ { { Bad_Opcode }, - { PREFIX_TABLE (PREFIX_VEX_0F385C_X86_64) }, + { MOD_TABLE (MOD_VEX_0F385C_X86_64) }, }, /* X86_64_VEX_0F385E */ { { Bad_Opcode }, - { PREFIX_TABLE (PREFIX_VEX_0F385E_X86_64) }, + { MOD_TABLE (MOD_VEX_0F385E_X86_64) }, }, /* X86_64_VEX_0F386C */ { { Bad_Opcode }, - { VEX_W_TABLE (VEX_W_0F386C_X86_64) }, + { MOD_TABLE (MOD_VEX_0F386C_X86_64) }, }, /* X86_64_VEX_0F38E0 */ @@ -7210,39 +7198,19 @@ static const struct dis386 vex_len_table[][2] = { { VEX_W_TABLE (VEX_W_0F385A_M_0_L_0) }, }, - /* VEX_LEN_0F385C_X86_64_P_1_W_0_M_0 */ + /* VEX_LEN_0F385C_X86_64_M_1 */ { - { "tdpbf16ps", { TMM, EXtmm, VexTmm }, 0 }, + { VEX_W_TABLE (VEX_W_0F385C_X86_64_M_1_L_0) }, }, - /* VEX_LEN_0F385C_X86_64_P_3_W_0_M_0 */ + /* VEX_LEN_0F385E_X86_64_M_1 */ { - { "tdpfp16ps", { TMM, EXtmm, VexTmm }, 0 }, + { VEX_W_TABLE (VEX_W_0F385E_X86_64_M_1_L_0) }, }, - /* VEX_LEN_0F385E_X86_64_P_0_W_0_M_0 */ + /* VEX_LEN_0F386C_X86_64_M_1 */ { - { "tdpbuud", {TMM, EXtmm, VexTmm }, 0 }, - }, - - /* VEX_LEN_0F385E_X86_64_P_1_W_0_M_0 */ - { - { "tdpbsud", {TMM, EXtmm, VexTmm }, 0 }, - }, - - /* VEX_LEN_0F385E_X86_64_P_2_W_0_M_0 */ - { - { "tdpbusd", {TMM, EXtmm, VexTmm }, 0 }, - }, - - /* VEX_LEN_0F385E_X86_64_P_3_W_0_M_0 */ - { - { "tdpbssd", {TMM, EXtmm, VexTmm }, 0 }, - }, - - /* VEX_LEN_0F386C_X86_64_W_0_M_1 */ - { - { PREFIX_TABLE (PREFIX_VEX_0F386C_X86_64_W_0_M_1_L_0) }, + { VEX_W_TABLE (VEX_W_0F386C_X86_64_M_1_L_0) }, }, /* VEX_LEN_0F38DB */ @@ -7890,32 +7858,16 @@ static const struct dis386 vex_w_table[][2] = { { "vbroadcasti128", { XM, Mxmm }, PREFIX_DATA }, }, { - /* VEX_W_0F385C_X86_64_P_1 */ - { MOD_TABLE (MOD_VEX_0F385C_X86_64_P_1_W_0) }, + /* VEX_W_0F385C_X86_64_M_1_L_0 */ + { PREFIX_TABLE (PREFIX_VEX_0F385C_X86_64_M_1_L_0_W_0) }, }, { - /* VEX_W_0F385C_X86_64_P_3 */ - { MOD_TABLE (MOD_VEX_0F385C_X86_64_P_3_W_0) }, + /* VEX_W_0F385E_X86_64_M_1_L_0 */ + { PREFIX_TABLE (PREFIX_VEX_0F385E_X86_64_M_1_L_0_W_0) }, }, { - /* VEX_W_0F385E_X86_64_P_0 */ - { MOD_TABLE (MOD_VEX_0F385E_X86_64_P_0_W_0) }, - }, - { - /* VEX_W_0F385E_X86_64_P_1 */ - { MOD_TABLE (MOD_VEX_0F385E_X86_64_P_1_W_0) }, - }, - { - /* VEX_W_0F385E_X86_64_P_2 */ - { MOD_TABLE (MOD_VEX_0F385E_X86_64_P_2_W_0) }, - }, - { - /* VEX_W_0F385E_X86_64_P_3 */ - { MOD_TABLE (MOD_VEX_0F385E_X86_64_P_3_W_0) }, - }, - { - /* VEX_W_0F386C_X86_64 */ - { MOD_TABLE (MOD_VEX_0F386C_X86_64_W_0) }, + /* VEX_W_0F386C_X86_64_M_1_L_0 */ + { PREFIX_TABLE (PREFIX_VEX_0F386C_X86_64_M_1_L_0_W_0) }, }, { /* VEX_W_0F3872_P_1 */ @@ -8735,39 +8687,19 @@ static const struct dis386 mod_table[][2] = { { VEX_LEN_TABLE (VEX_LEN_0F385A_M_0) }, }, { - /* MOD_VEX_0F385C_X86_64_P_1_W_0 */ + /* MOD_VEX_0F385C_X86_64 */ { Bad_Opcode }, - { VEX_LEN_TABLE (VEX_LEN_0F385C_X86_64_P_1_W_0_M_0) }, + { VEX_LEN_TABLE (VEX_LEN_0F385C_X86_64_M_1) }, }, { - /* MOD_VEX_0F385C_X86_64_P_3_W_0 */ + /* MOD_VEX_0F385E_X86_64 */ { Bad_Opcode }, - { VEX_LEN_TABLE (VEX_LEN_0F385C_X86_64_P_3_W_0_M_0) }, + { VEX_LEN_TABLE (VEX_LEN_0F385E_X86_64_M_1) }, }, { - /* MOD_VEX_0F385E_X86_64_P_0_W_0 */ + /* MOD_VEX_0F386C_X86_64 */ { Bad_Opcode }, - { VEX_LEN_TABLE (VEX_LEN_0F385E_X86_64_P_0_W_0_M_0) }, - }, - { - /* MOD_VEX_0F385E_X86_64_P_1_W_0 */ - { Bad_Opcode }, - { VEX_LEN_TABLE (VEX_LEN_0F385E_X86_64_P_1_W_0_M_0) }, - }, - { - /* MOD_VEX_0F385E_X86_64_P_2_W_0 */ - { Bad_Opcode }, - { VEX_LEN_TABLE (VEX_LEN_0F385E_X86_64_P_2_W_0_M_0) }, - }, - { - /* MOD_VEX_0F385E_X86_64_P_3_W_0 */ - { Bad_Opcode }, - { VEX_LEN_TABLE (VEX_LEN_0F385E_X86_64_P_3_W_0_M_0) }, - }, - { - /* MOD_VEX_0F386C_X86_64_W_0 */ - { Bad_Opcode }, - { VEX_LEN_TABLE (VEX_LEN_0F386C_X86_64_W_0_M_1) }, + { VEX_LEN_TABLE (VEX_LEN_0F386C_X86_64_M_1) }, }, { /* MOD_VEX_0F388C */