From: rsandifo Date: Sun, 1 Jun 2008 10:01:51 +0000 (+0000) Subject: gcc/ X-Git-Tag: upstream/4.9.2~41716 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=250b65e69dbc6117f5bce37c660138876e30ee17;p=platform%2Fupstream%2Flinaro-gcc.git gcc/ * config/mips/mips-protos.h (mips_expand_before_return): Declare. * config/mips/mips.c (mips_expand_before_return): New function. (mips_expand_epilogue): Call it. * config/mips/mips.md (return): Turn into a define_expand. (*return): New insn. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@136252 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e990443..624d338 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2008-06-01 Richard Sandiford + * config/mips/mips-protos.h (mips_expand_before_return): Declare. + * config/mips/mips.c (mips_expand_before_return): New function. + (mips_expand_epilogue): Call it. + * config/mips/mips.md (return): Turn into a define_expand. + (*return): New insn. + +2008-06-01 Richard Sandiford + * rtl.h (emit_clobber, gen_clobber, emit_use, gen_use): Declare. * emit-rtl.c (emit_clobber, gen_clobber, emit_use, gen_use): New functions. Do not emit uses and clobbers of CONCATs; individually diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h index db65aab..1bf0ee9 100644 --- a/gcc/config/mips/mips-protos.h +++ b/gcc/config/mips/mips-protos.h @@ -257,6 +257,7 @@ extern HOST_WIDE_INT mips_initial_elimination_offset (int, int); extern rtx mips_return_addr (int, rtx); extern enum mips_loadgp_style mips_current_loadgp_style (void); extern void mips_expand_prologue (void); +extern void mips_expand_before_return (void); extern void mips_expand_epilogue (bool); extern bool mips_can_use_return_insn (void); extern rtx mips_function_value (const_tree, enum machine_mode); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index b12e2e2..246600d 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -8633,6 +8633,24 @@ mips_restore_reg (rtx reg, rtx mem) mips_emit_move (reg, mem); } +/* Emit any instructions needed before a return. */ + +void +mips_expand_before_return (void) +{ + /* When using a call-clobbered gp, we start out with unified call + insns that include instructions to restore the gp. We then split + these unified calls after reload. These split calls explicitly + clobber gp, so there is no need to define + PIC_OFFSET_TABLE_REG_CALL_CLOBBERED. + + For consistency, we should also insert an explicit clobber of $28 + before return insns, so that the post-reload optimizers know that + the register is not live on exit. */ + if (TARGET_CALL_CLOBBERED_GP) + emit_clobber (pic_offset_table_rtx); +} + /* Expand an "epilogue" or "sibcall_epilogue" pattern; SIBCALL_P says which. */ @@ -8775,6 +8793,7 @@ mips_expand_epilogue (bool sibcall_p) regno = GP_REG_FIRST + 7; else regno = GP_REG_FIRST + 31; + mips_expand_before_return (); emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, regno))); } } diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index 921e416..55e1cd0 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -5739,7 +5739,12 @@ ;; Trivial return. Make it look like a normal return insn as that ;; allows jump optimizations to work better. -(define_insn "return" +(define_expand "return" + [(return)] + "mips_can_use_return_insn ()" + { mips_expand_before_return (); }) + +(define_insn "*return" [(return)] "mips_can_use_return_insn ()" "%*j\t$31%/"