Commit fcf8632e by Christian Bruel Committed by Christian Bruel

re PR target/54546 (SH: Enable -fshrink-wrap)

       PR target/54546
       * config/sh/sh-protos.h (sh_need_epilogue): Delete.
       (sh_can_use_simple_return_p): Declare.
       * config/sh/sh.c (sh_can_use_simple_return_p): Define.
       (sh_need_epilogue, sh_need_epilogue_known): Delete.
       (sh_output_function_epilogue): Remove sh_need_epilogue_known.
       * config/sh/sh.md (simple_return, return): Define.
       (epilogue): Use inline return rtl.
       (sh_expand_epilogue): Cleanup parameters boolean type.
       * config/sh/iterators.md (any_return): New iterator.

From-SVN: r191301
parent 312f9b9d
2012-09-14 Christian Bruel <christian.bruel@st.com> 2012-09-14 Christian Bruel <christian.bruel@st.com>
PR target/54546
* config/sh/sh-protos.h (sh_need_epilogue): Delete.
(sh_can_use_simple_return_p): Declare.
* config/sh/sh.c (sh_can_use_simple_return_p): Define.
(sh_need_epilogue, sh_need_epilogue_known): Delete.
(sh_output_function_epilogue): Remove sh_need_epilogue_known.
* config/sh/sh.md (simple_return, return): Define.
(epilogue): Use inline return rtl.
(sh_expand_epilogue): Cleanup parameters boolean type.
* config/sh/iterators.md (any_return): New iterator.
2012-09-14 Christian Bruel <christian.bruel@st.com>
* config/sh/predicates.md (t_reg_operand): Check REG_P for SUBREG. * config/sh/predicates.md (t_reg_operand): Check REG_P for SUBREG.
* config/sh/sh.c (sequence_insn_p: Check INSNP_P for SEQUENCE. * config/sh/sh.c (sequence_insn_p: Check INSNP_P for SEQUENCE.
......
...@@ -34,3 +34,6 @@ ...@@ -34,3 +34,6 @@
(define_mode_attr disp04 [(QI "K04") (HI "K05")]) (define_mode_attr disp04 [(QI "K04") (HI "K05")])
(define_mode_attr disp12 [(QI "K12") (HI "K13")]) (define_mode_attr disp12 [(QI "K12") (HI "K13")])
;; Return codes.
(define_code_iterator any_return [return simple_return])
...@@ -117,7 +117,6 @@ extern rtx get_fpscr_rtx (void); ...@@ -117,7 +117,6 @@ extern rtx get_fpscr_rtx (void);
extern int sh_media_register_for_return (void); extern int sh_media_register_for_return (void);
extern void sh_expand_prologue (void); extern void sh_expand_prologue (void);
extern void sh_expand_epilogue (bool); extern void sh_expand_epilogue (bool);
extern bool sh_need_epilogue (void);
extern void sh_set_return_address (rtx, rtx); extern void sh_set_return_address (rtx, rtx);
extern int initial_elimination_offset (int, int); extern int initial_elimination_offset (int, int);
extern bool fldi_ok (void); extern bool fldi_ok (void);
...@@ -155,4 +154,5 @@ extern int sh2a_get_function_vector_number (rtx); ...@@ -155,4 +154,5 @@ extern int sh2a_get_function_vector_number (rtx);
extern bool sh2a_is_function_vector_call (rtx); extern bool sh2a_is_function_vector_call (rtx);
extern void sh_fix_range (const char *); extern void sh_fix_range (const char *);
extern bool sh_hard_regno_mode_ok (unsigned int, enum machine_mode); extern bool sh_hard_regno_mode_ok (unsigned int, enum machine_mode);
extern bool sh_can_use_simple_return_p (void);
#endif /* ! GCC_SH_PROTOS_H */ #endif /* ! GCC_SH_PROTOS_H */
...@@ -7899,24 +7899,6 @@ sh_expand_epilogue (bool sibcall_p) ...@@ -7899,24 +7899,6 @@ sh_expand_epilogue (bool sibcall_p)
emit_use (gen_rtx_REG (SImode, PR_REG)); emit_use (gen_rtx_REG (SImode, PR_REG));
} }
static int sh_need_epilogue_known = 0;
bool
sh_need_epilogue (void)
{
if (! sh_need_epilogue_known)
{
rtx epilogue;
start_sequence ();
sh_expand_epilogue (0);
epilogue = get_insns ();
end_sequence ();
sh_need_epilogue_known = (epilogue == NULL ? -1 : 1);
}
return sh_need_epilogue_known > 0;
}
/* Emit code to change the current function's return address to RA. /* Emit code to change the current function's return address to RA.
TEMP is available as a scratch register, if needed. */ TEMP is available as a scratch register, if needed. */
...@@ -7996,7 +7978,6 @@ static void ...@@ -7996,7 +7978,6 @@ static void
sh_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED, sh_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED,
HOST_WIDE_INT size ATTRIBUTE_UNUSED) HOST_WIDE_INT size ATTRIBUTE_UNUSED)
{ {
sh_need_epilogue_known = 0;
} }
static rtx static rtx
...@@ -12955,4 +12936,34 @@ sh_init_sync_libfuncs (void) ...@@ -12955,4 +12936,34 @@ sh_init_sync_libfuncs (void)
init_sync_libfuncs (UNITS_PER_WORD); init_sync_libfuncs (UNITS_PER_WORD);
} }
/* Return true if it is appropriate to emit `ret' instructions in the
body of a function. */
bool
sh_can_use_simple_return_p (void)
{
HARD_REG_SET live_regs_mask;
int d;
if (! reload_completed || frame_pointer_needed)
return false;
/* Moving prologue around does't reduce the size. */
if (optimize_function_for_size_p (cfun))
return false;
/* Can't optimize CROSSING_JUMPS for now. */
if (flag_reorder_blocks_and_partition)
return false;
/* Finally, allow for pr save. */
d = calc_live_regs (&live_regs_mask);
if (rounded_frame_size (d) > 4)
return false;
return true;
}
#include "gt-sh.h" #include "gt-sh.h"
...@@ -9335,7 +9335,7 @@ label: ...@@ -9335,7 +9335,7 @@ label:
[(return)] [(return)]
"" ""
{ {
sh_expand_epilogue (1); sh_expand_epilogue (true);
if (TARGET_SHCOMPACT) if (TARGET_SHCOMPACT)
{ {
rtx insn, set; rtx insn, set;
...@@ -10154,9 +10154,13 @@ label: ...@@ -10154,9 +10154,13 @@ label:
} }
[(set_attr "type" "load_media")]) [(set_attr "type" "load_media")])
(define_expand "simple_return"
[(simple_return)]
"sh_can_use_simple_return_p ()")
(define_expand "return" (define_expand "return"
[(return)] [(return)]
"reload_completed && ! sh_need_epilogue ()" "reload_completed && epilogue_completed"
{ {
if (TARGET_SHMEDIA) if (TARGET_SHMEDIA)
{ {
...@@ -10172,8 +10176,8 @@ label: ...@@ -10172,8 +10176,8 @@ label:
} }
}) })
(define_insn "*return_i" (define_insn "*<code>_i"
[(return)] [(any_return)]
"TARGET_SH1 && ! (TARGET_SHCOMPACT "TARGET_SH1 && ! (TARGET_SHCOMPACT
&& (crtl->args.info.call_cookie && (crtl->args.info.call_cookie
& CALL_COOKIE_RET_TRAMP (1))) & CALL_COOKIE_RET_TRAMP (1)))
...@@ -10299,19 +10303,12 @@ label: ...@@ -10299,19 +10303,12 @@ label:
(define_expand "prologue" (define_expand "prologue"
[(const_int 0)] [(const_int 0)]
"" ""
{ "sh_expand_prologue (); DONE;")
sh_expand_prologue ();
DONE;
})
(define_expand "epilogue" (define_expand "epilogue"
[(return)] [(return)]
"" ""
{ "sh_expand_epilogue (false);")
sh_expand_epilogue (0);
emit_jump_insn (gen_return ());
DONE;
})
(define_expand "eh_return" (define_expand "eh_return"
[(use (match_operand 0 "register_operand" ""))] [(use (match_operand 0 "register_operand" ""))]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment