public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression
@ 2015-03-03  6:43 Max Filippov
  2015-03-03 14:51 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Max Filippov @ 2015-03-03  6:43 UTC (permalink / raw)
  To: gcc-patches
  Cc: Sterling Augustine, Joseph Myers, David S. Miller,
	Richard Henderson, Eric Botcazou, Max Filippov

This allows a target to support both windowed and non-windowed ABI.

2015-03-03  Max Filippov  <jcmvbkbc@gmail.com>

gcc/
	* builtins.c (expand_builtin_return_addr): Add
	RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition, remove
	surrounding #ifdef.
	* config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
	definition to 1.
	* config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
	Likewise.
	* defaults.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Define to 0 if
	undefined.
	doc/tm.texi.in (RETURN_ADDR_IN_PREVIOUS_FRAME): Update
	paragraph.
---
Changes RFC->PATCH:
- provide default definition for RETURN_ADDR_IN_PREVIOUS_FRAME and drop
  #ifdef from builtins.c;
- update doc/tm.texi.in.

 gcc/builtins.c             | 4 +---
 gcc/config/sparc/sparc.h   | 2 +-
 gcc/config/xtensa/xtensa.h | 2 +-
 gcc/defaults.h             | 4 ++++
 gcc/doc/tm.texi.in         | 7 ++++---
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index fb871e6..9263777 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -802,10 +802,8 @@ expand_builtin_return_addr (enum built_in_function fndecl_code, int count)
      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.  */
-#ifdef RETURN_ADDR_IN_PREVIOUS_FRAME
-  if (fndecl_code == BUILT_IN_RETURN_ADDRESS)
+  if (RETURN_ADDR_IN_PREVIOUS_FRAME && fndecl_code == BUILT_IN_RETURN_ADDRESS)
     count--;
-#endif
 
   /* Scan back COUNT frames to the specified frame.  */
   for (i = 0; i < count; i++)
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index c6100a1..27ad748 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -1293,7 +1293,7 @@ do {									\
    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
    save area.  */
-#define RETURN_ADDR_IN_PREVIOUS_FRAME
+#define RETURN_ADDR_IN_PREVIOUS_FRAME 1
 
 /* This is the offset of the return address to the true next instruction to be
    executed for the current function.  */
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index 74ca240..14fe4bb 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -615,7 +615,7 @@ typedef struct xtensa_args
 
 /* Define this if the return address of a particular stack frame is
    accessed from the frame pointer of the previous stack frame.  */
-#define RETURN_ADDR_IN_PREVIOUS_FRAME
+#define RETURN_ADDR_IN_PREVIOUS_FRAME 1
 
 /* A C expression whose value is RTL representing the value of the
    return address for the frame COUNT steps up from the current
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 5cef92c..1d54798 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -1095,6 +1095,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define FRAME_GROWS_DOWNWARD 0
 #endif
 
+#ifndef RETURN_ADDR_IN_PREVIOUS_FRAME
+#define RETURN_ADDR_IN_PREVIOUS_FRAME 0
+#endif
+
 /* On most machines, the CFA coincides with the first incoming parm.  */
 #ifndef ARG_POINTER_CFA_OFFSET
 #define ARG_POINTER_CFA_OFFSET(FNDECL) \
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 16d5df7..8d6dfbc 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -2650,7 +2650,7 @@ 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
 the prologue.  @var{frameaddr} is the frame pointer of the @var{count}
 frame, or the frame pointer of the @var{count} @minus{} 1 frame if
-@code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
+@code{RETURN_ADDR_IN_PREVIOUS_FRAME} is nonzero.
 
 The value of the expression must always be the correct address when
 @var{count} is zero, but may be @code{NULL_RTX} if there is no way to
@@ -2658,8 +2658,9 @@ determine the return address of other frames.
 @end defmac
 
 @defmac RETURN_ADDR_IN_PREVIOUS_FRAME
-Define this if the return address of a particular stack frame is accessed
-from the frame pointer of the previous stack frame.
+Define this macro to nonzero value if the return address of a particular
+stack frame is accessed from the frame pointer of the previous stack
+frame.  The zero default for this macro is suitable for most ports.
 @end defmac
 
 @defmac INCOMING_RETURN_ADDR_RTX
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression
  2015-03-03  6:43 [PATCH] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression Max Filippov
@ 2015-03-03 14:51 ` Richard Henderson
  2015-03-03 15:05   ` Max Filippov
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2015-03-03 14:51 UTC (permalink / raw)
  To: Max Filippov, gcc-patches
  Cc: Sterling Augustine, Joseph Myers, David S. Miller, Eric Botcazou

On 03/02/2015 10:42 PM, Max Filippov wrote:
> gcc/
> 	* builtins.c (expand_builtin_return_addr): Add
> 	RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition, remove
> 	surrounding #ifdef.
> 	* config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
> 	definition to 1.
> 	* config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
> 	Likewise.
> 	* defaults.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Define to 0 if
> 	undefined.
> 	doc/tm.texi.in (RETURN_ADDR_IN_PREVIOUS_FRAME): Update
> 	paragraph.

Ok.


r~

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression
  2015-03-03 14:51 ` Richard Henderson
@ 2015-03-03 15:05   ` Max Filippov
  2015-03-03 15:53     ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Max Filippov @ 2015-03-03 15:05 UTC (permalink / raw)
  To: Richard Henderson
  Cc: gcc-patches, Sterling Augustine, Joseph Myers, David S. Miller,
	Eric Botcazou

On Tue, Mar 3, 2015 at 5:51 PM, Richard Henderson <rth@redhat.com> wrote:
> On 03/02/2015 10:42 PM, Max Filippov wrote:
>> gcc/
>>       * builtins.c (expand_builtin_return_addr): Add
>>       RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition, remove
>>       surrounding #ifdef.
>>       * config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
>>       definition to 1.
>>       * config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
>>       Likewise.
>>       * defaults.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Define to 0 if
>>       undefined.
>>       doc/tm.texi.in (RETURN_ADDR_IN_PREVIOUS_FRAME): Update
>>       paragraph.
>
> Ok.

Applied to trunk. Thanks!

-- Max

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression
  2015-03-03 15:05   ` Max Filippov
@ 2015-03-03 15:53     ` H.J. Lu
  2015-03-03 17:01       ` Max Filippov
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2015-03-03 15:53 UTC (permalink / raw)
  To: Max Filippov
  Cc: Richard Henderson, gcc-patches, Sterling Augustine, Joseph Myers,
	David S. Miller, Eric Botcazou

On Tue, Mar 3, 2015 at 7:05 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> On Tue, Mar 3, 2015 at 5:51 PM, Richard Henderson <rth@redhat.com> wrote:
>> On 03/02/2015 10:42 PM, Max Filippov wrote:
>>> gcc/
>>>       * builtins.c (expand_builtin_return_addr): Add
>>>       RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition, remove
>>>       surrounding #ifdef.
>>>       * config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
>>>       definition to 1.
>>>       * config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
>>>       Likewise.
>>>       * defaults.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Define to 0 if
>>>       undefined.
>>>       doc/tm.texi.in (RETURN_ADDR_IN_PREVIOUS_FRAME): Update
>>>       paragraph.
>>
>> Ok.
>
> Applied to trunk. Thanks!
>

I checked in this to fix bootstrap.

-- 
H.J.
---
Index: ChangeLog
===================================================================
--- ChangeLog (revision 221150)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2015-03-03  H.J. Lu  <hongjiu.lu@intel.com>
+
+ * doc/tm.texi: Regenerated.
+
 2015-03-03  Max Filippov  <jcmvbkbc@gmail.com>

  * builtins.c (expand_builtin_return_addr): Add
Index: doc/tm.texi
===================================================================
--- doc/tm.texi (revision 221150)
+++ doc/tm.texi (working copy)
@@ -3045,7 +3045,7 @@ A C expression whose value is RTL repres
 address for the frame @var{count} steps up from the current frame, after
 the prologue.  @var{frameaddr} is the frame pointer of the @var{count}
 frame, or the frame pointer of the @var{count} @minus{} 1 frame if
-@code{RETURN_ADDR_IN_PREVIOUS_FRAME} is defined.
+@code{RETURN_ADDR_IN_PREVIOUS_FRAME} is nonzero.

 The value of the expression must always be the correct address when
 @var{count} is zero, but may be @code{NULL_RTX} if there is no way to
@@ -3053,8 +3053,9 @@ determine the return address of other fr
 @end defmac

 @defmac RETURN_ADDR_IN_PREVIOUS_FRAME
-Define this if the return address of a particular stack frame is accessed
-from the frame pointer of the previous stack frame.
+Define this macro to nonzero value if the return address of a particular
+stack frame is accessed from the frame pointer of the previous stack
+frame.  The zero default for this macro is suitable for most ports.
 @end defmac

 @defmac INCOMING_RETURN_ADDR_RTX

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression
  2015-03-03 15:53     ` H.J. Lu
@ 2015-03-03 17:01       ` Max Filippov
  0 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2015-03-03 17:01 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Richard Henderson, gcc-patches, Sterling Augustine, Joseph Myers,
	David S. Miller, Eric Botcazou

On Tue, Mar 3, 2015 at 6:52 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Mar 3, 2015 at 7:05 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> On Tue, Mar 3, 2015 at 5:51 PM, Richard Henderson <rth@redhat.com> wrote:
>>> On 03/02/2015 10:42 PM, Max Filippov wrote:
>>>> gcc/
>>>>       * builtins.c (expand_builtin_return_addr): Add
>>>>       RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition, remove
>>>>       surrounding #ifdef.
>>>>       * config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
>>>>       definition to 1.
>>>>       * config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
>>>>       Likewise.
>>>>       * defaults.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Define to 0 if
>>>>       undefined.
>>>>       doc/tm.texi.in (RETURN_ADDR_IN_PREVIOUS_FRAME): Update
>>>>       paragraph.
>>>
>>> Ok.
>>
>> Applied to trunk. Thanks!
>>
>
> I checked in this to fix bootstrap.
>
> Index: ChangeLog
> ===================================================================
> --- ChangeLog (revision 221150)
> +++ ChangeLog (working copy)
> @@ -1,3 +1,7 @@
> +2015-03-03  H.J. Lu  <hongjiu.lu@intel.com>
> +
> + * doc/tm.texi: Regenerated.
> +

Oops. Sorry about that.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-03 17:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03  6:43 [PATCH] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression Max Filippov
2015-03-03 14:51 ` Richard Henderson
2015-03-03 15:05   ` Max Filippov
2015-03-03 15:53     ` H.J. Lu
2015-03-03 17:01       ` Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).