public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH 7/9] x86: reuse further VEX entries for EVEX
Date: Tue, 9 Mar 2021 14:11:20 +0100	[thread overview]
Message-ID: <53e4cbb7-4601-4fc3-44c8-246d83099c5e@suse.com> (raw)
In-Reply-To: <59d65321-4135-a723-be53-2450c3759c35@suse.com>

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.)

opcodes/
2021-03-XX  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.

--- a/opcodes/i386-dis-evex-len.h
+++ b/opcodes/i386-dis-evex-len.h
@@ -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_tabl
     { 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_tabl
     { 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 },
--- a/opcodes/i386-dis-evex-prefix.h
+++ b/opcodes/i386-dis-evex-prefix.h
@@ -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 */
   {
--- a/opcodes/i386-dis-evex-w.h
+++ b/opcodes/i386-dis-evex-w.h
@@ -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 */
   {
--- a/opcodes/i386-dis-evex.h
+++ b/opcodes/i386-dis-evex.h
@@ -125,7 +125,7 @@ static const struct dis386 evex_table[][
     { 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[][
     { 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[][
     { 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[][
     { 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[][
     { "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 },
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -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 *d
 	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;


  parent reply	other threads:[~2021-03-09 13:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 13:05 [PATCH 0/9] x86: disassembler fixes and table shrinking Jan Beulich
2021-03-09 13:06 ` [PATCH 1/9] x86: correct decoding of nop/reserved space (0f18 ... 0x1f) Jan Beulich
2021-03-09 13:06 ` [PATCH 2/9] x86: re-arrange order of decode for various legacy opcodes Jan Beulich
2021-03-09 13:07 ` [PATCH 3/9] x86: re-arrange order of decode for various VEX opcodes Jan Beulich
2021-03-09 13:07 ` [PATCH 4/9] x86: re-arrange order of decode for various mask reg opcodes Jan Beulich
2021-03-09 13:10 ` [PATCH 5/9] x86: re-arrange order of decode for various EVEX opcodes Jan Beulich
2021-03-09 13:10 ` [PATCH 6/9] x86: reuse VEX entries for EVEX vperm{q,pd} Jan Beulich
2021-03-09 13:11 ` Jan Beulich [this message]
2021-03-09 13:12 ` [PATCH 8/9] x86: rearrange enumerator and table entry order Jan Beulich
2021-03-09 13:12 ` [PATCH 9/9] x86/Intel: correct AVX512 S/G disassembly Jan Beulich
2021-03-09 14:27 ` [PATCH 0/9] x86: disassembler fixes and table shrinking H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53e4cbb7-4601-4fc3-44c8-246d83099c5e@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).