MIPS16/GAS: Disallow EXTEND delay-slot scheduling
authorMaciej W. Rozycki <macro@imgtec.com>
Fri, 23 Dec 2016 12:37:40 +0000 (12:37 +0000)
committerMaciej W. Rozycki <macro@imgtec.com>
Fri, 23 Dec 2016 19:25:44 +0000 (19:25 +0000)
Do not allow any explicitly coded EXTEND instruction to be automatically
scheduled into a jump delay slot, as an EXTEND prefix is coupled with
the next regular MIPS16 instruction and therefore swapping it with a
jump would change program's semantics; EXTEND is not architecturally
allowed to be present in a jump delay slot anyway.

opcodes/
* mips16-opc.c (mips16_opcodes): Set NODS in `pinfo' for
"extend".

gas/
* testsuite/gas/mips/mips16-extend-swap.d: New test.
* testsuite/gas/mips/mips16-extend-swap.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new test.

gas/ChangeLog
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16-extend-swap.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-extend-swap.s [new file with mode: 0644]
opcodes/ChangeLog
opcodes/mips16-opc.c

index d78c57d0941a2f9a9a11ed99dc0d6e9bb0bc9e52..53fa95280ccd2fb302caf3517419819a6c488558 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-23  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * testsuite/gas/mips/mips16-extend-swap.d: New test.
+       * testsuite/gas/mips/mips16-extend-swap.s: New test source.
+       * testsuite/gas/mips/mips.exp: Run the new test.
+
 2016-12-23  Joe Seymour  <joe.s@somniumtech.com>
 
        * config/tc-msp430.c (msp430_mcu_data): Sync with data from TI's
index cd62e446ec91c2e1908c2365c0a1669f7a56ed58..c16891ad6984a9b15c0c9a72984529069b1f23a2 100644 (file)
@@ -1341,6 +1341,7 @@ if { [istarget mips*-*-vxworks*] } {
     run_list_test "mips16e-save-err" "-march=mips32 -32"
     run_dump_test "mips16-intermix"
     run_dump_test "mips16-extend"
+    run_dump_test "mips16-extend-swap"
     run_dump_test "mips16-sprel-swap"
     run_dump_test "mips16-sdrasp"
 
diff --git a/gas/testsuite/gas/mips/mips16-extend-swap.d b/gas/testsuite/gas/mips/mips16-extend-swap.d
new file mode 100644 (file)
index 0000000..eb9dd73
--- /dev/null
@@ -0,0 +1,22 @@
+#objdump: -d --prefix-addresses --show-raw-insn
+#name: MIPS16 jump delay slot scheduling for EXTEND instructions
+#as: -32
+
+# Verify that EXTEND instructions are not scheduled into a jump delay slot.
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> f123         extend  0x123
+[0-9a-f]+ <[^>]*> 1800 0000    jal     00000000 <foo>
+[0-9a-f]+ <[^>]*> 6500         nop
+[0-9a-f]+ <[^>]*> f123         extend  0x123
+[0-9a-f]+ <[^>]*> 1c00 0000    jalx    00000000 <foo>
+[0-9a-f]+ <[^>]*> 6500         nop
+[0-9a-f]+ <[^>]*> f123 eb00    jr      v1
+[0-9a-f]+ <[^>]*> 6500         nop
+[0-9a-f]+ <[^>]*> f123 e820    jr      ra
+[0-9a-f]+ <[^>]*> 6500         nop
+[0-9a-f]+ <[^>]*> f123 eb40    jalr    v1
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-extend-swap.s b/gas/testsuite/gas/mips/mips16-extend-swap.s
new file mode 100644 (file)
index 0000000..c299cf1
--- /dev/null
@@ -0,0 +1,21 @@
+       .set    mips1
+       .set    mips16
+foo:
+       extend  0x123
+       jal     bar
+
+       extend  0x123
+       jalx    baz
+
+       extend  0x123
+       jr      $3
+
+       extend  0x123
+       jr      $31
+
+       extend  0x123
+       jalr    $3
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
index 9938992f4ffe1e0909ed8c9402fec09f252ecf70..5166be4fa33d72049eb6601a66e372b12b1dd042 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-23  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * mips16-opc.c (mips16_opcodes): Set NODS in `pinfo' for
+       "extend".
+
 2016-12-23  Maciej W. Rozycki  <macro@imgtec.com>
 
        * mips-dis.c (set_default_mips_dis_options): Use
index 758b78fba62070bf3c47587b210f7cf3750fde68..7d430dd1b972efed7e6465c06455c90aa79ad879 100644 (file)
@@ -357,7 +357,7 @@ const struct mips_opcode mips16_opcodes[] =
 {"zew",            "x",        0xe851, 0xf8ff,         MOD_1,                  0,              I64,    0,      0 },
   /* Place EXTEND last so that it catches any prefix that didn't match
      anything.  */
-{"extend",  "e",       0xf000, 0xf800,         0,                      0,              I1,     0,      0 },
+{"extend",  "e",       0xf000, 0xf800,         NODS,                   0,              I1,     0,      0 },
 };
 
 const int bfd_mips16_num_opcodes =