[03/12] x86-64: generalize OP_G()'s EVEX.R' handling

Message ID 030d1c70-0ee9-dd0f-e574-4613cc4b228b@suse.com
State New
Headers show
Series
  • x86: disassembler fixes and some consolidation
Related show

Commit Message

Libor Bukata via Binutils July 21, 2021, 10:19 a.m.
EVEX.R' is invalid to be clear not only for mask registers, but also for
GPRs - IOW everything handled in this function.

Patch

--- a/gas/testsuite/gas/i386/evex.d
+++ b/gas/testsuite/gas/i386/evex.d
@@ -16,4 +16,6 @@  Disassembly of section .text:
  +[a-f0-9]+:	62 f1 d6 38 7b f0    	vcvtusi2ssl %eax,\{rd-sae\},%xmm5,%xmm6
  +[a-f0-9]+:	62 f1 57 38 7b f0    	vcvtusi2sdl %eax,\(bad\),%xmm5,%xmm6
  +[a-f0-9]+:	62 f1 d7 38 7b f0    	vcvtusi2sdl %eax,\(bad\),%xmm5,%xmm6
+ +[a-f0-9]+:	62 e1 7e 08 2d c0    	vcvtss2si %xmm0,%eax
+ +[a-f0-9]+:	62 e1 7c 08 c2 c0 00 	vcmpeqps %xmm0,%xmm0,%k0
 #pass
--- a/gas/testsuite/gas/i386/evex.s
+++ b/gas/testsuite/gas/i386/evex.s
@@ -12,3 +12,5 @@  _start:
 	.byte 0x62, 0xf1, 0xd6, 0x38, 0x7b, 0xf0
 	.byte 0x62, 0xf1, 0x57, 0x38, 0x7b, 0xf0
 	.byte 0x62, 0xf1, 0xd7, 0x38, 0x7b, 0xf0
+	.byte 0x62, 0xe1, 0x7e, 0x08, 0x2d, 0xc0
+	.byte 0x62, 0xe1, 0x7c, 0x08, 0xc2, 0xc0, 0x00
--- a/gas/testsuite/gas/i386/x86-64-evex.d
+++ b/gas/testsuite/gas/i386/x86-64-evex.d
@@ -17,4 +17,6 @@  Disassembly of section .text:
  +[a-f0-9]+:	62 f1 d6 38 7b f0    	vcvtusi2ss %rax,\{rd-sae\},%xmm5,%xmm6
  +[a-f0-9]+:	62 f1 57 38 7b f0    	vcvtusi2sd %eax,\(bad\),%xmm5,%xmm6
  +[a-f0-9]+:	62 f1 d7 38 7b f0    	vcvtusi2sd %rax,\{rd-sae\},%xmm5,%xmm6
+ +[a-f0-9]+:	62 e1 7e 08 2d c0    	vcvtss2si %xmm0,\(bad\)
+ +[a-f0-9]+:	62 e1 7c 08 c2 c0 00 	vcmpeqps %xmm0,%xmm0,\(bad\)
 #pass
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -11934,6 +11934,13 @@  OP_G (int bytemode, int sizeflag)
 {
   int add = 0;
   const char **names;
+
+  if (vex.evex && !vex.r && address_mode == mode_64bit)
+    {
+      oappend ("(bad)");
+      return;
+    }
+
   USED_REX (REX_R);
   if (rex & REX_R)
     add += 8;
@@ -12012,7 +12019,7 @@  OP_G (int bytemode, int sizeflag)
       break;
     case mask_bd_mode:
     case mask_mode:
-      if (add || (vex.evex && !vex.r))
+      if (add)
 	{
 	  oappend ("(bad)");
 	  return;