From 464ab0e55ade01d2bb0b4fa45c429af7a2f85a26 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Mon, 6 Aug 2012 20:33:00 +0000 Subject: [PATCH] gas/ * 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 | 5 +++++ gas/config/tc-mips.c | 2 +- gas/testsuite/ChangeLog | 6 ++++++ gas/testsuite/gas/mips/branch-swap-2.l | 1 + gas/testsuite/gas/mips/branch-swap-2.s | 8 ++++++++ gas/testsuite/gas/mips/mips.exp | 14 ++++++++++++++ 6 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/mips/branch-swap-2.l create mode 100644 gas/testsuite/gas/mips/branch-swap-2.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 0ed4312..9597f5e 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2012-08-06 Maciej W. Rozycki + + * config/tc-mips.c (append_insn): Also handle moving delay-slot + instruction across frags for fixed branches. + 2012-08-03 Maciej W. Rozycki * frags.c (frag_grow): Never shrink the obstack size requested diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index a9bd0d8..fa78840 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -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 diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index fd73cce..33ddd17 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-08-06 Maciej W. Rozycki + + * 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 * 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 index 0000000..36a0971 --- /dev/null +++ b/gas/testsuite/gas/mips/branch-swap-2.l @@ -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 index 0000000..9fe21d1 --- /dev/null +++ b/gas/testsuite/gas/mips/branch-swap-2.s @@ -0,0 +1,8 @@ + .set micromips + .text +foo: + .rept count + ori $2, $3, (. - foo) >> 2 + .endr + addu $2, $3, $4 + j ext diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index b88782f..cc44e62 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -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 } { -- 2.7.4