* sh-protos.h (sh_pr_n_sets): Declare.
* sh.c (calc_live_regs): If the initial value for PR has been copied,
look at the copy to determine if PR needs to be saved.
sh_pr_n_sets: New function.
* sh.h (RETURN_ADDR_RTX): Use get_hard_reg_initial_val.
(ALLOCATE_INITIAL_VALUE): Define.
* sh.c (initial_elimination_offset):
Fix RETURN_ADDRESS_POINTER_REGNUM case.
From-SVN: r45717
+Fri Sep 21 01:49:41 2001 J"orn Rennecke <amylaar@redhat.com>
+
+ * sh-protos.h (sh_pr_n_sets): Declare.
+ * sh.c (calc_live_regs): If the initial value for PR has been copied,
+ look at the copy to determine if PR needs to be saved.
+ sh_pr_n_sets: New function.
+ * sh.h (RETURN_ADDR_RTX): Use get_hard_reg_initial_val.
+ (ALLOCATE_INITIAL_VALUE): Define.
+
+ * sh.c (initial_elimination_offset):
+ Fix RETURN_ADDRESS_POINTER_REGNUM case.
+
Fri Sep 21 01:13:56 2001 J"orn Rennecke <amylaar@redhat.com>
* integrate.c (allocate_initial_values): New function.
extern int sh_need_epilogue PARAMS ((void));
extern int initial_elimination_offset PARAMS ((int, int));
extern int fldi_ok PARAMS ((void));
+extern int sh_pr_n_sets PARAMS ((void));
#ifdef HARD_CONST
extern void fpscr_set_from_mem PARAMS ((int, HARD_REG_SET));
int live_regs_mask = 0;
int count;
int interrupt_handler;
+ rtx pr_initial;
+ int pr_live;
if ((lookup_attribute
("interrupt_handler",
target_flags &= ~FPU_SINGLE_BIT;
break;
}
+ pr_initial = has_hard_reg_initial_val (Pmode, PR_REG);
+ pr_live = (pr_initial
+ ? REGNO (pr_initial) != PR_REG
+ : regs_ever_live[PR_REG]);
for (count = 0, reg = FIRST_PSEUDO_REGISTER - 1; reg >= 0; reg--)
{
- if ((interrupt_handler && ! pragma_trapa)
+ if (reg == PR_REG
+ ? pr_live
+ : (interrupt_handler && ! pragma_trapa)
? (/* Need to save all the regs ever live. */
(regs_ever_live[reg]
|| (call_used_regs[reg]
&& (! fixed_regs[reg] || reg == MACH_REG || reg == MACL_REG)
- && regs_ever_live[PR_REG]))
+ && pr_live))
&& reg != STACK_POINTER_REGNUM && reg != ARG_POINTER_REGNUM
&& reg != RETURN_ADDRESS_POINTER_REGNUM
&& reg != T_REG && reg != GBR_REG && reg != FPSCR_REG)
if (from == RETURN_ADDRESS_POINTER_REGNUM
&& (to == FRAME_POINTER_REGNUM || to == STACK_POINTER_REGNUM))
- return UNITS_PER_WORD + total_auto_space;
+ return total_auto_space;
abort ();
}
return cost;
}
+
+/* For use by ALLOCATE_INITIAL_VALUE. Note that sh.md contains some
+ 'special function' patterns (type sfunc) that clobber pr, but that
+ do not look like function calls to leaf_function_p. Hence we must
+ do this extra check. */
+int
+sh_pr_n_sets ()
+{
+ return REG_N_SETS (PR_REG);
+}
#define RETURN_ADDR_RTX(COUNT, FRAME) \
(((COUNT) == 0) \
- ? gen_rtx_MEM (Pmode, gen_rtx_REG (Pmode, RETURN_ADDRESS_POINTER_REGNUM)) \
+ ? get_hard_reg_initial_val (Pmode, PR_REG) \
: (rtx) 0)
\f
/* Generate necessary RTL for __builtin_saveregs(). */
1: .long " USER_LABEL_PREFIX #func " - 0b\n\
2:")
+#define ALLOCATE_INITIAL_VALUE(hard_reg) \
+ (REGNO (hard_reg) == PR_REG \
+ ? (current_function_is_leaf && ! sh_pr_n_sets () \
+ ? (hard_reg) \
+ : gen_rtx_MEM (Pmode, arg_pointer_rtx)) \
+ : NULL_RTX)
+
#endif /* ! GCC_SH_H */