gas/
authorMaciej W. Rozycki <macro@linux-mips.org>
Mon, 6 Aug 2012 20:33:00 +0000 (20:33 +0000)
committerMaciej W. Rozycki <macro@linux-mips.org>
Mon, 6 Aug 2012 20:33:00 +0000 (20:33 +0000)
* config/tc-mips.c (append_insn): Also handle moving delay-slot
instruction across frags for fixed branches.

gas/testsuite/
* gas/mips/branch-swap-2.l: New list test.
* gas/mips/branch-swap-2.s: New test source.
* gas/mips/mips.exp: Run the new test.

gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/ChangeLog
gas/testsuite/gas/mips/branch-swap-2.l [new file with mode: 0644]
gas/testsuite/gas/mips/branch-swap-2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp

index 0ed4312..9597f5e 100644 (file)
@@ -1,3 +1,8 @@
+2012-08-06  Maciej W. Rozycki  <macro@codesourcery.com>
+
+       * config/tc-mips.c (append_insn): Also handle moving delay-slot
+       instruction across frags for fixed branches.
+
 2012-08-03  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * frags.c (frag_grow): Never shrink the obstack size requested
index a9bd0d8..fa78840 100644 (file)
@@ -4488,7 +4488,7 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr,
            move_insn (ip, delay.frag, delay.where);
            move_insn (&delay, ip->frag, ip->where + insn_length (ip));
          }
-       else if (relaxed_branch)
+       else if (relaxed_branch || delay.frag != ip->frag)
          {
            /* Add the delay slot instruction to the end of the
               current frag and shrink the fixed part of the
index fd73cce..33ddd17 100644 (file)
@@ -1,3 +1,9 @@
+2012-08-06  Maciej W. Rozycki  <macro@codesourcery.com>
+
+       * gas/mips/branch-swap-2.l: New list test.
+       * gas/mips/branch-swap-2.s: New test source.
+       * gas/mips/mips.exp: Run the new test.
+
 2012-08-06  Roland McGrath  <mcgrathr@google.com>
 
        * gas/i386/x86-64-stack.s: Add cases for push immediate.
diff --git a/gas/testsuite/gas/mips/branch-swap-2.l b/gas/testsuite/gas/mips/branch-swap-2.l
new file mode 100644 (file)
index 0000000..36a0971
--- /dev/null
@@ -0,0 +1 @@
+# No warnings or errors expected!
diff --git a/gas/testsuite/gas/mips/branch-swap-2.s b/gas/testsuite/gas/mips/branch-swap-2.s
new file mode 100644 (file)
index 0000000..9fe21d1
--- /dev/null
@@ -0,0 +1,8 @@
+       .set    micromips
+       .text
+foo:
+       .rept   count
+       ori     $2, $3, (. - foo) >> 2
+       .endr
+       addu    $2, $3, $4
+       j       ext
index b88782f..cc44e62 100644 (file)
@@ -505,6 +505,20 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test_arches "branch-misc-2pic-64" [mips_arch_list_matching mips3]
     run_dump_test "branch-misc-3"
     run_dump_test "branch-swap"
+
+    if $elf {
+       # Sweep a range of branch offsets so that it hits a position where
+       # it is at the beginning of a frag and then swapped with a 16-bit
+       # instruction from the preceding frag.  The offset will be somewhere
+       # close below 4096 as this is the default obstack size limit that
+       # we use and some space will have been already consumed.  The exact
+       # amount depends on the host's programming model.
+       for { set count 960 } { $count <= 1024 } { incr count } {
+           run_list_test "branch-swap-2" "--defsym count=$count" \
+               "MIPS branch swapping ($count)"
+       }
+    }
+
     run_dump_test "div"
 
     if { !$addr32 } {