aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2017-05-08 23:53:14 +0000
committerMax Filippov <jcmvbkbc@gcc.gnu.org>2017-05-08 23:53:14 +0000
commit5057f9e00f35616b7739680d0838bbb76a1e331b (patch)
tree80b16fbd3ca779686cd1e7482ba8b3bf6fb38b2c /gcc
parent26ffe6942c8d5c38600e3385fc1b1ba9c3ea78ee (diff)
downloadgcc-5057f9e00f35616b7739680d0838bbb76a1e331b.zip
gcc-5057f9e00f35616b7739680d0838bbb76a1e331b.tar.gz
gcc-5057f9e00f35616b7739680d0838bbb76a1e331b.tar.bz2
xtensa: add support for SSP
gcc/ 2017-05-08 Max Filippov <jcmvbkbc@gmail.com> * config/xtensa/xtensa-protos.h (xtensa_initial_elimination_offset): New declaration. * config/xtensa/xtensa.c (xtensa_initial_elimination_offset): New function. Move its body from the INITIAL_ELIMINATION_OFFSET macro definition, add case for FRAME_POINTER_REGNUM when FRAME_GROWS_DOWNWARD. * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): New macro definition. (INITIAL_ELIMINATION_OFFSET): Replace body with call to xtensa_initial_elimination_offset. From-SVN: r247771
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/config/xtensa/xtensa-protos.h1
-rw-r--r--gcc/config/xtensa/xtensa.c24
-rw-r--r--gcc/config/xtensa/xtensa.h19
4 files changed, 42 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4ba97f7a..2bfe704 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2017-05-08 Max Filippov <jcmvbkbc@gmail.com>
+
+ * config/xtensa/xtensa-protos.h
+ (xtensa_initial_elimination_offset): New declaration.
+ * config/xtensa/xtensa.c (xtensa_initial_elimination_offset):
+ New function. Move its body from the INITIAL_ELIMINATION_OFFSET
+ macro definition, add case for FRAME_POINTER_REGNUM when
+ FRAME_GROWS_DOWNWARD.
+ * config/xtensa/xtensa.h (FRAME_GROWS_DOWNWARD): New macro
+ definition.
+ (INITIAL_ELIMINATION_OFFSET): Replace body with call to
+ xtensa_initial_elimination_offset.
+
2017-05-08 Nathan Sidwell <nathan@acm.org>
* doc/invoke.texi: Alphabetize -fdump options.
diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h
index 38901b7..dac5657 100644
--- a/gcc/config/xtensa/xtensa-protos.h
+++ b/gcc/config/xtensa/xtensa-protos.h
@@ -73,5 +73,6 @@ extern void xtensa_expand_prologue (void);
extern void xtensa_expand_epilogue (void);
extern void order_regs_for_local_alloc (void);
extern enum reg_class xtensa_regno_to_class (int regno);
+extern HOST_WIDE_INT xtensa_initial_elimination_offset (int from, int to);
#endif /* !__XTENSA_PROTOS_H__ */
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 0181dde..015dd10 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -2676,6 +2676,30 @@ xtensa_frame_pointer_required (void)
return false;
}
+HOST_WIDE_INT
+xtensa_initial_elimination_offset (int from, int to)
+{
+ long frame_size = compute_frame_size (get_frame_size ());
+ HOST_WIDE_INT offset;
+
+ switch (from)
+ {
+ case FRAME_POINTER_REGNUM:
+ if (FRAME_GROWS_DOWNWARD)
+ offset = frame_size - (WINDOW_SIZE * UNITS_PER_WORD)
+ - cfun->machine->callee_save_size;
+ else
+ offset = 0;
+ break;
+ case ARG_POINTER_REGNUM:
+ offset = frame_size;
+ break;
+ default:
+ gcc_unreachable ();
+ }
+
+ return offset;
+}
/* minimum frame = reg save area (4 words) plus static chain (1 word)
and the total number of words must be a multiple of 128 bits. */
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index c32e8ca..08457a4 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -460,9 +460,11 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
+#define FRAME_GROWS_DOWNWARD flag_stack_protect
+
/* Offset within stack frame to start allocating local variables at. */
#define STARTING_FRAME_OFFSET \
- crtl->outgoing_args_size
+ (FRAME_GROWS_DOWNWARD ? 0 : crtl->outgoing_args_size)
/* The ARG_POINTER and FRAME_POINTER are not real Xtensa registers, so
they are eliminated to either the stack pointer or hard frame pointer. */
@@ -474,20 +476,7 @@ enum reg_class
/* Specify the initial difference between the specified pair of registers. */
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
- do { \
- long frame_size = compute_frame_size (get_frame_size ()); \
- switch (FROM) \
- { \
- case FRAME_POINTER_REGNUM: \
- (OFFSET) = 0; \
- break; \
- case ARG_POINTER_REGNUM: \
- (OFFSET) = frame_size; \
- break; \
- default: \
- gcc_unreachable (); \
- } \
- } while (0)
+ (OFFSET) = xtensa_initial_elimination_offset ((FROM), (TO))
/* If defined, the maximum amount of space required for outgoing
arguments will be computed and placed into the variable