This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed] MIPS hazards at the end of a file
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 29 Jun 2011 21:35:08 +0100
- Subject: [committed] MIPS hazards at the end of a file
Oops. I forgot about the alignment differences between traditional and
non-traditional MIPS targets when doing the recent 24k patch. It turns
out that the extra alignment was causing bogus passes on mips*-linux-gnu,
and that the tests were still failing on mips*-elf* targets.
As I said in the previous message, the idea is that we should assume
the worst whenever we lose track of what the next instruction is.
This includes branch targets, section switches, and run-through
to the end of file.
It turns out that we don't actually handle the last case properly.
If a potential hazard comes at the end of a file, such as:
mflo $4
on targets without hi/lo interlocks, then we won't emit the required
nops. However, if we follow it with a spurious section switch (a case
we do handle correctly) then everything is fine:
mflo $4
.data
This seems to be a very long-standing bug that even affects the
old MIPS I tests.
Fixed with the patch below. Tested on:
mips64-elf mips64el-unknown-kfreebsd-gnu mips64-linux-gnu
mips64octeon-linux-gnu mips64-unknown-kfreebsd-gnu
mipsel-unknown-kfreebsd-gnu mipsisa32el-linux-gnu
mipsisa64-elf mips-linux-gnu mips-sgi-irix6.5
mips-unknown-kfreebsd-gnu mips-wrs-vxworks
and applied.
Richard
gas/
* config/tc-mips.c (md_mips_end): Call mips_emit_delays.
gas/testsuite/
* gas/mips/24k-triple-stores-9.d: Add -z to dump options and
explicitly match one nop.
* gas/mips/24k-triple-stores-10.d: Likewise.
* gas/mips/24k-triple-stores-11.d: Likewise.
* gas/mips/lifloat.d: Likewise.
* gas/mips/trunc.d: Likewise 1 extra nop.
* gas/mips/vr4111.d: Likewise 2 nops.
Index: gas/config/tc-mips.c
===================================================================
--- gas/config/tc-mips.c 2011-06-29 20:30:08.000000000 +0100
+++ gas/config/tc-mips.c 2011-06-29 21:25:16.000000000 +0100
@@ -2111,6 +2111,7 @@ md_begin (void)
void
md_mips_end (void)
{
+ mips_emit_delays ();
if (! ECOFF_DEBUGGING)
md_obj_end ();
}
Index: gas/testsuite/gas/mips/24k-triple-stores-9.d
===================================================================
--- gas/testsuite/gas/mips/24k-triple-stores-9.d 2011-06-29 20:04:35.000000000 +0100
+++ gas/testsuite/gas/mips/24k-triple-stores-9.d 2011-06-29 20:36:48.000000000 +0100
@@ -1,4 +1,4 @@
-#objdump: -dr
+#objdump: -drz
#as: -mfix-24k -32
#name: 24K: Triple store (Intervening data #1)
@@ -12,4 +12,5 @@ Disassembly of section .text:
8: a1030008 sb v1,8\(t0\)
c: 00000000 nop
10: a1040010 sb a0,16\(t0\)
- \.\.\.
+ 14: 00000000 nop
+#pass
Index: gas/testsuite/gas/mips/24k-triple-stores-10.d
===================================================================
--- gas/testsuite/gas/mips/24k-triple-stores-10.d 2011-06-29 20:04:35.000000000 +0100
+++ gas/testsuite/gas/mips/24k-triple-stores-10.d 2011-06-29 20:34:18.000000000 +0100
@@ -1,4 +1,4 @@
-#objdump: -dr
+#objdump: -dr -z
#as: -mfix-24k -32
#name: 24K: Triple Store (Intervening data #2)
@@ -10,4 +10,5 @@ Disassembly of section .text:
4: a1030008 sb v1,8\(t0\)
8: 00000000 nop
c: a1040010 sb a0,16\(t0\)
- \.\.\.
+ 10: 00000000 nop
+#pass
Index: gas/testsuite/gas/mips/24k-triple-stores-11.d
===================================================================
--- gas/testsuite/gas/mips/24k-triple-stores-11.d 2011-06-29 20:32:32.000000000 +0100
+++ gas/testsuite/gas/mips/24k-triple-stores-11.d 2011-06-29 20:36:45.000000000 +0100
@@ -1,4 +1,4 @@
-#objdump: -d
+#objdump: -dz
#as: -mfix-24k -32
#name: 24K: Triple Store (gprel relocs)
@@ -14,4 +14,5 @@ Disassembly of section .text:
14: af830000 sw v1,0\(gp\)
18: 00000000 nop
1c: af840000 sw a0,0\(gp\)
-
+ 20: 00000000 nop
+#pass
Index: gas/testsuite/gas/mips/lifloat.d
===================================================================
--- gas/testsuite/gas/mips/lifloat.d 2011-06-29 20:37:19.000000000 +0100
+++ gas/testsuite/gas/mips/lifloat.d 2011-06-29 20:37:36.000000000 +0100
@@ -1,4 +1,4 @@
-#objdump: -dr --prefix-addresses -mmips:3000
+#objdump: -drz --prefix-addresses -mmips:3000
#name: MIPS lifloat
#as: -32 -mips1
@@ -21,3 +21,5 @@ Disassembly of section .text:
0+0018 <[^>]*> ori a0,a0,0xcd36
0+001c <[^>]*> lwc1 \$f4,[-0-9]+\(gp\)
[ ]*1c: [A-Z0-9_]*LITERAL[A-Z0-9_]* .lit4.*
+0+0020 <[^>]*> nop
+#pass
Index: gas/testsuite/gas/mips/trunc.d
===================================================================
--- gas/testsuite/gas/mips/trunc.d 2011-06-29 20:37:51.000000000 +0100
+++ gas/testsuite/gas/mips/trunc.d 2011-06-29 20:38:43.000000000 +0100
@@ -1,4 +1,4 @@
-#objdump: -dr --prefix-addresses -mmips:3000
+#objdump: -drz --prefix-addresses -mmips:3000
#name: MIPS trunc
#as: -32 -mips1 -mtune=r3000
@@ -27,3 +27,5 @@ Disassembly of section .text:
0+0044 <[^>]*> cvt.w.s \$f4,\$f6
0+0048 <[^>]*> ctc1 a0,\$31
0+004c <[^>]*> nop
+0+0050 <[^>]*> nop
+#pass
Index: gas/testsuite/gas/mips/vr4111.d
===================================================================
--- gas/testsuite/gas/mips/vr4111.d 2011-06-29 20:39:00.000000000 +0100
+++ gas/testsuite/gas/mips/vr4111.d 2011-06-29 20:42:10.000000000 +0100
@@ -1,4 +1,4 @@
-#objdump: -dr
+#objdump: -drz
#name: MIPS VR4111
#as: -march=vr4111
@@ -7,5 +7,9 @@
Disassembly of section \.text:
0+000 <\.text>:
+ 0: 00850029 dmadd16 a0,a1
- \.\.\.
+ + 4: 00000000 nop
+ + 8: 00000000 nop
+ c: 00a60028 madd16 a1,a2
+ +10: 00000000 nop
+ +14: 00000000 nop
+#pass