diff mbox

[RFC,1/2] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression

Message ID 1425147282-7415-2-git-send-email-jcmvbkbc@gmail.com
State New
Headers show

Commit Message

Max Filippov Feb. 28, 2015, 6:14 p.m. UTC
This allows a target to support both windowed and non-windowed ABI.

2015-02-28  Max Filippov  <jcmvbkbc@gmail.com>

gcc/
	* builtins.c (expand_builtin_return_addr): Add
	RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition.
	* config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
	definition to 1.
	* config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
	Likewise.
---
 gcc/builtins.c             | 2 +-
 gcc/config/sparc/sparc.h   | 2 +-
 gcc/config/xtensa/xtensa.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comments

augustine.sterling@gmail.com March 1, 2015, 5:34 a.m. UTC | #1
On Sat, Feb 28, 2015 at 10:14 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> This allows a target to support both windowed and non-windowed ABI.
>
> 2015-02-28  Max Filippov  <jcmvbkbc@gmail.com>
>
> gcc/
>         * builtins.c (expand_builtin_return_addr): Add
>         RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition.
>         * config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
>         definition to 1.
>         * config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
>         Likewise.

Unfortunately, I can't approve a change to spark.h, even though this
seems quite innocuous to me. I'm not sure why it is even relevant to
xtensa.

Without that, approved.
Max Filippov March 1, 2015, 6:30 a.m. UTC | #2
On Sun, Mar 1, 2015 at 8:34 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Sat, Feb 28, 2015 at 10:14 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> This allows a target to support both windowed and non-windowed ABI.
>>
>> 2015-02-28  Max Filippov  <jcmvbkbc@gmail.com>
>>
>> gcc/
>>         * builtins.c (expand_builtin_return_addr): Add
>>         RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition.
>>         * config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
>>         definition to 1.
>>         * config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
>>         Likewise.
>
> Unfortunately, I can't approve a change to spark.h, even though this
> seems quite innocuous to me. I'm not sure why it is even relevant to
> xtensa.

Ok, I'll cc sparc maintainers.
In the 2/2 RETURN_ADDR_IN_PREVIOUS_FRAME is changed for xtensa
depending on the selected ABI.

> Without that, approved.
Max Filippov March 1, 2015, 6:34 a.m. UTC | #3
Richard, David, Eric,

could you please take a look and possibly approve the below changes for
sparc?

On Sat, Feb 28, 2015 at 9:14 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> This allows a target to support both windowed and non-windowed ABI.
>
> 2015-02-28  Max Filippov  <jcmvbkbc@gmail.com>
>
> gcc/
>         * builtins.c (expand_builtin_return_addr): Add
>         RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition.
>         * config/sparc/sparc.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Change
>         definition to 1.
>         * config/xtensa/xtensa.h (RETURN_ADDR_IN_PREVIOUS_FRAME):
>         Likewise.
> ---
>  gcc/builtins.c             | 2 +-
>  gcc/config/sparc/sparc.h   | 2 +-
>  gcc/config/xtensa/xtensa.h | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/builtins.c b/gcc/builtins.c
> index fb871e6..0cc0c68 100644
> --- a/gcc/builtins.c
> +++ b/gcc/builtins.c
> @@ -803,7 +803,7 @@ expand_builtin_return_addr (enum built_in_function fndecl_code, int count)
>       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
>
> 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
> --
> 1.8.1.4
>
Joseph Myers March 1, 2015, 10:07 p.m. UTC | #4
On Sat, 28 Feb 2015, Max Filippov wrote:

> This allows a target to support both windowed and non-windowed ABI.
> 
> 2015-02-28  Max Filippov  <jcmvbkbc@gmail.com>
> 
> gcc/
> 	* builtins.c (expand_builtin_return_addr): Add
> 	RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition.

If you change the semantics of a target macro you need to update the 
documentation in tm.texi.in.  I'd say you should also change the semantics 
properly to true/false, not a tristate true/false/undefined (i.e., add a 
default 0 to defaults.h and remove the #ifdef).
Max Filippov March 2, 2015, 4:14 a.m. UTC | #5
On Mon, Mar 2, 2015 at 1:07 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Sat, 28 Feb 2015, Max Filippov wrote:
>
> > This allows a target to support both windowed and non-windowed ABI.
> >
> > 2015-02-28  Max Filippov  <jcmvbkbc@gmail.com>
> >
> > gcc/
> >       * builtins.c (expand_builtin_return_addr): Add
> >       RETURN_ADDR_IN_PREVIOUS_FRAME to 'if' condition.
>
> If you change the semantics of a target macro you need to update the
> documentation in tm.texi.in.  I'd say you should also change the semantics
> properly to true/false, not a tristate true/false/undefined (i.e., add a
> default 0 to defaults.h and remove the #ifdef).

Will do. Thanks!

-- Max
David Miller March 2, 2015, 9:10 p.m. UTC | #6
From: Max Filippov <jcmvbkbc@gmail.com>
Date: Sun, 1 Mar 2015 09:34:38 +0300

> Richard, David, Eric,
> 
> could you please take a look and possibly approve the below changes for
> sparc?

I don't have any objection to the sparc changes.
diff mbox

Patch

diff --git a/gcc/builtins.c b/gcc/builtins.c
index fb871e6..0cc0c68 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -803,7 +803,7 @@  expand_builtin_return_addr (enum built_in_function fndecl_code, int count)
      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
 
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