This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Improvement in HC11 prologue/epilogue
- From: Stephane Carrez <stcarrez at nerim dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 31 Mar 2003 22:27:45 +0200
- Subject: [PATCH]: Improvement in HC11 prologue/epilogue
Hi!
I've committed this patch on 3_3 and mainline to change the 68HC11/HC12
interrupt prologue so that gdb can unwind it as a function (the frame is
saved at the same place as for a function). The patch also optimizes the
epilogue when we return a value > 32 bits as this is a return by reference
and we can use X register as a scratch reg (faster than Y register).
Stephane
2003-03-31 Stephane Carrez <stcarrez at nerim dot fr>
* config/m68hc11/m68hc11.c (expand_prologue): For an interrupt handler
save the soft registers after the frame pointer so that gdb can unwind
the frame more easily.
(expand_epilogue): Likewise in opposite order; allow to use X register
as scratch if the return value is by reference.
Index: m68hc11.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.56.4.12
diff -u -p -r1.56.4.12 m68hc11.c
--- m68hc11.c 24 Mar 2003 22:27:36 -0000 1.56.4.12
+++ m68hc11.c 31 Mar 2003 20:06:44 -0000
@@ -1673,6 +1673,10 @@ expand_prologue ()
else
scratch = ix_reg;
+ /* Save current stack frame. */
+ if (frame_pointer_needed)
+ emit_move_after_reload (stack_push_word, hard_frame_pointer_rtx, scratch);
+
/* For an interrupt handler, we must preserve _.tmp, _.z and _.xy.
Other soft registers in page0 need not to be saved because they
will be restored by C functions. For a trap handler, we don't
@@ -1687,10 +1691,6 @@ expand_prologue ()
scratch);
}
- /* Save current stack frame. */
- if (frame_pointer_needed)
- emit_move_after_reload (stack_push_word, hard_frame_pointer_rtx, scratch);
-
/* Allocate local variables. */
if (TARGET_M6812 && (size > 4 || size == 3))
{
@@ -1764,7 +1764,7 @@ expand_epilogue ()
else
return_size = GET_MODE_SIZE (GET_MODE (current_function_return_rtx));
- if (return_size > HARD_REG_SIZE)
+ if (return_size > HARD_REG_SIZE && return_size <= 2 * HARD_REG_SIZE)
scratch = iy_reg;
else
scratch = ix_reg;
@@ -1811,10 +1811,6 @@ expand_epilogue ()
stack_pointer_rtx, GEN_INT (1)));
}
- /* Restore previous frame pointer. */
- if (frame_pointer_needed)
- emit_move_after_reload (hard_frame_pointer_rtx, stack_pop_word, scratch);
-
/* For an interrupt handler, restore ZTMP, ZREG and XYREG. */
if (current_function_interrupt)
{
@@ -1824,6 +1820,10 @@ expand_epilogue ()
stack_pop_word, scratch);
emit_move_after_reload (m68hc11_soft_tmp_reg, stack_pop_word, scratch);
}
+
+ /* Restore previous frame pointer. */
+ if (frame_pointer_needed)
+ emit_move_after_reload (hard_frame_pointer_rtx, stack_pop_word, scratch);
/* If the trap handler returns some value, copy the value
in D, X onto the stack so that the rti will pop the return value