builtins.c (expand_builtin_return_addr): Deal with FRAME_ADDR_RTX.
authorEric Botcazou <ebotcazou@libertysurf.fr>
Tue, 3 Oct 2006 16:25:00 +0000 (18:25 +0200)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 3 Oct 2006 16:25:00 +0000 (16:25 +0000)
* builtins.c (expand_builtin_return_addr): Deal with FRAME_ADDR_RTX.
* doc/tm.texi (Basic Stack Layout): Document FRAME_ADDR_RTX.
* config/sparc/sparc.h (FRAME_ADDR_RTX): Define.

From-SVN: r117403

gcc/ChangeLog
gcc/builtins.c
gcc/config/sparc/sparc.h
gcc/doc/tm.texi

index f8fb06df3830fdb556fecd44ae577cdf59708129..260fc34977803c1cc2ca9e8c39e9ff11d82780f7 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-03  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * builtins.c (expand_builtin_return_addr): Deal with FRAME_ADDR_RTX.
+       * doc/tm.texi (Basic Stack Layout): Document FRAME_ADDR_RTX.
+       * config/sparc/sparc.h (FRAME_ADDR_RTX): Define.
+
 2006-10-02  Jack Howarth  <howarth@bromo.med.uc.edu>
 
        * unwind-dw2-fde-darwin.c (getsectdatafromheader_64): Fix first
index 8fb58ca052dd3e61e9583e571fc1772d1b39c8a8..2c81983f3d31572d7cbd89e2ce08a473fc4933e3 100644 (file)
@@ -558,14 +558,14 @@ expand_builtin_return_addr (enum built_in_function fndecl_code, int count)
 #endif
 
   /* Some machines need special handling before we can access
-     arbitrary frames.  For example, on the sparc, we must first flush
+     arbitrary frames.  For example, on the SPARC, we must first flush
      all register windows to the stack.  */
 #ifdef SETUP_FRAME_ADDRESSES
   if (count > 0)
     SETUP_FRAME_ADDRESSES ();
 #endif
 
-  /* On the sparc, the return address is not in the frame, it is in a
+  /* On the SPARC, the return address is not in the frame, it is in a
      register.  There is no way to access it off of the current frame
      pointer, but it can be accessed off the previous frame pointer by
      reading the value from the register window save area.  */
@@ -587,12 +587,16 @@ expand_builtin_return_addr (enum built_in_function fndecl_code, int count)
       tem = copy_to_reg (tem);
     }
 
-  /* For __builtin_frame_address, return what we've got.  */
+  /* For __builtin_frame_address, return what we've got.  But, on
+     the SPARC for example, we may have to add a bias.  */
   if (fndecl_code == BUILT_IN_FRAME_ADDRESS)
+#ifdef FRAME_ADDR_RTX
+    return FRAME_ADDR_RTX (tem);
+#else
     return tem;
+#endif
 
-  /* For __builtin_return_address, Get the return address from that
-     frame.  */
+  /* For __builtin_return_address, get the return address from that frame.  */
 #ifdef RETURN_ADDR_RTX
   tem = RETURN_ADDR_RTX (count, tem);
 #else
index 1d595bc395b9bfced4aef8c7c5917d36c325fa65..8a2121cf27c42dcbd86712b29c56032b23a90676 100644 (file)
@@ -1701,6 +1701,10 @@ do {                                                                     \
 #define DYNAMIC_CHAIN_ADDRESS(frame)   \
   plus_constant (frame, 14 * UNITS_PER_WORD + SPARC_STACK_BIAS)
 
+/* Given an rtx for the frame pointer,
+   return an rtx for the address of the frame.  */
+#define FRAME_ADDR_RTX(frame) plus_constant (frame, SPARC_STACK_BIAS)
+
 /* The return address isn't on the stack, it is in a register, so we can't
    access it from the current frame pointer.  We can access it from the
    previous frame pointer though by reading a value from the register window
index c724a49a40e81446675f327ed20a5939fe7a5344..cc448bcc687a05b344b487549fe92945e372f043 100644 (file)
@@ -2995,6 +2995,14 @@ machines.  One reason you may need to define this target hook is if
 @code{hard_frame_pointer_rtx} is the appropriate value on your machine.
 @end deftypefn
 
+@defmac FRAME_ADDR_RTX (@var{frameaddr})
+A C expression whose value is RTL representing the value of the frame
+address for the current frame.  @var{frameaddr} is the frame pointer
+of the current frame.  This is used for __builtin_frame_address.
+You need only define this macro if the frame address is not the same
+as the frame pointer.  Most machines do not need to define it.
+@end defmac
+
 @defmac RETURN_ADDR_RTX (@var{count}, @var{frameaddr})
 A C expression whose value is RTL representing the value of the return
 address for the frame @var{count} steps up from the current frame, after