From: Kazuhiro Inaoka Date: Tue, 15 Jun 2004 10:01:34 +0000 (+0000) Subject: m32r.h (RETURN_ADDR_RTX): Define. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7b14411a870638fb16f4a6052fcd64917ed1505d;p=gcc.git m32r.h (RETURN_ADDR_RTX): Define. * config/m32r/m32r.h (RETURN_ADDR_RTX): Define. (INCOMING_RETURN_ADDR_RTX): Define. * config/m32r/m32r-protos.h (m32r_return_addr): Added. * config/m32r/m32r.c (m32r_exppand_prologue): Changed for __builtin_return_address(0). (m32r_return_addr): Added for __builtin_return_address(0). (m32r_reload_lr): Ditto. From-SVN: r83171 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5ae9715ade7..e6038259986 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2004-06-15 Kazuhiro Inaoka + + * config/m32r/m32r.h (RETURN_ADDR_RTX): Define. + (INCOMING_RETURN_ADDR_RTX): Define. + * config/m32r/m32r-protos.h (m32r_return_addr): Added. + * config/m32r/m32r.c (m32r_exppand_prologue): Changed for + __builtin_return_address(0). + (m32r_return_addr): Added for __builtin_return_address(0). + (m32r_reload_lr): Ditto. + 2004-06-15 Paolo Bonzini * doc/install.texi (Prerequisites): Update libbanshee, @@ -5910,7 +5920,7 @@ * config/arm/t-xscale-elf: Disable iwmmxt multilibs until they can be safely built. -2004-04-16 Kazuhiro Inaoka +2004-04-16 Kazuhiro Inaoka * config/m32r/m32r.h (BIG_ENDIAN_BIT): Deleted to fix endian bug. diff --git a/gcc/config/m32r/m32r-protos.h b/gcc/config/m32r/m32r-protos.h index 97247d63143..4bc4c6c8ca7 100644 --- a/gcc/config/m32r/m32r-protos.h +++ b/gcc/config/m32r/m32r-protos.h @@ -58,6 +58,7 @@ extern int m32r_not_same_reg (rtx, rtx); extern int m32r_hard_regno_rename_ok (unsigned int, unsigned int); extern int m32r_legitimate_pic_operand_p (rtx); extern rtx m32r_legitimize_pic_address (rtx, rtx); +extern rtx m32r_return_addr (int); #ifdef HAVE_MACHINE_MODES extern int call_address_operand (rtx, Mmode); diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index fa898bcd189..6599dc64bbe 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -1905,6 +1905,29 @@ m32r_compute_frame_size (int size) /* # of var. bytes allocated. */ /* The table we use to reference PIC data. */ static rtx global_offset_table; +static void +m32r_reload_lr (rtx sp, int size) +{ + rtx lr = gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM); + + if (size == 0) + emit_insn (gen_movsi (lr, gen_rtx_MEM (Pmode, sp))); + else if (size <= 32768) + emit_insn (gen_movsi (lr, gen_rtx_MEM (Pmode, + gen_rtx_PLUS (Pmode, sp, + GEN_INT (size))))); + else + { + rtx tmp = gen_rtx_REG (Pmode, PROLOGUE_TMP_REGNUM); + + emit_insn (gen_movsi (tmp, GEN_INT (size))); + emit_insn (gen_addsi3 (tmp, tmp, sp)); + emit_insn (gen_movsi (lr, gen_rtx_MEM (Pmode, tmp))); + } + + emit_insn (gen_rtx_USE (VOIDmode, lr)); +} + void m32r_load_pic_register (void) { @@ -1993,7 +2016,11 @@ m32r_expand_prologue (void) gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM))); if (pic_reg_used) - m32r_load_pic_register (); + { + m32r_load_pic_register (); + m32r_reload_lr (stack_pointer_rtx, + (current_function_profile ? 0 : frame_size)); + } if (current_function_profile && !pic_reg_used) emit_insn (gen_blockage ()); @@ -3052,3 +3079,12 @@ m32r_hard_regno_rename_ok (unsigned int old_reg ATTRIBUTE_UNUSED, return 1; } + +rtx +m32r_return_addr (int count) +{ + if (count != 0) + return const0_rtx; + + return get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); +} diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h index 82b265b1065..c20b0424bb0 100644 --- a/gcc/config/m32r/m32r.h +++ b/gcc/config/m32r/m32r.h @@ -1265,6 +1265,10 @@ L2: .word STATIC /* Generate calls to memcpy, memcmp and memset. */ #define TARGET_MEM_FUNCTIONS +#define RETURN_ADDR_RTX(COUNT, FRAME) m32r_return_addr (COUNT) + +#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM) + /* Addressing modes, and classification of registers for them. */ /* Maximum number of registers that can appear in a valid memory address. */