x86: reuse further VEX entries for EVEX

When the VEX.L=1 decode matches that of both EVEX.L'L=1 and EVEX.L'L=2
(typically when all three are invalid) the (smaller) VEX table entry can
be reused by EVEX, instead of duplicating data. (Note that XM and XMM as
well as EXxmm_md and EXd are equivalent at least for the purposes here.)
This commit is contained in:
Jan Beulich 2021-03-10 08:19:11 +01:00
parent 066f82b96a
commit 85ba7507f6
6 changed files with 46 additions and 98 deletions

View File

@ -1,3 +1,22 @@
2021-03-10 Jan Beulich <jbeulich@suse.com>
* opcodes/i386-dis.c (EVEX_LEN_0F6E, EVEX_LEN_0F7E_P_1,
EVEX_LEN_0F7E_P_2, EVEX_LEN_0FC4, EVEX_LEN_0FC5, EVEX_LEN_0FD6,
EVEX_LEN_0F3816, EVEX_LEN_0F3A14, EVEX_LEN_0F3A15,
EVEX_LEN_0F3A16, EVEX_LEN_0F3A17, EVEX_LEN_0F3A20,
EVEX_LEN_0F3A21_W_0, EVEX_LEN_0F3A22, EVEX_W_0FD6_L_0): Delete.
(EVEX_LEN_0F3816, EVEX_W_0FD6): New.
(get_valid_dis386): Also handle 512-bit vector length when
vectoring into vex_len_table[].
* i386-dis-evex.h (evex_table): Adjust opcode 0F6E, 0FC4, 0FC5,
0FD6, 0F3A14, 0F3A15, 0F3A16, 0F3A17, 0F3A20, and 0F3A22
entries.
* i386-dis-evex-len.h: Delete opcode 0F6E, 0FC4, 0FC5, 0FD6,
0F3A14, 0F3A15, 0F3A16, 0F3A17, 0F3A20, and 0F3A22 entries.
* i386-dis-evex-prefix.h: Adjust 0F7E entry.
* i386-dis-evex-w.h: Adjust 0F7E, 0F7F, 0FD6, and 0F3A21
entries.
2021-03-10 Jan Beulich <jbeulich@suse.com>
* opcodes/i386-dis.c (EVEX_LEN_0F3A00_W_1, EVEX_LEN_0F3A01_W_1):

View File

@ -1,34 +1,4 @@
static const struct dis386 evex_len_table[][3] = {
/* EVEX_LEN_0F6E */
{
{ "vmovK", { XMScalar, Edq }, PREFIX_DATA },
},
/* EVEX_LEN_0F7E_P_1 */
{
{ VEX_W_TABLE (EVEX_W_0F7E_P_1) },
},
/* EVEX_LEN_0F7E_P_2 */
{
{ "vmovK", { Edq, XMScalar }, 0 },
},
/* EVEX_LEN_0FC4 */
{
{ "vpinsrw", { XM, Vex, Edqw, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0FC5 */
{
{ "vpextrw", { Gdq, XS, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0FD6 */
{
{ VEX_W_TABLE (EVEX_W_0FD6_L_0) },
},
/* EVEX_LEN_0F3816 */
{
{ Bad_Opcode },
@ -106,26 +76,6 @@ static const struct dis386 evex_len_table[][3] = {
{ VEX_W_TABLE (VEX_W_0F3A01_L_1) },
},
/* EVEX_LEN_0F3A14 */
{
{ "vpextrb", { Edqb, XM, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0F3A15 */
{
{ "vpextrw", { Edqw, XM, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0F3A16 */
{
{ "vpextrK", { Edq, XM, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0F3A17 */
{
{ "vextractps", { Edqd, XMM, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0F3A18 */
{
{ Bad_Opcode },
@ -154,21 +104,6 @@ static const struct dis386 evex_len_table[][3] = {
{ VEX_W_TABLE (EVEX_W_0F3A1B_L_2) },
},
/* EVEX_LEN_0F3A20 */
{
{ "vpinsrb", { XM, Vex, Edqb, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0F3A21_W_0 */
{
{ "vinsertps", { XMM, Vex, EXxmm_md, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0F3A22 */
{
{ "vpinsrK", { XM, Vex, Edq, Ib }, PREFIX_DATA },
},
/* EVEX_LEN_0F3A23 */
{
{ Bad_Opcode },

View File

@ -139,8 +139,8 @@
/* PREFIX_EVEX_0F7E */
{
{ Bad_Opcode },
{ EVEX_LEN_TABLE (EVEX_LEN_0F7E_P_1) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F7E_P_2) },
{ VEX_W_TABLE (EVEX_W_0F7E_P_1) },
{ VEX_LEN_TABLE (VEX_LEN_0F7E_P_2) },
},
/* PREFIX_EVEX_0F7F */
{

View File

@ -251,7 +251,7 @@
/* EVEX_W_0F7E_P_1 */
{
{ Bad_Opcode },
{ "vmovq", { XMScalar, EXxmm_mq }, 0 },
{ VEX_LEN_TABLE (VEX_LEN_0F7E_P_1) },
},
/* EVEX_W_0F7F_P_1 */
{
@ -291,10 +291,10 @@
{ Bad_Opcode },
{ "vpaddq", { XM, Vex, EXx }, PREFIX_DATA },
},
/* EVEX_W_0FD6_L_0 */
/* EVEX_W_0FD6 */
{
{ Bad_Opcode },
{ "vmovq", { EXqS, XMScalar }, PREFIX_DATA },
{ VEX_LEN_TABLE (VEX_LEN_0FD6) },
},
/* EVEX_W_0FE6_P_1 */
{
@ -625,7 +625,7 @@
},
/* EVEX_W_0F3A21 */
{
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A21_W_0) },
{ VEX_LEN_TABLE (VEX_LEN_0F3A21) },
},
/* EVEX_W_0F3A23_L_n */
{

View File

@ -125,7 +125,7 @@ static const struct dis386 evex_table[][256] = {
{ VEX_W_TABLE (EVEX_W_0F6B) },
{ VEX_W_TABLE (EVEX_W_0F6C) },
{ VEX_W_TABLE (EVEX_W_0F6D) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F6E) },
{ VEX_LEN_TABLE (VEX_LEN_0F6E) },
{ PREFIX_TABLE (PREFIX_EVEX_0F6F) },
/* 70 */
{ PREFIX_TABLE (PREFIX_EVEX_0F70) },
@ -222,8 +222,8 @@ static const struct dis386 evex_table[][256] = {
{ Bad_Opcode },
{ PREFIX_TABLE (PREFIX_EVEX_0FC2) },
{ Bad_Opcode },
{ EVEX_LEN_TABLE (EVEX_LEN_0FC4) },
{ EVEX_LEN_TABLE (EVEX_LEN_0FC5) },
{ VEX_LEN_TABLE (VEX_LEN_0FC4) },
{ VEX_LEN_TABLE (VEX_LEN_0FC5) },
{ "vshufpX", { XM, Vex, EXx, Ib }, PREFIX_OPCODE },
{ Bad_Opcode },
/* C8 */
@ -242,7 +242,7 @@ static const struct dis386 evex_table[][256] = {
{ VEX_W_TABLE (EVEX_W_0FD3) },
{ VEX_W_TABLE (EVEX_W_0FD4) },
{ "vpmullw", { XM, Vex, EXx }, PREFIX_DATA },
{ EVEX_LEN_TABLE (EVEX_LEN_0FD6) },
{ VEX_W_TABLE (EVEX_W_0FD6) },
{ Bad_Opcode },
/* D8 */
{ "vpsubusb", { XM, Vex, EXx }, PREFIX_DATA },
@ -606,10 +606,10 @@ static const struct dis386 evex_table[][256] = {
{ Bad_Opcode },
{ Bad_Opcode },
{ Bad_Opcode },
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A14) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A15) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A16) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A17) },
{ VEX_LEN_TABLE (VEX_LEN_0F3A14) },
{ VEX_LEN_TABLE (VEX_LEN_0F3A15) },
{ VEX_LEN_TABLE (VEX_LEN_0F3A16) },
{ VEX_LEN_TABLE (VEX_LEN_0F3A17) },
/* 18 */
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A18) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A19) },
@ -620,9 +620,9 @@ static const struct dis386 evex_table[][256] = {
{ "vpcmpu%DQ", { XMask, Vex, EXx, VPCMP }, PREFIX_DATA },
{ "vpcmp%DQ", { XMask, Vex, EXx, VPCMP }, PREFIX_DATA },
/* 20 */
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A20) },
{ VEX_LEN_TABLE (VEX_LEN_0F3A20) },
{ VEX_W_TABLE (EVEX_W_0F3A21) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A22) },
{ VEX_LEN_TABLE (VEX_LEN_0F3A22) },
{ EVEX_LEN_TABLE (EVEX_LEN_0F3A23) },
{ Bad_Opcode },
{ "vpternlog%DQ", { XM, Vex, EXx, Ib }, PREFIX_DATA },

View File

@ -1334,13 +1334,7 @@ enum
enum
{
EVEX_LEN_0F6E = 0,
EVEX_LEN_0F7E_P_1,
EVEX_LEN_0F7E_P_2,
EVEX_LEN_0FC4,
EVEX_LEN_0FC5,
EVEX_LEN_0FD6,
EVEX_LEN_0F3816,
EVEX_LEN_0F3816 = 0,
EVEX_LEN_0F3819,
EVEX_LEN_0F381A_M_0,
EVEX_LEN_0F381B_M_0,
@ -1351,17 +1345,10 @@ enum
EVEX_LEN_0F38C7_M_0,
EVEX_LEN_0F3A00,
EVEX_LEN_0F3A01,
EVEX_LEN_0F3A14,
EVEX_LEN_0F3A15,
EVEX_LEN_0F3A16,
EVEX_LEN_0F3A17,
EVEX_LEN_0F3A18,
EVEX_LEN_0F3A19,
EVEX_LEN_0F3A1A,
EVEX_LEN_0F3A1B,
EVEX_LEN_0F3A20,
EVEX_LEN_0F3A21_W_0,
EVEX_LEN_0F3A22,
EVEX_LEN_0F3A23,
EVEX_LEN_0F3A38,
EVEX_LEN_0F3A39,
@ -1549,7 +1536,7 @@ enum
EVEX_W_0FD2,
EVEX_W_0FD3,
EVEX_W_0FD4,
EVEX_W_0FD6_L_0,
EVEX_W_0FD6,
EVEX_W_0FE6_P_1,
EVEX_W_0FE6_P_2,
EVEX_W_0FE6_P_3,
@ -9063,9 +9050,16 @@ get_valid_dis386 (const struct dis386 *dp, disassemble_info *info)
case 128:
vindex = 0;
break;
case 512:
/* This allows re-using in particular table entries where only
128-bit operand size (VEX.L=0 / EVEX.L'L=0) are valid. */
if (vex.evex)
{
case 256:
vindex = 1;
break;
vindex = 1;
break;
}
/* Fall through. */
default:
abort ();
break;