[1/5] x86: x87-related adjustments

Message ID 5AE0583302000078001BE50E@prv1-mh.provo.novell.com
State New
Headers show
Series
  • x86: various register handling corrections
Related show

Commit Message

Jan Beulich April 25, 2018, 10:28 a.m.
Neither 287 wrt 8087 nor 387 wrt 287 are proper supersets - in each case
some insns get removed from the ISA (they become NOPs, but code intended
for newer co-processors should not use them).

Furthermore with .no87, ST should not be recognized as a register name.

gas/
2018-04-25  Jan Beulich  <jbeulich@suse.com>

	* config/tc-i386.c (parse_real_register): Check FPU register
	earlier.
	* testsuite/gas/i386/fpu.s, testsuite/gas/i386/fpu.l,
	testsuite/gas/i386/stN.s, testsuite/gas/i386/stN.l: New.
	* testsuite/gas/i386/i386.exp: Run new tests.

opcodes/
2018-04-25  Jan Beulich  <jbeulich@suse.com>

	* i386-gen.c (cpu_flag_init): CPU_I586_FLAGS inherits Cpu387 only.
	CPU_287_FLAGS is Cpu287 only. CPU_387_FLAGS is Cpu387 only.
	* i386-init.h: Re-generate.

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -10109,6 +10109,11 @@  parse_real_register (char *reg_string, c
   /* Handle floating point regs, allowing spaces in the (i) part.  */
   if (r == i386_regtab /* %st is first entry of table  */)
     {
+      if (!cpu_arch_flags.bitfield.cpu8087
+	  && !cpu_arch_flags.bitfield.cpu287
+	  && !cpu_arch_flags.bitfield.cpu387)
+	return (const reg_entry *) NULL;
+
       if (is_space_char (*s))
 	++s;
       if (*s == '(')
@@ -10149,12 +10154,6 @@  parse_real_register (char *reg_string, c
       && !cpu_arch_flags.bitfield.cpui386)
     return (const reg_entry *) NULL;
 
-  if (r->reg_type.bitfield.tbyte
-      && !cpu_arch_flags.bitfield.cpu8087
-      && !cpu_arch_flags.bitfield.cpu287
-      && !cpu_arch_flags.bitfield.cpu387)
-    return (const reg_entry *) NULL;
-
   if (r->reg_type.bitfield.regmmx && !cpu_arch_flags.bitfield.cpuregmmx)
     return (const reg_entry *) NULL;
 
--- /dev/null
+++ b/gas/testsuite/gas/i386/fpu.l
@@ -0,0 +1,4 @@ 
+.*: Assembler messages:
+.*:6: Error: .*`fneni'.*
+.*:11: Error: .*`fneni'.*
+.*:12: Error: .*`fnsetpm'.*
--- /dev/null
+++ b/gas/testsuite/gas/i386/fpu.s
@@ -0,0 +1,12 @@ 
+	.text
+	.intel_syntax noprefix
+	.arch generic32
+fpu:
+	.arch .287
+	fneni
+	fnsetpm
+
+	.arch .no287
+	.arch .387
+	fneni
+	fnsetpm
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -170,6 +170,8 @@  if [expr ([istarget "i*86-*-*"] ||  [ist
     run_list_test "no87" "-al"
     run_list_test "no87-2" "-march=i686+no87 -al"
     run_list_test "no87-3" "-al"
+    run_list_test "stN" "-al"
+    run_list_test "fpu"
     run_list_test "nommx-1" "-al"
     run_list_test "nommx-2" "-march=core+nommx -al"
     run_list_test "nommx-3" "-march=+nommx -al"
--- /dev/null
+++ b/gas/testsuite/gas/i386/stN.l
@@ -0,0 +1,16 @@ 
+.*: Assembler messages:
+.*:6: Error: .*junk.*
+.*:7: Error: .*junk.*
+.*:8: Error: .*junk.*
+GAS LISTING .*
+
+
+[ 	]*1[ 	]+\.text
+[ 	]*2[ 	]+\.intel_syntax noprefix
+[ 	]*3[ 	]+\.arch \.no87
+[ 	]*4[ 	]+stN:
+[ 	]*5[ 	]+\?\?\?\? A1000000[ 	]+mov	eax, st
+[ 	]*5[ 	]+00
+[ 	]*6[ 	]+mov	eax, st\(7\)
+[ 	]*7[ 	]+mov	eax, st \( 7 \)
+[ 	]*8[ 	]+mov	eax, x\(7\)
--- /dev/null
+++ b/gas/testsuite/gas/i386/stN.s
@@ -0,0 +1,8 @@ 
+	.text
+	.intel_syntax noprefix
+	.arch .no87
+stN:
+	mov	eax, st
+	mov	eax, st(7)
+	mov	eax, st ( 7 )
+	mov	eax, x(7)
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -58,7 +58,7 @@  static initializer cpu_flag_init[] =
   { "CPU_I486_FLAGS",
     "CPU_I386_FLAGS|Cpu486" },
   { "CPU_I586_FLAGS",
-    "CPU_I486_FLAGS|CPU_387_FLAGS|Cpu586" },
+    "CPU_I486_FLAGS|Cpu387|Cpu586" },
   { "CPU_I686_FLAGS",
     "CPU_I586_FLAGS|Cpu686|Cpu687" },
   { "CPU_PENTIUMPRO_FLAGS",
@@ -104,9 +104,9 @@  static initializer cpu_flag_init[] =
   { "CPU_8087_FLAGS",
     "Cpu8087" },
   { "CPU_287_FLAGS",
-    "CPU_8087_FLAGS|Cpu287" },
+    "Cpu287" },
   { "CPU_387_FLAGS",
-    "CPU_287_FLAGS|Cpu387" },
+    "Cpu387" },
   { "CPU_687_FLAGS",
     "CPU_387_FLAGS|Cpu687" },
   { "CPU_CLFLUSH_FLAGS",