]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Implement __builtin_return_address (0)
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Jan 2001 00:00:35 +0000 (00:00 +0000)
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 6 Jan 2001 00:00:35 +0000 (00:00 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38734 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/v850/v850-protos.h
gcc/config/v850/v850.c
gcc/config/v850/v850.h

index 580133ce0bbbad6af9717080c54af1249fee0300..7f280c1f329e886a77b1d101d160386c37bfa448 100644 (file)
@@ -1,3 +1,17 @@
+2001-01-05  DJ Delorie <dj@redhat.com>
+
+       * config/v850/v850.h (RETURN_ADDR_RTX): Define.
+       (INIT_EXPANDERS): Define.
+
+       * 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.
+
+       * config/v850/v850-protos.h: Add prototypes for v850_return_addr
+       and v850_init_expanders.
+       
 2001-01-05  Zack Weinberg  <zack@wolery.stanford.edu>
 
        * cpplib.h (struct cpp_reader): Add help_only field.
index 03be1346ebb0e6620dde5e60d072520d6ba057e2..f0b7b4ed27f0fef2fa5f8648113631ddb0da5ec7 100644 (file)
@@ -39,8 +39,10 @@ extern void   asm_file_start                PARAMS ((FILE *));
 extern void   override_options              PARAMS ((void));
 extern int    compute_register_save_size    PARAMS ((long *));
 extern int    compute_frame_size            PARAMS ((int, long *));
+extern void   v850_init_expanders           PARAMS ((void));
 
 #ifdef RTX_CODE
+extern rtx    v850_return_addr              PARAMS ((int));
 extern void   print_operand                 PARAMS ((FILE *, rtx, int ));
 extern void   print_operand_address         PARAMS ((FILE *, rtx));
 extern int    const_costs                   PARAMS ((rtx, enum rtx_code));
index c30b6e8651cdd9fd4dc40aa327289dab886ff4bd..86c7144206ce2149bbdea2d8be11fbc7034b7d43 100644 (file)
@@ -1,5 +1,6 @@
 /* Subroutines for insn-output.c for NEC V850 series
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
    Contributed by Jeff Law (law@cygnus.com).
 
 This file is part of GNU CC.
@@ -52,6 +53,8 @@ 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;
@@ -2783,3 +2786,74 @@ v850_va_arg (valist, type)
 
   return addr_rtx;
 }
+\f
+/* Functions to save and restore machine-specific function data.  */
+
+static rtx ra_rtx;
+
+struct machine_function
+{
+  /* Records __builtin_return address.  */
+  struct rtx_def * ra_rtx;
+};
+
+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;
+}
+
+/* Return an RTX indicating where the return address to the
+   calling function can be found.  */
+
+rtx
+v850_return_addr (count)
+     int count;
+{
+  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 ();
+      emit_insn_after (init, get_insns ());
+      pop_topmost_sequence ();
+    }
+
+  debug_rtx (ra_rtx);
+  return ra_rtx;
+}
+
+/* Do anything needed before RTL is emitted for each function.  */
+
+void
+v850_init_expanders ()
+{
+  ra_rtx = NULL;
+
+  save_machine_status    = v850_save_machine_status;
+  restore_machine_status = v850_restore_machine_status;
+}
index ccf49674d1da0112d9152c11aa88c95870cfb298..36bce1a84bb21be1d73c5ca228183095e654379a 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler. NEC V850 series
-   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
    Contributed by Jeff Law (law@cygnus.com).
 
 This file is part of GNU CC.
@@ -681,6 +681,7 @@ enum reg_class
 
 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
 
+#define RETURN_ADDR_RTX(COUNT, FP) v850_return_addr (COUNT)
 \f
 /* Define a data type for recording info about an argument list
    during the scan of that argument list.  This data type should
@@ -789,6 +790,10 @@ extern int current_function_anonymous_args;
 
 #define EXIT_IGNORE_STACK 1
 
+/* Initialize data used by insn expanders.  This is called from insn_emit,
+   once for every function before code is generated.  */
+#define INIT_EXPANDERS  v850_init_expanders ()
+
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.  */
 
@@ -1618,7 +1623,6 @@ extern union tree_node * GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_K
    matched by the predicate.  The list should have a trailing comma.  */
 
 #define PREDICATE_CODES                                                        \
-{ "ep_memory_operand",         { MEM }},                               \
 { "reg_or_0_operand",          { REG, SUBREG, CONST_INT, CONST_DOUBLE }}, \
 { "reg_or_int5_operand",       { REG, SUBREG, CONST_INT }},            \
 { "call_address_operand",      { REG, SYMBOL_REF }},                   \