x86/Intel: don't mistake riz/eiz as base register
authorJan Beulich <jbeulich@novell.com>
Mon, 13 Nov 2017 11:20:30 +0000 (12:20 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 13 Nov 2017 11:20:30 +0000 (12:20 +0100)
Just like we make rsp/esp a base register even if it comes second, make
riz/eiz an index register even if it comes first.

gas/ChangeLog
gas/config/tc-i386-intel.c
gas/testsuite/gas/i386/intel.d
gas/testsuite/gas/i386/intel.s

index 2c63aaa31f78281baf0a26ec8467e1a0390c1535..d18c381843e957e5260b633cf9cdf4ee45253a8a 100644 (file)
@@ -1,3 +1,11 @@
+2017-11-13  Jan Beulich  <jbeulich@suse.com>
+
+       * config/tc-i386-intel.c (i386_intel_simplify_register): Also
+       recognize RegRiz/RegEiz as index-only registers.
+       * testsuite/gas/i386/intel.s: Add tests exercising base/index
+       swapping.
+       * testsuite/gas/i386/intel.d: Adjust expectations.
+
 2017-11-13  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-i386.c (i386_index_check): Break out ...
index 36ae8189edd17ac62ffe23e0cb2da964ffa92687..b8874e4b8dd79db0705f2c6ba6344104eb72264b 100644 (file)
@@ -288,7 +288,9 @@ i386_intel_simplify_register (expressionS *e)
   else if (!intel_state.index
           && (i386_regtab[reg_num].reg_type.bitfield.regxmm
               || i386_regtab[reg_num].reg_type.bitfield.regymm
-              || i386_regtab[reg_num].reg_type.bitfield.regzmm))
+              || i386_regtab[reg_num].reg_type.bitfield.regzmm
+              || i386_regtab[reg_num].reg_num == RegRiz
+              || i386_regtab[reg_num].reg_num == RegEiz))
     intel_state.index = i386_regtab + reg_num;
   else if (!intel_state.base && !intel_state.in_scale)
     intel_state.base = i386_regtab + reg_num;
index d10b4f00bb499898763b711558a11dfc202b015d..836acd601dc5cfe969d6e106e34281af1bb94902 100644 (file)
@@ -698,6 +698,9 @@ Disassembly of section .text:
 [      ]*[a-f0-9]+:    0f 4b 90 90 90 90 90    cmovnp -0x6f6f6f70\(%eax\),%edx
 [      ]*[a-f0-9]+:    66 0f 4a 90 90 90 90 90         cmovp  -0x6f6f6f70\(%eax\),%dx
 [      ]*[a-f0-9]+:    66 0f 4b 90 90 90 90 90         cmovnp -0x6f6f6f70\(%eax\),%dx
+[      ]*[a-f0-9]+:    8b 04 04                mov    \(%esp,%eax(,1)?\),%eax
+[      ]*[a-f0-9]+:    8b 04 20                mov    \(%eax(,%eiz)?(,1)?\),%eax
+[      ]*[a-f0-9]+:    c4 e2 69 92 04 08       vgatherdps %xmm2,\(%eax,%xmm1(,1)?\),%xmm0
 [      ]*[a-f0-9]+:    24 2f                   and    \$0x2f,%al
 [      ]*[a-f0-9]+:    0f                      \.byte 0xf
 [a-f0-9]+ <barn>:
index 045d6ae0fd0a57251b858010e7eadeb995f9ffcf..813daaa60df87ac705578eb3281d96925439a8f2 100644 (file)
@@ -699,6 +699,12 @@ fidivr  dword ptr [ebx]
  cmovpe  dx, 0x90909090[eax]
  cmovpo dx, 0x90909090[eax]
 
+ # Check base/index swapping
+       .allow_index_reg
+ mov    eax, [eax+esp]
+ mov    eax, [eiz+eax]
+ vgatherdps xmm0, [xmm1+eax], xmm2
+
        # Test that disassembly of a partial instruction shows the partial byte:
        # https://www.sourceware.org/ml/binutils/2015-08/msg00226.html
        .byte 0x24