[rl78] use ax to copy fp to sp

Submitted by DJ Delorie on Sept. 12, 2013, 10:43 p.m.

Details

Message ID 201309122243.r8CMhXrY027285@greed.delorie.com
State New
Headers show

Commit Message

DJ Delorie Sept. 12, 2013, 10:43 p.m.
Devirtualizer used to do this for us.  Committed.

	* config/rl78/rl78.c (rl78_expand_prologue): Use AX to copy
	between SP and FP.
	(rl78_expand_epilogue): Likewise.

Patch hide | download patch | download mbox

Index: config/rl78/rl78.c
===================================================================
--- config/rl78/rl78.c	(revision 202541)
+++ config/rl78/rl78.c	(working copy)
@@ -1033,14 +1033,18 @@  rl78_expand_prologue (void)
 	F (emit_insn (gen_push (gen_rtx_REG (HImode, i*2))));
       }
   if (rb != 0)
     emit_insn (gen_sel_rb (GEN_INT (0)));
 
   if (frame_pointer_needed)
-    F (emit_move_insn (gen_rtx_REG (HImode, FRAME_POINTER_REGNUM),
-		       gen_rtx_REG (HImode, STACK_POINTER_REGNUM)));
+    {
+      F (emit_move_insn (gen_rtx_REG (HImode, AX_REG),
+			 gen_rtx_REG (HImode, STACK_POINTER_REGNUM)));
+      F (emit_move_insn (gen_rtx_REG (HImode, FRAME_POINTER_REGNUM),
+			 gen_rtx_REG (HImode, AX_REG)));
+    }
 
   fs = cfun->machine->framesize_locals + cfun->machine->framesize_outgoing;
   while (fs > 0)
     {
       int fs_byte = (fs > 254) ? 254 : fs;
       F (emit_insn (gen_subhi3 (sp, sp, GEN_INT (fs_byte))));
@@ -1058,14 +1062,16 @@  rl78_expand_epilogue (void)
 
   if (rl78_is_naked_func ())
     return;
 
   if (frame_pointer_needed)
     {
-      emit_move_insn (gen_rtx_REG (HImode, STACK_POINTER_REGNUM),
+      emit_move_insn (gen_rtx_REG (HImode, AX_REG),
 		      gen_rtx_REG (HImode, FRAME_POINTER_REGNUM));
+      emit_move_insn (gen_rtx_REG (HImode, STACK_POINTER_REGNUM),
+		      gen_rtx_REG (HImode, AX_REG));
     }
   else
     {
       fs = cfun->machine->framesize_locals + cfun->machine->framesize_outgoing;
       while (fs > 0)
 	{