From: Jan Beulich Date: Thu, 22 Mar 2018 07:33:38 +0000 (+0100) Subject: ix86: allow HLE store of accumulator to absolute address X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1212781b35c9e0080db6ee546cf5e7ebd45d6b09;p=binutils-gdb.git ix86: allow HLE store of accumulator to absolute address Since they're shorter to encode, the 0xa0...0xa3 encodings are preferred for moves between accumulator and absolute address outside of 64-bit mode. With HLE release semantics this encoding is unsupported though, with the assembler raising an error. The operation is valid though, we merely need to pick the longer encoding in that case. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 6abb8532342..ace9839f508 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2018-03-22 Jan Beulich + + * config/tc-i386.c (match_template): Special case base opcode + 0xa0 with HLE prefix. + * testsuite/gas/i386/hle.s: Add mov-accumulator-to-disp cases. + * testsuite/gas/i386/hle.d, testsuite/gas/i386/hle-intel.d: + Adjust expectations. + 2018-03-22 Jan Beulich * testsuite/gas/i386/opts.s: Add bndmov cases. diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 8905de4f6a1..1a05f48e661 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5427,6 +5427,14 @@ match_template (char mnem_suffix) && operand_type_equal (&i.types [0], &acc32) && operand_type_equal (&i.types [1], &acc32)) continue; + /* xrelease mov %eax, is another special case. It must not + match the accumulator-only encoding of mov. */ + if (flag_code != CODE_64BIT + && i.hle_prefix + && t->base_opcode == 0xa0 + && i.types[0].bitfield.acc + && operand_type_check (i.types[1], anymem)) + continue; /* If we want store form, we reverse direction of operands. */ if (i.dir_encoding == dir_encoding_store && t->opcode_modifier.d) diff --git a/gas/testsuite/gas/i386/hle-intel.d b/gas/testsuite/gas/i386/hle-intel.d index 0caf954beed..696e8727917 100644 --- a/gas/testsuite/gas/i386/hle-intel.d +++ b/gas/testsuite/gas/i386/hle-intel.d @@ -321,6 +321,7 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f0 f2 20 01 lock xacquire and BYTE PTR \[ecx\],al [ ]*[a-f0-9]+: f0 f3 20 01 lock xrelease and BYTE PTR \[ecx\],al [ ]*[a-f0-9]+: f3 88 01 xrelease mov BYTE PTR \[ecx\],al +[ ]*[a-f0-9]+: f3 88 05 78 56 34 12 xrelease mov BYTE PTR ds:0x12345678,al [ ]*[a-f0-9]+: f2 f0 08 01 xacquire lock or BYTE PTR \[ecx\],al [ ]*[a-f0-9]+: f2 f0 08 01 xacquire lock or BYTE PTR \[ecx\],al [ ]*[a-f0-9]+: f3 f0 08 01 xrelease lock or BYTE PTR \[ecx\],al @@ -372,6 +373,7 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f0 f2 66 21 01 lock xacquire and WORD PTR \[ecx\],ax [ ]*[a-f0-9]+: f0 f3 66 21 01 lock xrelease and WORD PTR \[ecx\],ax [ ]*[a-f0-9]+: 66 f3 89 01 xrelease mov WORD PTR \[ecx\],ax +[ ]*[a-f0-9]+: 66 f3 89 05 78 56 34 12 xrelease mov WORD PTR ds:0x12345678,ax [ ]*[a-f0-9]+: 66 f2 f0 09 01 xacquire lock or WORD PTR \[ecx\],ax [ ]*[a-f0-9]+: 66 f2 f0 09 01 xacquire lock or WORD PTR \[ecx\],ax [ ]*[a-f0-9]+: 66 f3 f0 09 01 xrelease lock or WORD PTR \[ecx\],ax @@ -423,6 +425,7 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f0 f2 21 01 lock xacquire and DWORD PTR \[ecx\],eax [ ]*[a-f0-9]+: f0 f3 21 01 lock xrelease and DWORD PTR \[ecx\],eax [ ]*[a-f0-9]+: f3 89 01 xrelease mov DWORD PTR \[ecx\],eax +[ ]*[a-f0-9]+: f3 89 05 78 56 34 12 xrelease mov DWORD PTR ds:0x12345678,eax [ ]*[a-f0-9]+: f2 f0 09 01 xacquire lock or DWORD PTR \[ecx\],eax [ ]*[a-f0-9]+: f2 f0 09 01 xacquire lock or DWORD PTR \[ecx\],eax [ ]*[a-f0-9]+: f3 f0 09 01 xrelease lock or DWORD PTR \[ecx\],eax diff --git a/gas/testsuite/gas/i386/hle.d b/gas/testsuite/gas/i386/hle.d index bf7bdcff293..96b620fc482 100644 --- a/gas/testsuite/gas/i386/hle.d +++ b/gas/testsuite/gas/i386/hle.d @@ -320,6 +320,7 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f0 f2 20 01 lock xacquire and %al,\(%ecx\) [ ]*[a-f0-9]+: f0 f3 20 01 lock xrelease and %al,\(%ecx\) [ ]*[a-f0-9]+: f3 88 01 xrelease mov %al,\(%ecx\) +[ ]*[a-f0-9]+: f3 88 05 78 56 34 12 xrelease mov %al,0x12345678 [ ]*[a-f0-9]+: f2 f0 08 01 xacquire lock or %al,\(%ecx\) [ ]*[a-f0-9]+: f2 f0 08 01 xacquire lock or %al,\(%ecx\) [ ]*[a-f0-9]+: f3 f0 08 01 xrelease lock or %al,\(%ecx\) @@ -371,6 +372,7 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f0 f2 66 21 01 lock xacquire and %ax,\(%ecx\) [ ]*[a-f0-9]+: f0 f3 66 21 01 lock xrelease and %ax,\(%ecx\) [ ]*[a-f0-9]+: 66 f3 89 01 xrelease mov %ax,\(%ecx\) +[ ]*[a-f0-9]+: 66 f3 89 05 78 56 34 12 xrelease mov %ax,0x12345678 [ ]*[a-f0-9]+: 66 f2 f0 09 01 xacquire lock or %ax,\(%ecx\) [ ]*[a-f0-9]+: 66 f2 f0 09 01 xacquire lock or %ax,\(%ecx\) [ ]*[a-f0-9]+: 66 f3 f0 09 01 xrelease lock or %ax,\(%ecx\) @@ -422,6 +424,7 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f0 f2 21 01 lock xacquire and %eax,\(%ecx\) [ ]*[a-f0-9]+: f0 f3 21 01 lock xrelease and %eax,\(%ecx\) [ ]*[a-f0-9]+: f3 89 01 xrelease mov %eax,\(%ecx\) +[ ]*[a-f0-9]+: f3 89 05 78 56 34 12 xrelease mov %eax,0x12345678 [ ]*[a-f0-9]+: f2 f0 09 01 xacquire lock or %eax,\(%ecx\) [ ]*[a-f0-9]+: f2 f0 09 01 xacquire lock or %eax,\(%ecx\) [ ]*[a-f0-9]+: f3 f0 09 01 xrelease lock or %eax,\(%ecx\) diff --git a/gas/testsuite/gas/i386/hle.s b/gas/testsuite/gas/i386/hle.s index 1fffa9e7a4e..1beddc458f5 100644 --- a/gas/testsuite/gas/i386/hle.s +++ b/gas/testsuite/gas/i386/hle.s @@ -331,6 +331,7 @@ _start: .byte 0xf0; .byte 0xf2; andb %al,(%ecx) .byte 0xf0; .byte 0xf3; andb %al,(%ecx) xrelease movb %al,(%ecx) + xrelease movb %al,0x12345678 xacquire lock orb %al,(%ecx) lock xacquire orb %al,(%ecx) xrelease lock orb %al,(%ecx) @@ -385,6 +386,7 @@ _start: .byte 0xf0; .byte 0xf2; andw %ax,(%ecx) .byte 0xf0; .byte 0xf3; andw %ax,(%ecx) xrelease movw %ax,(%ecx) + xrelease movw %ax,0x12345678 xacquire lock orw %ax,(%ecx) lock xacquire orw %ax,(%ecx) xrelease lock orw %ax,(%ecx) @@ -439,6 +441,7 @@ _start: .byte 0xf0; .byte 0xf2; andl %eax,(%ecx) .byte 0xf0; .byte 0xf3; andl %eax,(%ecx) xrelease movl %eax,(%ecx) + xrelease movl %eax,0x12345678 xacquire lock orl %eax,(%ecx) lock xacquire orl %eax,(%ecx) xrelease lock orl %eax,(%ecx)