public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] x86: simplify table-referencing macros
Date: Tue, 11 Jul 2023 06:22:39 +0000 (GMT)	[thread overview]
Message-ID: <20230711062239.7A9D13858031@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=034b6bec547084b19e39b051b3dbab7f9b8b4f23

commit 034b6bec547084b19e39b051b3dbab7f9b8b4f23
Author: Jan Beulich <jbeulich@suse.com>
Date:   Tue Jul 11 08:22:17 2023 +0200

    x86: simplify table-referencing macros
    
    First of all it is entirely unclear why THREE_BYTE_TABLE_PREFIX() was
    introduced by bf890a93a7c4. Nothing uses the .prefix_requirement values
    from the two relevant entries.
    
    And then having VEX_Cn_TABLE() and friends take arguments is misleading.
    These aren't used (or pointlessly used in the case of VEX_C5_TABLE); the
    respective table index is decoded from the insn (or implied in the case
    of VEX_C5_TABLE).

Diff:
---
 opcodes/i386-dis.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 77a54314b36..9905317c110 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -789,20 +789,18 @@ enum
 #define FLOAT			NULL, { { NULL, FLOATCODE } }, 0
 
 #define DIS386(T, I)		NULL, { { NULL, (T)}, { NULL,  (I) } }, 0
-#define DIS386_PREFIX(T, I, P)		NULL, { { NULL, (T)}, { NULL,  (I) } }, P
 #define REG_TABLE(I)		DIS386 (USE_REG_TABLE, (I))
 #define MOD_TABLE(I)		DIS386 (USE_MOD_TABLE, (I))
 #define RM_TABLE(I)		DIS386 (USE_RM_TABLE, (I))
 #define PREFIX_TABLE(I)		DIS386 (USE_PREFIX_TABLE, (I))
 #define X86_64_TABLE(I)		DIS386 (USE_X86_64_TABLE, (I))
 #define THREE_BYTE_TABLE(I)	DIS386 (USE_3BYTE_TABLE, (I))
-#define THREE_BYTE_TABLE_PREFIX(I, P)	DIS386_PREFIX (USE_3BYTE_TABLE, (I), P)
-#define XOP_8F_TABLE(I)		DIS386 (USE_XOP_8F_TABLE, (I))
-#define VEX_C4_TABLE(I)		DIS386 (USE_VEX_C4_TABLE, (I))
-#define VEX_C5_TABLE(I)		DIS386 (USE_VEX_C5_TABLE, (I))
+#define XOP_8F_TABLE()		DIS386 (USE_XOP_8F_TABLE, 0)
+#define VEX_C4_TABLE()		DIS386 (USE_VEX_C4_TABLE, 0)
+#define VEX_C5_TABLE()		DIS386 (USE_VEX_C5_TABLE, 0)
 #define VEX_LEN_TABLE(I)	DIS386 (USE_VEX_LEN_TABLE, (I))
 #define VEX_W_TABLE(I)		DIS386 (USE_VEX_W_TABLE, (I))
-#define EVEX_TABLE(I)		DIS386 (USE_EVEX_TABLE, (I))
+#define EVEX_TABLE()		DIS386 (USE_EVEX_TABLE, 0)
 #define EVEX_LEN_TABLE(I)	DIS386 (USE_EVEX_LEN_TABLE, (I))
 
 enum
@@ -2081,9 +2079,9 @@ static const struct dis386 dis386_twobyte[] = {
   { Bad_Opcode },
   { "getsec",		{ XX }, 0 },
   /* 38 */
-  { THREE_BYTE_TABLE_PREFIX (THREE_BYTE_0F38, PREFIX_OPCODE) },
+  { THREE_BYTE_TABLE (THREE_BYTE_0F38) },
   { Bad_Opcode },
-  { THREE_BYTE_TABLE_PREFIX (THREE_BYTE_0F3A, PREFIX_OPCODE) },
+  { THREE_BYTE_TABLE (THREE_BYTE_0F3A) },
   { Bad_Opcode },
   { Bad_Opcode },
   { Bad_Opcode },
@@ -2493,11 +2491,11 @@ static const struct dis386 reg_table[][8] = {
   /* REG_8F */
   {
     { "pop{P|}", { stackEv }, 0 },
-    { XOP_8F_TABLE (XOP_09) },
+    { XOP_8F_TABLE () },
     { Bad_Opcode },
     { Bad_Opcode },
     { Bad_Opcode },
-    { XOP_8F_TABLE (XOP_09) },
+    { XOP_8F_TABLE () },
   },
   /* REG_C0 */
   {
@@ -4016,7 +4014,7 @@ static const struct dis386 x86_64_table[][2] = {
   /* X86_64_62 */
   {
     { MOD_TABLE (MOD_62_32BIT) },
-    { EVEX_TABLE (EVEX_0F) },
+    { EVEX_TABLE () },
   },
 
   /* X86_64_63 */
@@ -4063,13 +4061,13 @@ static const struct dis386 x86_64_table[][2] = {
   /* X86_64_C4 */
   {
     { MOD_TABLE (MOD_C4_32BIT) },
-    { VEX_C4_TABLE (VEX_0F) },
+    { VEX_C4_TABLE () },
   },
 
   /* X86_64_C5 */
   {
     { MOD_TABLE (MOD_C5_32BIT) },
-    { VEX_C5_TABLE (VEX_0F) },
+    { VEX_C5_TABLE () },
   },
 
   /* X86_64_CE */
@@ -7854,17 +7852,17 @@ static const struct dis386 mod_table[][2] = {
   {
     /* MOD_62_32BIT */
     { "bound{S|}",	{ Gv, Ma }, 0 },
-    { EVEX_TABLE (EVEX_0F) },
+    { EVEX_TABLE () },
   },
   {
     /* MOD_C4_32BIT */
     { "lesS",		{ Gv, Mp }, 0 },
-    { VEX_C4_TABLE (VEX_0F) },
+    { VEX_C4_TABLE () },
   },
   {
     /* MOD_C5_32BIT */
     { "ldsS",		{ Gv, Mp }, 0 },
-    { VEX_C5_TABLE (VEX_0F) },
+    { VEX_C5_TABLE () },
   },
   {
     /* MOD_0F01_REG_0 */
@@ -8710,7 +8708,7 @@ get_valid_dis386 (const struct dis386 *dp, instr_info *ins)
       ins->need_vex = 2;
       ins->codep++;
       vindex = *ins->codep++;
-      dp = &vex_table[dp->op[1].bytemode][vindex];
+      dp = &vex_table[VEX_0F][vindex];
       ins->end_codep = ins->codep;
       /* There is no MODRM byte for VEX 77.  */
       if (vindex != 0x77 && !fetch_modrm (ins))

                 reply	other threads:[~2023-07-11  6:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230711062239.7A9D13858031@sourceware.org \
    --to=jbeulich@sourceware.org \
    --cc=bfd-cvs@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).