Commit 2ba1dca1 by Nick Clifton Committed by DJ Delorie

rl78.c (need_to_save): Change return type to bool.

* config/rl78/rl78.c (need_to_save): Change return type to bool.
For interrupt functions: save all call clobbered registers if the
interrupt handler is not a leaf function.
(rl78_expand_prologue): Always recompute the frame information.
For interrupt functions: only select bank 0 if one of the bank 0
registers is going to be psuhed.

From-SVN: r202667
parent 2e7c3f21
2013-09-17 Nick Clifton <nickc@redhat.com>
* config/rl78/rl78.c (need_to_save): Change return type to bool.
For interrupt functions: save all call clobbered registers if the
interrupt handler is not a leaf function.
(rl78_expand_prologue): Always recompute the frame information.
For interrupt functions: only select bank 0 if one of the bank 0
registers is going to be psuhed.
2013-09-17 DJ Delorie <dj@redhat.com> 2013-09-17 DJ Delorie <dj@redhat.com>
* config/rl78/constraints.md: For each W* constraint, rename to C* * config/rl78/constraints.md: For each W* constraint, rename to C*
......
...@@ -540,34 +540,39 @@ rl78_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to ATTRIBUTE_UNUS ...@@ -540,34 +540,39 @@ rl78_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to ATTRIBUTE_UNUS
return true; return true;
} }
/* Returns nonzero if the given register needs to be saved by the /* Returns true if the given register needs to be saved by the
current function. */ current function. */
static int static bool
need_to_save (int regno) need_to_save (unsigned int regno)
{ {
if (is_interrupt_func (cfun->decl)) if (is_interrupt_func (cfun->decl))
{ {
if (regno < 8) /* We don't need to save registers that have
return 1; /* don't know what devirt will need */ been reserved for interrupt handlers. */
if (regno > 23) if (regno > 23)
return 0; /* don't need to save interrupt registers */ return false;
if (crtl->is_leaf)
{ /* If the handler is a non-leaf function then it may call
return df_regs_ever_live_p (regno); non-interrupt aware routines which will happily clobber
} any call_used registers, so we have to preserve them. */
else if (!crtl->is_leaf && call_used_regs[regno])
return 1; return true;
/* Otherwise we only have to save a register, call_used
or not, if it is used by this handler. */
return df_regs_ever_live_p (regno);
} }
if (regno == FRAME_POINTER_REGNUM && frame_pointer_needed) if (regno == FRAME_POINTER_REGNUM && frame_pointer_needed)
return 1; return true;
if (fixed_regs[regno]) if (fixed_regs[regno])
return 0; return false;
if (crtl->calls_eh_return) if (crtl->calls_eh_return)
return 1; return true;
if (df_regs_ever_live_p (regno) if (df_regs_ever_live_p (regno)
&& !call_used_regs[regno]) && !call_used_regs[regno])
return 1; return true;
return 0; return false;
} }
/* We use this to wrap all emitted insns in the prologue. */ /* We use this to wrap all emitted insns in the prologue. */
...@@ -1026,14 +1031,20 @@ rl78_expand_prologue (void) ...@@ -1026,14 +1031,20 @@ rl78_expand_prologue (void)
if (rl78_is_naked_func ()) if (rl78_is_naked_func ())
return; return;
if (!cfun->machine->computed) /* Always re-compute the frame info - the register usage may have changed. */
rl78_compute_frame_info (); rl78_compute_frame_info ();
if (flag_stack_usage_info) if (flag_stack_usage_info)
current_function_static_stack_size = cfun->machine->framesize; current_function_static_stack_size = cfun->machine->framesize;
if (is_interrupt_func (cfun->decl) && !TARGET_G10) if (is_interrupt_func (cfun->decl) && !TARGET_G10)
emit_insn (gen_sel_rb (GEN_INT (0))); for (i = 0; i < 4; i++)
if (cfun->machine->need_to_push [i])
{
/* Select Bank 0 if we are using any registers from Bank 0. */
emit_insn (gen_sel_rb (GEN_INT (0)));
break;
}
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
if (cfun->machine->need_to_push [i]) if (cfun->machine->need_to_push [i])
......
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