Patchwork RFA: RL78: Always select register bank 0 at the start of an ISR

login
register
mail settings
Submitter Nick Clifton
Date Jan. 3, 2013, 12:45 p.m.
Message ID <878v8a1llw.fsf@redhat.com>
Download mbox | patch
Permalink /patch/209242/
State New
Headers show

Comments

Nick Clifton - Jan. 3, 2013, 12:45 p.m.
Hi DJ,

  Since interrupts can happen at any time, it is possible for a ISR to
  be called when register bank 0 is not the currently selected bank.
  Hence the prologue for an interrupt handler should always select bank
  0 before saving any registers.  The patch below makes sure that this
  happens.

  No regressions with a rl78-elf toolchain.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2013-01-03  Nick Clifton  <nickc@redhat.com>

	* config/rl78/rl78.c (rl78_expand_prologue): Always select
	register bank 0 at the start of an interrupt handler.
DJ Delorie - Jan. 7, 2013, 7:54 p.m.
I think that's right, since the ISR return restores the flag register,
which has the bank select bits in it.

Patch

Index: gcc/config/rl78/rl78.c
===================================================================
--- gcc/config/rl78/rl78.c	(revision 194833)
+++ gcc/config/rl78/rl78.c	(working copy)
@@ -839,6 +839,9 @@ 
   if (flag_stack_usage_info)
     current_function_static_stack_size = cfun->machine->framesize;
 
+  if (is_interrupt_func (cfun->decl))
+    emit_insn (gen_sel_rb (GEN_INT (0)));
+
   for (i = 0; i < 16; i++)
     if (cfun->machine->need_to_push [i])
       {