From 290248614c6058e929e4403124d2cc106d130c83 Mon Sep 17 00:00:00 2001 From: David Ung Date: Wed, 19 Oct 2005 18:47:09 +0000 Subject: [PATCH] * config/tc-mips.c (append_insn): Convert MIPS16 jr/jalr jumps into jrc/jalrc versions if ISA_MIPS32+ and not doing the swap, hence avoiding to emit a nop. * gas/mips/mips.exp: Run new test. * gas/testsuite/gas/mips/mips16e-jrc.s: New test for converting jalr/jr to the compact jalrc/jrc instructions. * gas/testsuite/gas/mips/mips16e-jrc.d: New. --- gas/ChangeLog | 6 ++++++ gas/config/tc-mips.c | 29 ++++++++++++++++++++++------ gas/testsuite/ChangeLog | 7 +++++++ gas/testsuite/gas/mips/mips.exp | 1 + gas/testsuite/gas/mips/mips16e-jrc.d | 14 ++++++++++++++ gas/testsuite/gas/mips/mips16e-jrc.s | 6 ++++++ 6 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 gas/testsuite/gas/mips/mips16e-jrc.d create mode 100644 gas/testsuite/gas/mips/mips16e-jrc.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 234aef89866..4d44caa839d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2005-10-19 David Ung + + * config/tc-mips.c (append_insn): Convert MIPS16 jr/jalr jumps + into jrc/jalrc versions if ISA_MIPS32+ and not doing the swap, + hence avoiding to emit a nop. + 2005-10-19 Jie Zhang * config/tc-bfin.c (md_begin): Let the lex_type of '(' be diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 6e061052cf2..7ae421d2229 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -2693,12 +2693,29 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr, sync.p, we can not swap. */ || (prev_pinfo & INSN_SYNC)) { - /* We could do even better for unconditional branches to - portions of this object file; we could pick up the - instruction at the destination, put it in the delay - slot, and bump the destination address. */ - insert_into_history (0, 1, ip); - emit_nop (); + if (mips_opts.mips16 + && (pinfo & INSN_UNCOND_BRANCH_DELAY) + && (pinfo & (MIPS16_INSN_READ_X | MIPS16_INSN_READ_31)) + && (mips_opts.isa == ISA_MIPS32 + || mips_opts.isa == ISA_MIPS32R2 + || mips_opts.isa == ISA_MIPS64 + || mips_opts.isa == ISA_MIPS64R2)) + { + /* Convert MIPS16 jr/jalr into a "compact" jump. */ + ip->insn_opcode |= 0x0080; + install_insn (ip); + insert_into_history (0, 1, ip); + } + else + { + /* We could do even better for unconditional branches to + portions of this object file; we could pick up the + instruction at the destination, put it in the delay + slot, and bump the destination address. */ + insert_into_history (0, 1, ip); + emit_nop (); + } + if (mips_relax.sequence) mips_relax.sizes[mips_relax.sequence - 1] += 4; } diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 1f4f7423d51..72608106f7f 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2005-10-19 David Ung + + * gas/mips/mips.exp: Run new test. + * gas/testsuite/gas/mips/mips16e-jrc.s: New test for converting + jalr/jr to the compact jalrc/jrc instructions. + * gas/testsuite/gas/mips/mips16e-jrc.d: New. + 2005-10-19 Martin Schwidefsky * gas/s390/zarch-z9-109.s: Add tests for unnormalized hfp multiply diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index 0eba51bd572..c787e4fb88a 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -771,4 +771,5 @@ if { [istarget mips*-*-*] } then { run_dump_test "mips16-dwarf2-n32" } } + if { !$no_mips16 } { run_dump_test "mips16e-jrc" } } diff --git a/gas/testsuite/gas/mips/mips16e-jrc.d b/gas/testsuite/gas/mips/mips16e-jrc.d new file mode 100644 index 00000000000..1a739b52d2c --- /dev/null +++ b/gas/testsuite/gas/mips/mips16e-jrc.d @@ -0,0 +1,14 @@ +#objdump: -dr -mmips:isa32 -mmips:16 +#as: -march=mips32 -mips16 +#name: mips16e jalrc/jrc +.*: file format .* +Disassembly of section .text: +00000000 <.text>: + 0: eac0 jalrc v0 + 2: e8a0 jrc ra + 4: 6a01 li v0,1 + 6: 6500 nop + 8: 6500 nop + a: 6500 nop + c: 6500 nop + e: 6500 nop diff --git a/gas/testsuite/gas/mips/mips16e-jrc.s b/gas/testsuite/gas/mips/mips16e-jrc.s new file mode 100644 index 00000000000..02c83892fee --- /dev/null +++ b/gas/testsuite/gas/mips/mips16e-jrc.s @@ -0,0 +1,6 @@ +# Test the generation of jalrc/jrc opcodes + jalr $31,$2 + jr $31 + li $2,1 + + .p2align 4 -- 2.30.2