[4/5] x86: fix {,V}MOV{L,H}PD disassembly

Message ID 1c4f49ad-1967-abad-3982-26c85c368de9@suse.com
State New
Headers show
Series
  • x86: (mainly) insn prefix decoding adjustments
Related show

Commit Message

Jan Beulich June 8, 2020, 7:46 a.m.
Neither the legacy nor the VEX-encoded forms are permitted with register
operands, just like is already the case for their store forms as well as
{,V}MOV{L,H}PS.

At the same time, besides folding respective vex_len_table[] entries,
adjust adjacent related legacy mod_table[] entries:
- when the prefix was already decoded, PREFIX_OPCODE is pointless,
- limit the amount of string literals by using X consistently on all
  {,V}MOV{L,H}P{S,D} forms.

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

	* i386-dis.c (MOD_0F12_PREFIX_2, MOD_0F16_PREFIX_2,
	MOD_VEX_0F12_PREFIX_2, MOD_VEX_0F16_PREFIX_2): New enumerators.
	(VEX_LEN_0F12_P_2, VEX_LEN_0F16_P_2): Delete.
	(VEX_LEN_0F12_P_2_M_0, VEX_LEN_0F16_P_2_M_0): Define.
	(prefix_table): Decode MOD for cases 2 of opcodes 0F12, 0F16,
	VEX_0F12, and VEX_0F16.
	(vex_len_table): Use X for vmovlp* and vmovh*s. Drop
	VEX_LEN_0F12_P_2 and VEX_LEN_0F16_P_2 entries.
	(mod_table): Use X for movlpX and movhpX. Drop PREFIX_OPCODE
	from movlps and movhlps. New MOD_0F12_PREFIX_2,
	MOD_0F16_PREFIX_2, MOD_VEX_0F12_PREFIX_2, and
	MOD_VEX_0F16_PREFIX_2 entries.

Patch

--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -778,8 +778,10 @@  enum
   MOD_0F01_REG_5,
   MOD_0F01_REG_7,
   MOD_0F12_PREFIX_0,
+  MOD_0F12_PREFIX_2,
   MOD_0F13,
   MOD_0F16_PREFIX_0,
+  MOD_0F16_PREFIX_2,
   MOD_0F17,
   MOD_0F18_REG_0,
   MOD_0F18_REG_1,
@@ -842,8 +844,10 @@  enum
   MOD_C4_32BIT,
   MOD_C5_32BIT,
   MOD_VEX_0F12_PREFIX_0,
+  MOD_VEX_0F12_PREFIX_2,
   MOD_VEX_0F13,
   MOD_VEX_0F16_PREFIX_0,
+  MOD_VEX_0F16_PREFIX_2,
   MOD_VEX_0F17,
   MOD_VEX_0F2B,
   MOD_VEX_W_0_0F41_P_0_LEN_1,
@@ -1799,11 +1803,11 @@  enum
 {
   VEX_LEN_0F12_P_0_M_0 = 0,
   VEX_LEN_0F12_P_0_M_1,
-  VEX_LEN_0F12_P_2,
+#define VEX_LEN_0F12_P_2_M_0 VEX_LEN_0F12_P_0_M_0
   VEX_LEN_0F13_M_0,
   VEX_LEN_0F16_P_0_M_0,
   VEX_LEN_0F16_P_0_M_1,
-  VEX_LEN_0F16_P_2,
+#define VEX_LEN_0F16_P_2_M_0 VEX_LEN_0F16_P_0_M_0
   VEX_LEN_0F17_M_0,
   VEX_LEN_0F41_P_0,
   VEX_LEN_0F41_P_2,
@@ -3643,7 +3647,7 @@  static const struct dis386 prefix_table[
   {
     { MOD_TABLE (MOD_0F12_PREFIX_0) },
     { "movsldup", { XM, EXx }, PREFIX_OPCODE },
-    { "movlpd",	{ XM, EXq }, PREFIX_OPCODE },
+    { MOD_TABLE (MOD_0F12_PREFIX_2) },
     { "movddup", { XM, EXq }, PREFIX_OPCODE },
   },
 
@@ -3651,7 +3655,7 @@  static const struct dis386 prefix_table[
   {
     { MOD_TABLE (MOD_0F16_PREFIX_0) },
     { "movshdup", { XM, EXx }, PREFIX_OPCODE },
-    { "movhpd",	{ XM, EXq }, PREFIX_OPCODE },
+    { MOD_TABLE (MOD_0F16_PREFIX_2) },
   },
 
   /* PREFIX_0F1A */
@@ -4648,7 +4652,7 @@  static const struct dis386 prefix_table[
   {
     { MOD_TABLE (MOD_VEX_0F12_PREFIX_0) },
     { "vmovsldup",	{ XM, EXx }, 0 },
-    { VEX_LEN_TABLE (VEX_LEN_0F12_P_2) },
+    { MOD_TABLE (MOD_VEX_0F12_PREFIX_2) },
     { "vmovddup",	{ XM, EXymmq }, 0 },
   },
 
@@ -4656,7 +4660,7 @@  static const struct dis386 prefix_table[
   {
     { MOD_TABLE (MOD_VEX_0F16_PREFIX_0) },
     { "vmovshdup",	{ XM, EXx }, 0 },
-    { VEX_LEN_TABLE (VEX_LEN_0F16_P_2) },
+    { MOD_TABLE (MOD_VEX_0F16_PREFIX_2) },
   },
 
   /* PREFIX_VEX_0F2A */
@@ -9279,9 +9283,9 @@  static const struct dis386 vex_table[][2
 #include "i386-dis-evex.h"
 
 static const struct dis386 vex_len_table[][2] = {
-  /* VEX_LEN_0F12_P_0_M_0 */
+  /* VEX_LEN_0F12_P_0_M_0 / VEX_LEN_0F12_P_2_M_0 */
   {
-    { "vmovlps",	{ XM, Vex128, EXq }, 0 },
+    { "vmovlpX",	{ XM, Vex128, EXq }, 0 },
   },
 
   /* VEX_LEN_0F12_P_0_M_1 */
@@ -9289,19 +9293,14 @@  static const struct dis386 vex_len_table
     { "vmovhlps",	{ XM, Vex128, EXq }, 0 },
   },
 
-  /* VEX_LEN_0F12_P_2 */
-  {
-    { "vmovlpd",	{ XM, Vex128, EXq }, 0 },
-  },
-
   /* VEX_LEN_0F13_M_0 */
   {
     { "vmovlpX",	{ EXq, XM }, PREFIX_OPCODE },
   },
 
-  /* VEX_LEN_0F16_P_0_M_0 */
+  /* VEX_LEN_0F16_P_0_M_0 / VEX_LEN_0F16_P_2_M_0 */
   {
-    { "vmovhps",	{ XM, Vex128, EXq }, 0 },
+    { "vmovhpX",	{ XM, Vex128, EXq }, 0 },
   },
 
   /* VEX_LEN_0F16_P_0_M_1 */
@@ -9309,11 +9308,6 @@  static const struct dis386 vex_len_table
     { "vmovlhps",	{ XM, Vex128, EXq }, 0 },
   },
 
-  /* VEX_LEN_0F16_P_2 */
-  {
-    { "vmovhpd",	{ XM, Vex128, EXq }, 0 },
-  },
-
   /* VEX_LEN_0F17_M_0 */
   {
     { "vmovhpX",	{ EXq, XM }, PREFIX_OPCODE },
@@ -10225,8 +10219,12 @@  static const struct dis386 mod_table[][2
   },
   {
     /* MOD_0F12_PREFIX_0 */
-    { "movlps",		{ XM, EXq }, PREFIX_OPCODE },
-    { "movhlps",	{ XM, EXq }, PREFIX_OPCODE },
+    { "movlpX",		{ XM, EXq }, 0 },
+    { "movhlps",	{ XM, EXq }, 0 },
+  },
+  {
+    /* MOD_0F12_PREFIX_2 */
+    { "movlpX",	{ XM, EXq }, 0 },
   },
   {
     /* MOD_0F13 */
@@ -10234,10 +10232,14 @@  static const struct dis386 mod_table[][2
   },
   {
     /* MOD_0F16_PREFIX_0 */
-    { "movhps",		{ XM, EXq }, 0 },
+    { "movhpX",		{ XM, EXq }, 0 },
     { "movlhps",	{ XM, EXq }, 0 },
   },
   {
+    /* MOD_0F16_PREFIX_2 */
+    { "movhpX",	{ XM, EXq }, 0 },
+  },
+  {
     /* MOD_0F17 */
     { "movhpX",		{ EXq, XM }, PREFIX_OPCODE },
   },
@@ -10519,6 +10521,10 @@  static const struct dis386 mod_table[][2
     { VEX_LEN_TABLE (VEX_LEN_0F12_P_0_M_1) },
   },
   {
+    /* MOD_VEX_0F12_PREFIX_2 */
+    { VEX_LEN_TABLE (VEX_LEN_0F12_P_2_M_0) },
+  },
+  {
     /* MOD_VEX_0F13 */
     { VEX_LEN_TABLE (VEX_LEN_0F13_M_0) },
   },
@@ -10528,6 +10534,10 @@  static const struct dis386 mod_table[][2
     { VEX_LEN_TABLE (VEX_LEN_0F16_P_0_M_1) },
   },
   {
+    /* MOD_VEX_0F16_PREFIX_2 */
+    { VEX_LEN_TABLE (VEX_LEN_0F16_P_2_M_0) },
+  },
+  {
     /* MOD_VEX_0F17 */
     { VEX_LEN_TABLE (VEX_LEN_0F17_M_0) },
   },