* [PATCH] x86 gas: allow 'rep nop'
@ 2012-07-02 16:39 Roland McGrath
2012-07-02 17:10 ` H.J. Lu
2012-07-03 7:01 ` Jan Beulich
0 siblings, 2 replies; 5+ messages in thread
From: Roland McGrath @ 2012-07-02 16:39 UTC (permalink / raw)
To: binutils
There is another 'rep;INSN' form that GCC likes to emit, this one
'rep;nop' as an alias for 'pause'. It's nicer to accept 'rep nop'
for this one too.
Ok for trunk?
Thanks,
Roland
gas/testsuite/
2012-07-02 Roland McGrath <mcgrathr@google.com>
* gas/i386/rep-nop.d: New file.
* gas/i386/rep-nop.s: New file.
* gas/i386/i386.exp: Add the new test.
opcodes/
2012-07-02 Roland McGrath <mcgrathr@google.com>
* i386-opc.tbl: Add RepPrefixOk to nop.
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 0049000..a954088 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -266,6 +266,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "pr12589-1"
run_dump_test "rep-bsf"
run_dump_test "rep-ret"
+ run_dump_test "rep-nop"
set ASFLAGS "$old_ASFLAGS"
}
diff --git a/gas/testsuite/gas/i386/rep-nop.d b/gas/testsuite/gas/i386/rep-nop.d
new file mode 100644
index 0000000..a269c6e
--- /dev/null
+++ b/gas/testsuite/gas/i386/rep-nop.d
@@ -0,0 +1,10 @@
+#objdump: -d
+#name: rep prefix on nop
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+000 <foo>:
+\s*[0-9a-f]+:\s+f3 90\s+pause\s*
+ \.\.\.
diff --git a/gas/testsuite/gas/i386/rep-nop.s b/gas/testsuite/gas/i386/rep-nop.s
new file mode 100644
index 0000000..ed9d5ad
--- /dev/null
+++ b/gas/testsuite/gas/i386/rep-nop.s
@@ -0,0 +1,3 @@
+ .text
+foo: rep nop
+ .p2align 4,0
diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
index 7de61a7..54cc0d1 100644
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -504,7 +504,7 @@ nop, 1, 0xf1f, 0x0, 2, CpuNop, Modrm|No_bSuf|No_sSuf|No_ldSuf, { Reg16|Reg32|Reg
// nop is actually "xchg %ax,%ax" in 16bit mode, "xchg %eax,%eax" in
// 32bit mode and "xchg %rax,%rax" in 64bit mode.
-nop, 0, 0x90, None, 1, 0, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { 0 }
+nop, 0, 0x90, None, 1, 0, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf|RepPrefixOk, { 0 }
// Protection control.
arpl, 2, 0x63, None, 1, Cpu286|CpuNo64, Modrm|IgnoreSize|No_bSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { Reg16, Reg16|Word|Unspecified|BaseIndex|Disp8|Disp16|Disp32 }
diff --git a/opcodes/i386-tbl.h b/opcodes/i386-tbl.h
index 89dfda4..2248c7b 100644
--- a/opcodes/i386-tbl.h
+++ b/opcodes/i386-tbl.h
@@ -4142,7 +4142,7 @@ const insn_template i386_optab[] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86 gas: allow 'rep nop'
2012-07-02 16:39 [PATCH] x86 gas: allow 'rep nop' Roland McGrath
@ 2012-07-02 17:10 ` H.J. Lu
2012-07-02 18:13 ` Roland McGrath
2012-07-03 7:01 ` Jan Beulich
1 sibling, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2012-07-02 17:10 UTC (permalink / raw)
To: Roland McGrath; +Cc: binutils
On Mon, Jul 2, 2012 at 9:39 AM, Roland McGrath <mcgrathr@google.com> wrote:
> There is another 'rep;INSN' form that GCC likes to emit, this one
> 'rep;nop' as an alias for 'pause'. It's nicer to accept 'rep nop'
> for this one too.
>
> Ok for trunk?
>
>
> Thanks,
> Roland
>
>
> gas/testsuite/
> 2012-07-02 Roland McGrath <mcgrathr@google.com>
>
> * gas/i386/rep-nop.d: New file.
> * gas/i386/rep-nop.s: New file.
> * gas/i386/i386.exp: Add the new test.
>
> opcodes/
> 2012-07-02 Roland McGrath <mcgrathr@google.com>
>
> * i386-opc.tbl: Add RepPrefixOk to nop.
>
I checked in a patch:
http://sourceware.org/ml/binutils/2012-07/msg00019.html
to move rep tests for bsf/bsr/ret to rep-suffix. Please add the
rep nop test to both rep-suffix.s and x86-64-rep-suffix.s. OK
with this change.
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86 gas: allow 'rep nop'
2012-07-02 17:10 ` H.J. Lu
@ 2012-07-02 18:13 ` Roland McGrath
0 siblings, 0 replies; 5+ messages in thread
From: Roland McGrath @ 2012-07-02 18:13 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
On Mon, Jul 2, 2012 at 10:10 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> Please add the rep nop test to both rep-suffix.s and x86-64-rep-suffix.s.
> OK with this change.
I've committed it as follows.
Thanks,
Roland
gas/testsuite/
2012-07-02 Roland McGrath <mcgrathr@google.com>
* gas/i386/rep-suffix.s: Add 'rep nop' case.
* gas/i386/x86-64-rep-suffix.s: Likewise.
* gas/i386/rep-suffix.d: Updated.
* gas/i386/x86-64-rep-suffix.d: Likewise.
* gas/i386/ilp32/x86-64-rep-suffix.d: Likewise.
opcodes/
2012-07-02 Roland McGrath <mcgrathr@google.com>
* i386-opc.tbl: Add RepPrefixOk to nop.
* i386-tbl.h: Regenerate.
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-rep-suffix.d
b/gas/testsuite/gas/i386/ilp32/x86-64-rep-suffix.d
index 241365d..19bb585 100644
--- a/gas/testsuite/gas/i386/ilp32/x86-64-rep-suffix.d
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-rep-suffix.d
@@ -17,5 +17,6 @@ Disassembly of section .text:
11: f3 48 ab[ ]+rep stosq %rax,%es:\(%rdi\)
14: f3 0f bc c1[ ]+tzcntl %ecx,%eax
18: f3 0f bd c1[ ]+lzcntl %ecx,%eax
- 1c: f3 c3[ ]+repz retq
+ 1c: f3 c3[ ]+repz retq\s*
+ 1e: f3 90[ ]+pause\s*
#pass
diff --git a/gas/testsuite/gas/i386/rep-suffix.d
b/gas/testsuite/gas/i386/rep-suffix.d
index 81f8d61..08e02d7 100644
--- a/gas/testsuite/gas/i386/rep-suffix.d
+++ b/gas/testsuite/gas/i386/rep-suffix.d
@@ -14,5 +14,6 @@ Disassembly of section .text:
c: f3 ab[ ]+rep stosl %eax,%es:\(%edi\)
e: f3 0f bc c1[ ]+tzcntl %ecx,%eax
12: f3 0f bd c1[ ]+lzcntl %ecx,%eax
- 16: f3 c3[ ]+repz retl
+ 16: f3 c3[ ]+repz retl\s*
+ 18: f3 90[ ]+pause\s*
#pass
diff --git a/gas/testsuite/gas/i386/rep-suffix.s
b/gas/testsuite/gas/i386/rep-suffix.s
index 6f53663..12bdbd0 100644
--- a/gas/testsuite/gas/i386/rep-suffix.s
+++ b/gas/testsuite/gas/i386/rep-suffix.s
@@ -12,3 +12,5 @@ _start:
rep bsr %ecx, %eax
rep ret
+
+ rep nop
diff --git a/gas/testsuite/gas/i386/x86-64-rep-suffix.d
b/gas/testsuite/gas/i386/x86-64-rep-suffix.d
index 3c3f7ea..bc6346d 100644
--- a/gas/testsuite/gas/i386/x86-64-rep-suffix.d
+++ b/gas/testsuite/gas/i386/x86-64-rep-suffix.d
@@ -16,5 +16,6 @@ Disassembly of section .text:
11: f3 48 ab[ ]+rep stosq %rax,%es:\(%rdi\)
14: f3 0f bc c1[ ]+tzcntl %ecx,%eax
18: f3 0f bd c1[ ]+lzcntl %ecx,%eax
- 1c: f3 c3[ ]+repz retq
+ 1c: f3 c3[ ]+repz retq\s*
+ 1e: f3 90[ ]+pause\s*
#pass
diff --git a/gas/testsuite/gas/i386/x86-64-rep-suffix.s
b/gas/testsuite/gas/i386/x86-64-rep-suffix.s
index 43d71cf..94df9e5 100644
--- a/gas/testsuite/gas/i386/x86-64-rep-suffix.s
+++ b/gas/testsuite/gas/i386/x86-64-rep-suffix.s
@@ -14,3 +14,5 @@ _start:
rep bsr %ecx, %eax
rep ret
+
+ rep nop
diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
index 7de61a7..54cc0d1 100644
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -504,7 +504,7 @@ nop, 1, 0xf1f, 0x0, 2, CpuNop,
Modrm|No_bSuf|No_sSuf|No_ldSuf, { Reg16|Reg32|Reg
// nop is actually "xchg %ax,%ax" in 16bit mode, "xchg %eax,%eax" in
// 32bit mode and "xchg %rax,%rax" in 64bit mode.
-nop, 0, 0x90, None, 1, 0,
No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { 0 }
+nop, 0, 0x90, None, 1, 0,
No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf|RepPrefixOk, { 0 }
// Protection control.
arpl, 2, 0x63, None, 1, Cpu286|CpuNo64,
Modrm|IgnoreSize|No_bSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { Reg16,
Reg16|Word|Unspecified|BaseIndex|Disp8|Disp16|Disp32 }
diff --git a/opcodes/i386-tbl.h b/opcodes/i386-tbl.h
index 89dfda4..2248c7b 100644
--- a/opcodes/i386-tbl.h
+++ b/opcodes/i386-tbl.h
@@ -4142,7 +4142,7 @@ const insn_template i386_optab[] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86 gas: allow 'rep nop'
2012-07-02 16:39 [PATCH] x86 gas: allow 'rep nop' Roland McGrath
2012-07-02 17:10 ` H.J. Lu
@ 2012-07-03 7:01 ` Jan Beulich
2012-07-03 16:34 ` Roland McGrath
1 sibling, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2012-07-03 7:01 UTC (permalink / raw)
To: Roland McGrath; +Cc: binutils
>>> On 02.07.12 at 18:39, Roland McGrath <mcgrathr@google.com> wrote:
> There is another 'rep;INSN' form that GCC likes to emit, this one
> 'rep;nop' as an alias for 'pause'. It's nicer to accept 'rep nop'
> for this one too.
As gcc has to detect the respective gas capability anyway, why
can't it use "pause" right away, and then on much older gas
versions too?
Jan
> Ok for trunk?
>
>
> Thanks,
> Roland
>
>
> gas/testsuite/
> 2012-07-02 Roland McGrath <mcgrathr@google.com>
>
> * gas/i386/rep-nop.d: New file.
> * gas/i386/rep-nop.s: New file.
> * gas/i386/i386.exp: Add the new test.
>
> opcodes/
> 2012-07-02 Roland McGrath <mcgrathr@google.com>
>
> * i386-opc.tbl: Add RepPrefixOk to nop.
>
> diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
> index 0049000..a954088 100644
> --- a/gas/testsuite/gas/i386/i386.exp
> +++ b/gas/testsuite/gas/i386/i386.exp
> @@ -266,6 +266,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) &&
> [gas_32_check]]
> run_dump_test "pr12589-1"
> run_dump_test "rep-bsf"
> run_dump_test "rep-ret"
> + run_dump_test "rep-nop"
>
> set ASFLAGS "$old_ASFLAGS"
> }
> diff --git a/gas/testsuite/gas/i386/rep-nop.d b/gas/testsuite/gas/i386/rep-nop.d
> new file mode 100644
> index 0000000..a269c6e
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/rep-nop.d
> @@ -0,0 +1,10 @@
> +#objdump: -d
> +#name: rep prefix on nop
> +
> +.*: +file format .*
> +
> +Disassembly of section .text:
> +
> +0+000 <foo>:
> +\s*[0-9a-f]+:\s+f3 90\s+pause\s*
> + \.\.\.
> diff --git a/gas/testsuite/gas/i386/rep-nop.s b/gas/testsuite/gas/i386/rep-nop.s
> new file mode 100644
> index 0000000..ed9d5ad
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/rep-nop.s
> @@ -0,0 +1,3 @@
> + .text
> +foo: rep nop
> + .p2align 4,0
> diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
> index 7de61a7..54cc0d1 100644
> --- a/opcodes/i386-opc.tbl
> +++ b/opcodes/i386-opc.tbl
> @@ -504,7 +504,7 @@ nop, 1, 0xf1f, 0x0, 2, CpuNop,
> Modrm|No_bSuf|No_sSuf|No_ldSuf, { Reg16|Reg32|Reg
>
> // nop is actually "xchg %ax,%ax" in 16bit mode, "xchg %eax,%eax" in
> // 32bit mode and "xchg %rax,%rax" in 64bit mode.
> -nop, 0, 0x90, None, 1, 0, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf,
> { 0 }
> +nop, 0, 0x90, None, 1, 0,
> No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf|RepPrefixOk, { 0 }
>
> // Protection control.
> arpl, 2, 0x63, None, 1, Cpu286|CpuNo64,
> Modrm|IgnoreSize|No_bSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, { Reg16,
> Reg16|Word|Unspecified|BaseIndex|Disp8|Disp16|Disp32 }
> diff --git a/opcodes/i386-tbl.h b/opcodes/i386-tbl.h
> index 89dfda4..2248c7b 100644
> --- a/opcodes/i386-tbl.h
> +++ b/opcodes/i386-tbl.h
> @@ -4142,7 +4142,7 @@ const insn_template i386_optab[] =
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
> - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
> { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86 gas: allow 'rep nop'
2012-07-03 7:01 ` Jan Beulich
@ 2012-07-03 16:34 ` Roland McGrath
0 siblings, 0 replies; 5+ messages in thread
From: Roland McGrath @ 2012-07-03 16:34 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
On Tue, Jul 3, 2012 at 12:02 AM, Jan Beulich <JBeulich@suse.com> wrote:
> As gcc has to detect the respective gas capability anyway, why
> can't it use "pause" right away, and then on much older gas
> versions too?
It could, it's just that GCC folks prefered to minimize the
conditionalization and just use the %; format specifier they
already had for a sometimes-necessary ; after a 'rep' or 'lock'
prefix.
Thanks,
Roland
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-07-03 16:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-02 16:39 [PATCH] x86 gas: allow 'rep nop' Roland McGrath
2012-07-02 17:10 ` H.J. Lu
2012-07-02 18:13 ` Roland McGrath
2012-07-03 7:01 ` Jan Beulich
2012-07-03 16:34 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).