[RFC 1/2] Turn RETURN_ADDR_IN_PREVIOUS_FRAME into C expression

Max Filippov jcmvbkbc@gmail.com
Sat Feb 28 20:35:00 GMT 2015


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



More information about the Gcc-patches mailing list