Implement __builtin_return_address(0) for v850
Nick Clifton
nickc@redhat.com
Mon Jan 8 19:06:00 GMT 2001
Hi Richard,
: On Fri, Jan 05, 2001 at 04:00:03PM -0800, Nick Clifton wrote:
: > * config/v850/v850.c (struct machine_function): Define.
: > (v850_save_machine_status): New function.
: > (v850_restore_machine_status): New function.
: > (v850_return_addr): New function.
: > (v850_init_expanders): New function.
:
: You really want init_machine_status and mark_machine_status.
: Moreover, you'll get gc errors without mark_machine_status.
Good point.
The patch below does this.
Cheers
Nick
2001-01-08 Nick Clifton <nickc@redhat.com>
* config/v850/v850.c (ra_rtx): Delete.
(v850_save_machine_status): Delete.
(v850_restore_machine_status): Delete.
(v850_init_machine_status): New function.
(v850_mark_machine_status): New function.
(v850_free_machine_status): New function.
(v850_return_addr): Use ra_rtx field in machine structure.
(v850_init_expanders): Use new functions.
Index: config/v850/v850.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/v850/v850.c,v
retrieving revision 1.36
diff -p -r1.36 v850.c
*** v850.c 2001/01/06 00:00:35 1.36
--- v850.c 2001/01/09 03:01:29
*************** Boston, MA 02111-1307, USA. */
*** 47,60 ****
#endif
/* Function prototypes for stupid compilers: */
! static void const_double_split
! PARAMS ((rtx, HOST_WIDE_INT *, HOST_WIDE_INT *));
! static int const_costs_int PARAMS ((HOST_WIDE_INT, int));
! static void substitute_ep_register PARAMS ((rtx, rtx, int, int, rtx *, rtx *));
! static int ep_memory_offset PARAMS ((enum machine_mode, int));
! static void v850_set_data_area PARAMS ((tree, v850_data_area));
! static void v850_save_machine_status PARAMS ((struct function *));
! static void v850_restore_machine_status PARAMS ((struct function *));
/* True if the current function has anonymous arguments. */
int current_function_anonymous_args;
--- 47,60 ----
#endif
/* Function prototypes for stupid compilers: */
! static void const_double_split PARAMS ((rtx, HOST_WIDE_INT *, HOST_WIDE_INT *));
! static int const_costs_int PARAMS ((HOST_WIDE_INT, int));
! static void substitute_ep_register PARAMS ((rtx, rtx, int, int, rtx *, rtx *));
! static int ep_memory_offset PARAMS ((enum machine_mode, int));
! static void v850_set_data_area PARAMS ((tree, v850_data_area));
! static void v850_init_machine_status PARAMS ((struct function *));
! static void v850_mark_machine_status PARAMS ((struct function *));
! static void v850_free_machine_status PARAMS ((struct function *));
/* True if the current function has anonymous arguments. */
int current_function_anonymous_args;
*************** v850_va_arg (valist, type)
*** 2788,2796 ****
}
/* Functions to save and restore machine-specific function data. */
-
- static rtx ra_rtx;
-
struct machine_function
{
/* Records __builtin_return address. */
--- 2788,2793 ----
*************** struct machine_function
*** 2798,2816 ****
};
static void
! v850_save_machine_status (p)
struct function * p;
{
p->machine =
(struct machine_function *) xcalloc (1, sizeof (struct machine_function));
! p->machine->ra_rtx = ra_rtx;
}
static void
! v850_restore_machine_status (p)
struct function * p;
{
- ra_rtx = p->machine->ra_rtx;
free (p->machine);
p->machine = NULL;
}
--- 2795,2818 ----
};
static void
! v850_init_machine_status (p)
struct function * p;
{
p->machine =
(struct machine_function *) xcalloc (1, sizeof (struct machine_function));
! }
!
! static void
! v850_mark_machine_status (p)
! struct function * p;
! {
! ggc_mark_rtx (p->machine->ra_rtx);
}
static void
! v850_free_machine_status (p)
struct function * p;
{
free (p->machine);
p->machine = NULL;
}
*************** v850_return_addr (count)
*** 2825,2841 ****
if (count != 0)
return const0_rtx;
! if (ra_rtx == NULL)
{
rtx init;
/* No rtx yet. Invent one, and initialize it for r31 (lp) in
the prologue. */
! ra_rtx = gen_reg_rtx (Pmode);
init = gen_rtx_REG (Pmode, LINK_POINTER_REGNUM);
! init = gen_rtx_SET (VOIDmode, ra_rtx, init);
/* Emit the insn to the prologue with the other argument copies. */
push_topmost_sequence ();
--- 2827,2843 ----
if (count != 0)
return const0_rtx;
! if (cfun->machine->ra_rtx == NULL)
{
rtx init;
/* No rtx yet. Invent one, and initialize it for r31 (lp) in
the prologue. */
! cfun->machine->ra_rtx = gen_reg_rtx (Pmode);
init = gen_rtx_REG (Pmode, LINK_POINTER_REGNUM);
! init = gen_rtx_SET (VOIDmode, cfun->machine->ra_rtx, init);
/* Emit the insn to the prologue with the other argument copies. */
push_topmost_sequence ();
*************** v850_return_addr (count)
*** 2843,2850 ****
pop_topmost_sequence ();
}
! debug_rtx (ra_rtx);
! return ra_rtx;
}
/* Do anything needed before RTL is emitted for each function. */
--- 2845,2851 ----
pop_topmost_sequence ();
}
! return cfun->machine->ra_rtx;
}
/* Do anything needed before RTL is emitted for each function. */
*************** v850_return_addr (count)
*** 2852,2859 ****
void
v850_init_expanders ()
{
! ra_rtx = NULL;
!
! save_machine_status = v850_save_machine_status;
! restore_machine_status = v850_restore_machine_status;
}
--- 2853,2859 ----
void
v850_init_expanders ()
{
! init_machine_status = v850_init_machine_status;
! mark_machine_status = v850_mark_machine_status;
! free_machine_status = v850_free_machine_status;
}
More information about the Gcc-patches
mailing list