]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: adjust segment override prefix emission
authorJan Beulich <jbeulich@suse.com>
Fri, 14 Feb 2020 13:04:23 +0000 (14:04 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 14 Feb 2020 13:04:23 +0000 (14:04 +0100)
Since we already suppress the prefix altogether when it's the default
one for the chosen addressing mode, let's do so also when instruction
prefix and override specified with the memory operand match. (Note that
insn prefix specified segment overrides never get discarded.)

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/prefix32.l
gas/testsuite/gas/i386/prefix32.s

index 0cbd2a5bbffaadcc72e8a2e1ced80c0ac239efe5..56d50719a2a746fa8df8cfddcc3cfcf72d4ee9d0 100644 (file)
@@ -1,3 +1,11 @@
+2020-02-14  Jan Beulich  <jbeulich@suse.com>
+
+       * config/tc-i386.c (process_operands): Also skip segment
+       override prefix emission if it matches an already present one.
+       * testsuite/gas/i386/prefix32.s: Add double segment override
+       cases.
+       * testsuite/gas/i386/prefix32.l: Adjust expectations.
+
 2020-02-14  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-i386.c (process_operands): Drop ineffectual segment
index d7d45de76e0f7af5bb61fbde10292cdce29a4db3..0e60919e492046ec6a416e29a8e330b4af5d4a4d 100644 (file)
@@ -7178,11 +7178,13 @@ duplicate:
     }
 
   /* If a segment was explicitly specified, and the specified segment
-     is not the default, use an opcode prefix to select it.  If we
-     never figured out what the default segment is, then default_seg
-     will be zero at this point, and the specified segment prefix will
-     always be used.  */
-  if ((i.seg[0]) && (i.seg[0] != default_seg))
+     is neither the default nor the one already recorded from a prefix,
+     use an opcode prefix to select it.  If we never figured out what
+     the default segment is, then default_seg will be zero at this
+     point, and the specified segment prefix will always be used.  */
+  if (i.seg[0]
+      && i.seg[0] != default_seg
+      && i.seg[0]->seg_prefix != i.prefix[SEG_PREFIX])
     {
       if (!add_prefix (i.seg[0]->seg_prefix))
        return 0;
index 41c8d8801c06e1afd6d45a8b591a002697de4b3c..09a00cd03d9707b11aabf9f744248f75748404ef 100644 (file)
@@ -8,6 +8,7 @@
 .*:19: Error: same type of prefix .*
 .*:20: Error: data size .* `vaddps'
 .*:21: Error: data size .* `vaddpd'
+.*:25: Error: same type of prefix .*
 GAS LISTING .*
 #...
 [      ]*1[    ]+\.text
@@ -33,4 +34,10 @@ GAS LISTING .*
 [      ]*20[   ]+data16 vaddps %xmm0, %xmm0, %xmm0
 [      ]*21[   ]+data16 vaddpd %xmm0, %xmm0, %xmm0
 [      ]*22[   ]*
-[      ]*23[   ]*[\?]+ 0+[ \t]+\.p2align       4,0
+[      ]*23[   ]+\.Lsegment:
+[      ]*24[   ]+\?\?\?\? 368B4500[    ]+ss mov                %ss:\(%ebp\), %eax
+[      ]*25[   ]+ss mov                %ds:\(%ebp\), %eax
+[      ]*26[   ]+\?\?\?\? 3E8B4500[    ]+ds mov                %ss:\(%ebp\), %eax
+[      ]*27[   ]+\?\?\?\? 3E8B4500[    ]+ds mov                %ds:\(%ebp\), %eax
+[      ]*28[   ]*
+#pass
index 1ffdff1325035ec80d9c730b80a7636059da954f..a4382a2b616117150205458f45efdba769fb5589 100644 (file)
@@ -20,4 +20,10 @@ prefix:
        data16 vaddps   %xmm0, %xmm0, %xmm0
        data16 vaddpd   %xmm0, %xmm0, %xmm0
 
+.Lsegment:
+       ss mov          %ss:(%ebp), %eax
+       ss mov          %ds:(%ebp), %eax
+       ds mov          %ss:(%ebp), %eax
+       ds mov          %ds:(%ebp), %eax
+
        .p2align        4,0