[06/19] x86: fold VCMP_Fixup() into CMP_Fixup()

Message ID 0c6a410e-ffb9-1eb7-a19e-a3976c8d3c48@suse.com
State New
Headers show
Series
  • x86: further disassembler fixes and folding
Related show

Commit Message

Jan Beulich July 13, 2020, 9:35 a.m.
There's no reason to have two functions and two tables, when the AVX
functionality here is a proper superset of the SSE one.

opcodes/
2020-07-XX  Jan Beulich  <jbeulich@suse.com>

	* i386-dis.c (VCMP_Fixup, VCMP): Delete.
	(simd_cmp_op): Add const.
	(vex_cmp_op): Move up and drop initial 8 entries. Add const.
	(CMP_Fixup): Handle VEX case.
	(prefix_table): Replace VCMP by CMP.
	* i386-dis-evex-prefix.h, i386-dis-evex-w.h: Likewise.

Patch

--- a/opcodes/i386-dis-evex-prefix.h
+++ b/opcodes/i386-dis-evex-prefix.h
@@ -291,9 +291,9 @@ 
   },
   /* PREFIX_EVEX_0FC2 */
   {
-    { "vcmppX",	{ XMask, Vex, EXx, EXxEVexS, VCMP }, PREFIX_OPCODE },
+    { "vcmppX",	{ XMask, Vex, EXx, EXxEVexS, CMP }, PREFIX_OPCODE },
     { VEX_W_TABLE (EVEX_W_0FC2_P_1) },
-    { "vcmppX",	{ XMask, Vex, EXx, EXxEVexS, VCMP }, PREFIX_OPCODE },
+    { "vcmppX",	{ XMask, Vex, EXx, EXxEVexS, CMP }, PREFIX_OPCODE },
     { VEX_W_TABLE (EVEX_W_0FC2_P_3) },
   },
   /* PREFIX_EVEX_0FC4 */
--- a/opcodes/i386-dis-evex-w.h
+++ b/opcodes/i386-dis-evex-w.h
@@ -270,12 +270,12 @@ 
   },
   /* EVEX_W_0FC2_P_1 */
   {
-    { "vcmpss",	{ XMask, VexScalar, EXxmm_md, EXxEVexS, VCMP }, 0 },
+    { "vcmpss",	{ XMask, VexScalar, EXxmm_md, EXxEVexS, CMP }, 0 },
   },
   /* EVEX_W_0FC2_P_3 */
   {
     { Bad_Opcode },
-    { "vcmpsd",	{ XMask, VexScalar, EXxmm_mq, EXxEVexS, VCMP }, 0 },
+    { "vcmpsd",	{ XMask, VexScalar, EXxmm_mq, EXxEVexS, CMP }, 0 },
   },
   /* EVEX_W_0FD2 */
   {
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -95,7 +95,6 @@  static void OP_Rounding (int, int);
 static void OP_REG_VexI4 (int, int);
 static void OP_VexI4 (int, int);
 static void PCLMUL_Fixup (int, int);
-static void VCMP_Fixup (int, int);
 static void VPCMP_Fixup (int, int);
 static void VPCOM_Fixup (int, int);
 static void OP_0f07 (int, int);
@@ -409,7 +408,6 @@  fetch_data (struct disassemble_info *inf
 #define XMVexScalarI4 { OP_REG_VexI4, scalar_mode }
 #define VexI4 { OP_VexI4, 0 }
 #define PCLMUL { PCLMUL_Fixup, 0 }
-#define VCMP { VCMP_Fixup, 0 }
 #define VPCMP { VPCMP_Fixup, 0 }
 #define VPCOM { VPCOM_Fixup, 0 }
 
@@ -5144,10 +5142,10 @@  static const struct dis386 prefix_table[
 
   /* PREFIX_VEX_0FC2 */
   {
-    { "vcmpps",		{ XM, Vex, EXx, VCMP }, 0 },
-    { "vcmpss",		{ XMScalar, VexScalar, EXxmm_md, VCMP }, 0 },
-    { "vcmppd",		{ XM, Vex, EXx, VCMP }, 0 },
-    { "vcmpsd",		{ XMScalar, VexScalar, EXxmm_mq, VCMP }, 0 },
+    { "vcmpps",		{ XM, Vex, EXx, CMP }, 0 },
+    { "vcmpss",		{ XMScalar, VexScalar, EXxmm_md, CMP }, 0 },
+    { "vcmppd",		{ XM, Vex, EXx, CMP }, 0 },
+    { "vcmpsd",		{ XMScalar, VexScalar, EXxmm_mq, CMP }, 0 },
   },
 
   /* PREFIX_VEX_0FC4 */
@@ -16111,7 +16109,7 @@  OP_3DNowSuffix (int bytemode ATTRIBUTE_U
   mnemonicendp = obufp;
 }
 
-static struct op simd_cmp_op[] =
+static const struct op simd_cmp_op[] =
 {
   { STRING_COMMA_LEN ("eq") },
   { STRING_COMMA_LEN ("lt") },
@@ -16123,6 +16121,34 @@  static struct op simd_cmp_op[] =
   { STRING_COMMA_LEN ("ord") }
 };
 
+static const struct op vex_cmp_op[] =
+{
+  { STRING_COMMA_LEN ("eq_uq") },
+  { STRING_COMMA_LEN ("nge") },
+  { STRING_COMMA_LEN ("ngt") },
+  { STRING_COMMA_LEN ("false") },
+  { STRING_COMMA_LEN ("neq_oq") },
+  { STRING_COMMA_LEN ("ge") },
+  { STRING_COMMA_LEN ("gt") },
+  { STRING_COMMA_LEN ("true") },
+  { STRING_COMMA_LEN ("eq_os") },
+  { STRING_COMMA_LEN ("lt_oq") },
+  { STRING_COMMA_LEN ("le_oq") },
+  { STRING_COMMA_LEN ("unord_s") },
+  { STRING_COMMA_LEN ("neq_us") },
+  { STRING_COMMA_LEN ("nlt_uq") },
+  { STRING_COMMA_LEN ("nle_uq") },
+  { STRING_COMMA_LEN ("ord_s") },
+  { STRING_COMMA_LEN ("eq_us") },
+  { STRING_COMMA_LEN ("nge_uq") },
+  { STRING_COMMA_LEN ("ngt_uq") },
+  { STRING_COMMA_LEN ("false_os") },
+  { STRING_COMMA_LEN ("neq_os") },
+  { STRING_COMMA_LEN ("ge_oq") },
+  { STRING_COMMA_LEN ("gt_oq") },
+  { STRING_COMMA_LEN ("true_us") },
+};
+
 static void
 CMP_Fixup (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
 {
@@ -16140,6 +16166,18 @@  CMP_Fixup (int bytemode ATTRIBUTE_UNUSED
       sprintf (p, "%s%s", simd_cmp_op[cmp_type].name, suffix);
       mnemonicendp += simd_cmp_op[cmp_type].len;
     }
+  else if (need_vex
+	   && cmp_type < ARRAY_SIZE (simd_cmp_op) + ARRAY_SIZE (vex_cmp_op))
+    {
+      char suffix [3];
+      char *p = mnemonicendp - 2;
+      suffix[0] = p[0];
+      suffix[1] = p[1];
+      suffix[2] = '\0';
+      cmp_type -= ARRAY_SIZE (simd_cmp_op);
+      sprintf (p, "%s%s", vex_cmp_op[cmp_type].name, suffix);
+      mnemonicendp += vex_cmp_op[cmp_type].len;
+    }
   else
     {
       /* We have a reserved extension byte.  Output it directly.  */
@@ -16597,69 +16635,6 @@  OP_XMM_Vex (int bytemode, int sizeflag)
   OP_XMM (bytemode, sizeflag);
 }
 
-static struct op vex_cmp_op[] =
-{
-  { STRING_COMMA_LEN ("eq") },
-  { STRING_COMMA_LEN ("lt") },
-  { STRING_COMMA_LEN ("le") },
-  { STRING_COMMA_LEN ("unord") },
-  { STRING_COMMA_LEN ("neq") },
-  { STRING_COMMA_LEN ("nlt") },
-  { STRING_COMMA_LEN ("nle") },
-  { STRING_COMMA_LEN ("ord") },
-  { STRING_COMMA_LEN ("eq_uq") },
-  { STRING_COMMA_LEN ("nge") },
-  { STRING_COMMA_LEN ("ngt") },
-  { STRING_COMMA_LEN ("false") },
-  { STRING_COMMA_LEN ("neq_oq") },
-  { STRING_COMMA_LEN ("ge") },
-  { STRING_COMMA_LEN ("gt") },
-  { STRING_COMMA_LEN ("true") },
-  { STRING_COMMA_LEN ("eq_os") },
-  { STRING_COMMA_LEN ("lt_oq") },
-  { STRING_COMMA_LEN ("le_oq") },
-  { STRING_COMMA_LEN ("unord_s") },
-  { STRING_COMMA_LEN ("neq_us") },
-  { STRING_COMMA_LEN ("nlt_uq") },
-  { STRING_COMMA_LEN ("nle_uq") },
-  { STRING_COMMA_LEN ("ord_s") },
-  { STRING_COMMA_LEN ("eq_us") },
-  { STRING_COMMA_LEN ("nge_uq") },
-  { STRING_COMMA_LEN ("ngt_uq") },
-  { STRING_COMMA_LEN ("false_os") },
-  { STRING_COMMA_LEN ("neq_os") },
-  { STRING_COMMA_LEN ("ge_oq") },
-  { STRING_COMMA_LEN ("gt_oq") },
-  { STRING_COMMA_LEN ("true_us") },
-};
-
-static void
-VCMP_Fixup (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
-{
-  unsigned int cmp_type;
-
-  FETCH_DATA (the_info, codep + 1);
-  cmp_type = *codep++ & 0xff;
-  if (cmp_type < ARRAY_SIZE (vex_cmp_op))
-    {
-      char suffix [3];
-      char *p = mnemonicendp - 2;
-      suffix[0] = p[0];
-      suffix[1] = p[1];
-      suffix[2] = '\0';
-      sprintf (p, "%s%s", vex_cmp_op[cmp_type].name, suffix);
-      mnemonicendp += vex_cmp_op[cmp_type].len;
-    }
-  else
-    {
-      /* We have a reserved extension byte.  Output it directly.  */
-      scratchbuf[0] = '$';
-      print_operand_value (scratchbuf + 1, 1, cmp_type);
-      oappend_maybe_intel (scratchbuf);
-      scratchbuf[0] = '\0';
-    }
-}
-
 static void
 VPCMP_Fixup (int bytemode ATTRIBUTE_UNUSED,
 	     int sizeflag ATTRIBUTE_UNUSED)