Tom de Vries <tom_devr...@mentor.com> writes: > 2014-01-12 Radovan Obradovic <robrado...@mips.com> > Tom de Vries <t...@codesourcery.com> > > * config/mips/mips-protos.h (mips_emit_call_insn): Declare. > * config/mips/mips.h (POST_CALL_TMP_REG): Define. > * config/mips/mips.c (mips_emit_call_insn): Remove static. Use > last_call_insn. Add POST_CALL_TMP_REG clobber > (mips_split_call): Use POST_CALL_TMP_REG. > (TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS): Redefine to true. > * config/mips/mips.md (define_expand "untyped_call"): Use > mips_emit_call_insn. > > * gcc.target/mips/mips.exp: Add use-caller-save to -ffoo/-fno-foo > options. > * gcc.target/mips/fuse-caller-save.h: New include file. > * gcc.target/mips/fuse-caller-save.c: New test. > * gcc.target/mips/fuse-caller-save-mips16.c: Same. > * gcc.target/mips/fuse-caller-save-micromips.c: Same.
Sorry, a couple of things, but this is looking pretty good: > mips_emit_call_insn (rtx pattern, rtx orig_addr, rtx addr, bool lazy_p) > { > rtx insn, reg; > > - insn = emit_call_insn (pattern); > + emit_call_insn (pattern); > + insn = last_call_insn (); > > if (TARGET_MIPS16 && mips_use_pic_fn_addr_reg_p (orig_addr)) > { This change isn't necessary; emit_call_insn is defined to return a CALL_INSN. > @@ -2843,6 +2844,16 @@ mips_emit_call_insn (rtx pattern, rtx orig_addr, rtx > addr, bool lazy_p) > gen_rtx_REG (Pmode, GOT_VERSION_REGNUM)); > emit_insn (gen_update_got_version ()); > } > + > + if (TARGET_MIPS16 > + && TARGET_EXPLICIT_RELOCS > + && TARGET_CALL_CLOBBERED_GP > + && !find_reg_note (insn, REG_NORETURN, 0)) > + { > + rtx post_call_tmp_reg = gen_rtx_REG (word_mode, POST_CALL_TMP_REG); > + clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), post_call_tmp_reg); > + } The REG_NORETURN note won't be around yet, so we might as well drop that line. I'm not sure how useful it would be anyway since values are never live across a noreturn call. > +/* Temporary register that is used after a call. $4 and $5 are used for Might as well make it "...used when restoring $gp after a call", now that it's not as obvious from context. > + returning complex double values in soft-float code, so $6 is the first > + suitable candidate for !TARGET_MIPS16. For TARGET_MIPS16, we use > + PIC_OFFSET_TABLE_REGNUM instead. */ !TARGET_MIPS16 and TARGET_MIPS16 are the wrong way around: suitable candidate for TARGET_MIPS16. For !TARGET_MIPS16 we can use $gp itself as the temporary. */ > +/* The scan of the sp-relative saves will fail for -O0 and -O1. > + For -flto, scans will fail because there's no code in the .s file. */ > +/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-flto"} } */ The -flto thing is handled automatically by the testsuite (see force_conventional_output_for) so that one should be left out. I'm a bit surprised that it doesn't work at -O1 for a simple test like this though. What goes wrong? Thanks, Richard