summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-23 09:48:31 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-23 09:48:31 +0000
commit8374586c166d040c34ef19a14ac7daffaf4df245 (patch)
treedc789f94038ad4986ddbf27397744b5117bf64e4
parent98a46e07665aad1bbde51d03ad41000141aaf3ca (diff)
downloadgcc-8374586c166d040c34ef19a14ac7daffaf4df245.tar.gz
Convert STARTING_FRAME_OFFSET to a hook
I took the documentation of the FRAME_GROWS_DOWNWARD behaviour from the version that was in most header files, since the one in the manual seemed less clear. The patch deliberately keeps FIRST_PARM_OFFSET(FNDECL) in microblaze_starting_frame_offset; this seems to be a port-local convention and takes advantage of the fact that FIRST_PARM_OFFSET doesn't read FNDECL. 2017-10-23 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * target.def (starting_frame_offset): New hook. * doc/tm.texi (STARTING_FRAME_OFFSET): Remove in favor of... (TARGET_STARTING_FRAME_OFFSET): ...this new hook. * doc/tm.texi.in: Regenerate. * hooks.h (hook_hwi_void_0): Declare. * hooks.c (hook_hwi_void_0): New function. * doc/rtl.texi: Refer to TARGET_STARTING_FRAME_OFFSET instead of STARTING_FRAME_OFFSET. * builtins.c (expand_builtin_setjmp_receiver): Likewise. * reload1.c (reload): Likewise. * cfgexpand.c (expand_used_vars): Use targetm.starting_frame_offset instead of STARTING_FRAME_OFFSET. * function.c (try_fit_stack_local): Likewise. (assign_stack_local_1): Likewise (instantiate_virtual_regs): Likewise. * rtlanal.c (rtx_addr_can_trap_p_1): Likewise. * config/avr/avr.md (nonlocal_goto_receiver): Likewise. * config/aarch64/aarch64.h (STARTING_FRAME_OFFSET): Delete. * config/alpha/alpha.h (STARTING_FRAME_OFFSET): Likewise. * config/arc/arc.h (STARTING_FRAME_OFFSET): Likewise. * config/arm/arm.h (STARTING_FRAME_OFFSET): Likewise. * config/bfin/bfin.h (STARTING_FRAME_OFFSET): Likewise. * config/c6x/c6x.h (STARTING_FRAME_OFFSET): Likewise. * config/cr16/cr16.h (STARTING_FRAME_OFFSET): Likewise. * config/cris/cris.h (STARTING_FRAME_OFFSET): Likewise. * config/fr30/fr30.h (STARTING_FRAME_OFFSET): Likewise. * config/frv/frv.h (STARTING_FRAME_OFFSET): Likewise. * config/ft32/ft32.h (STARTING_FRAME_OFFSET): Likewise. * config/h8300/h8300.h (STARTING_FRAME_OFFSET): Likewise. * config/i386/i386.h (STARTING_FRAME_OFFSET): Likewise. * config/ia64/ia64.h (STARTING_FRAME_OFFSET): Likewise. * config/m32c/m32c.h (STARTING_FRAME_OFFSET): Likewise. * config/m68k/m68k.h (STARTING_FRAME_OFFSET): Likewise. * config/mcore/mcore.h (STARTING_FRAME_OFFSET): Likewise. * config/mn10300/mn10300.h (STARTING_FRAME_OFFSET): Likewise. * config/moxie/moxie.h (STARTING_FRAME_OFFSET): Likewise. * config/msp430/msp430.h (STARTING_FRAME_OFFSET): Likewise. * config/nds32/nds32.h (STARTING_FRAME_OFFSET): Likewise. * config/nios2/nios2.h (STARTING_FRAME_OFFSET): Likewise. * config/nvptx/nvptx.h (STARTING_FRAME_OFFSET): Likewise. * config/pdp11/pdp11.h (STARTING_FRAME_OFFSET): Likewise. * config/riscv/riscv.h (STARTING_FRAME_OFFSET): Likewise. * config/rl78/rl78.h (STARTING_FRAME_OFFSET): Likewise. * config/rx/rx.h (STARTING_FRAME_OFFSET): Likewise. * config/s390/s390.h (STARTING_FRAME_OFFSET): Likewise. * config/sh/sh.h (STARTING_FRAME_OFFSET): Likewise. * config/sparc/sparc.c (sparc_compute_frame_size): Likewise. * config/sparc/sparc.h (STARTING_FRAME_OFFSET): Likewise. * config/spu/spu.h (STARTING_FRAME_OFFSET): Likewise. * config/stormy16/stormy16.h (STARTING_FRAME_OFFSET): Likewise. * config/tilegx/tilegx.h (STARTING_FRAME_OFFSET): Likewise. * config/tilepro/tilepro.h (STARTING_FRAME_OFFSET): Likewise. * config/v850/v850.h (STARTING_FRAME_OFFSET): Likewise. * config/visium/visium.h (STARTING_FRAME_OFFSET): Likewise. * config/avr/avr.h (STARTING_FRAME_OFFSET): Likewise. * config/avr/avr-protos.h (avr_starting_frame_offset): Likewise. * config/avr/avr.c (avr_starting_frame_offset): Make static and return a HOST_WIDE_INT. (avr_builtin_setjmp_frame_value): Use it instead of STARTING_FRAME_OFFSET. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/epiphany/epiphany.h (STARTING_FRAME_OFFSET): Delete. * config/epiphany/epiphany.c (epiphany_starting_frame_offset): New function. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/iq2000/iq2000.h (STARTING_FRAME_OFFSET): Delete. * config/iq2000/iq2000.c (iq2000_starting_frame_offset): New function. (TARGET_CONSTANT_ALIGNMENT): Redefine. * config/lm32/lm32.h (STARTING_FRAME_OFFSET): Delete. * config/lm32/lm32.c (lm32_starting_frame_offset): New function. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/m32r/m32r.h (STARTING_FRAME_OFFSET): Delete. * config/m32r/m32r.c (m32r_starting_frame_offset): New function. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/microblaze/microblaze.h (STARTING_FRAME_OFFSET): Delete. * config/microblaze/microblaze.c (microblaze_starting_frame_offset): New function. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/mips/mips.h (STARTING_FRAME_OFFSET): Delete. * config/mips/mips.c (mips_compute_frame_info): Refer to TARGET_STARTING_FRAME_OFFSET instead of STARTING_FRAME_OFFSET. (mips_starting_frame_offset): New function. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/mmix/mmix.h (STARTING_FRAME_OFFSET): Delete. * config/mmix/mmix-protos.h (mmix_starting_frame_offset): Delete. * config/mmix/mmix.c (mmix_starting_frame_offset): Make static and return a HOST_WIDE_INT. (TARGET_STARTING_FRAME_OFFSET): Redefine. (mmix_initial_elimination_offset): Refer to TARGET_STARTING_FRAME_OFFSET instead of STARTING_FRAME_OFFSET. * config/pa/pa.h (STARTING_FRAME_OFFSET): Delete. * config/pa/pa.c (pa_starting_frame_offset): New function. (pa_compute_frame_size): Use it instead of STARTING_FRAME_OFFSET. (pa_expand_prologue): Likewise. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/powerpcspe/aix.h (STARTING_FRAME_OFFSET): Split out !FRAME_GROWS_DOWNWARD handling to... (RS6000_STARTING_FRAME_OFFSET): ...this new macro. * config/powerpcspe/darwin.h (STARTING_FRAME_OFFSET): Split out !FRAME_GROWS_DOWNWARD handling to... (RS6000_STARTING_FRAME_OFFSET): ...this new macro. * config/powerpcspe/powerpcspe.h (STARTING_FRAME_OFFSET): Split out !FRAME_GROWS_DOWNWARD handling to... (RS6000_STARTING_FRAME_OFFSET): ...this new macro. * config/powerpcspe/powerpcspe.c (TARGET_STARTING_FRAME_OFFSET): Redefine. (rs6000_starting_frame_offset): New function. * config/rs6000/aix.h (STARTING_FRAME_OFFSET): Split out !FRAME_GROWS_DOWNWARD handling to... (RS6000_STARTING_FRAME_OFFSET): ...this new macro. * config/rs6000/darwin.h (STARTING_FRAME_OFFSET): Split out !FRAME_GROWS_DOWNWARD handling to... (RS6000_STARTING_FRAME_OFFSET): ...this new macro. * config/rs6000/rs6000.h (STARTING_FRAME_OFFSET): Split out !FRAME_GROWS_DOWNWARD handling to... (RS6000_STARTING_FRAME_OFFSET): ...this new macro. * config/rs6000/rs6000.c (TARGET_STARTING_FRAME_OFFSET): Refine. (rs6000_starting_frame_offset): New function. * config/vax/elf.h (STARTING_FRAME_OFFSET): Delete. * config/vax/vax.h (STARTING_FRAME_OFFSET): Delete. * config/vax/vax.c (vax_starting_frame_offset): New function. (vax_expand_prologue): Use it instead of STARTING_FRAME_OFFSET. (TARGET_STARTING_FRAME_OFFSET): Redefine. * config/xtensa/xtensa.h (STARTING_FRAME_OFFSET): Delete. * config/xtensa/xtensa.c (xtensa_starting_frame_offset): New function. (TARGET_STARTING_FRAME_OFFSET): Redefine. * system.h (STARTING_FRAME_OFFSET): Poison. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254003 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog130
-rw-r--r--gcc/builtins.c2
-rw-r--r--gcc/cfgexpand.c2
-rw-r--r--gcc/config/aarch64/aarch64.h2
-rw-r--r--gcc/config/alpha/alpha.h7
-rw-r--r--gcc/config/arc/arc.h6
-rw-r--r--gcc/config/arm/arm.h6
-rw-r--r--gcc/config/avr/avr-protos.h1
-rw-r--r--gcc/config/avr/avr.c13
-rw-r--r--gcc/config/avr/avr.h2
-rw-r--r--gcc/config/avr/avr.md5
-rw-r--r--gcc/config/bfin/bfin.h6
-rw-r--r--gcc/config/c6x/c6x.h1
-rw-r--r--gcc/config/cr16/cr16.h2
-rw-r--r--gcc/config/cris/cris.h4
-rw-r--r--gcc/config/epiphany/epiphany.c11
-rw-r--r--gcc/config/epiphany/epiphany.h6
-rw-r--r--gcc/config/fr30/fr30.h9
-rw-r--r--gcc/config/frv/frv.h8
-rw-r--r--gcc/config/ft32/ft32.h4
-rw-r--r--gcc/config/h8300/h8300.h7
-rw-r--r--gcc/config/i386/i386.h6
-rw-r--r--gcc/config/ia64/ia64.h4
-rw-r--r--gcc/config/iq2000/iq2000.c12
-rw-r--r--gcc/config/iq2000/iq2000.h3
-rw-r--r--gcc/config/lm32/lm32.c12
-rw-r--r--gcc/config/lm32/lm32.h2
-rw-r--r--gcc/config/m32c/m32c.h1
-rw-r--r--gcc/config/m32r/m32r.c13
-rw-r--r--gcc/config/m32r/m32r.h9
-rw-r--r--gcc/config/m68k/m68k.h1
-rw-r--r--gcc/config/mcore/mcore.h6
-rw-r--r--gcc/config/microblaze/microblaze.c11
-rw-r--r--gcc/config/microblaze/microblaze.h4
-rw-r--r--gcc/config/mips/mips.c16
-rw-r--r--gcc/config/mips/mips.h8
-rw-r--r--gcc/config/mmix/mmix-protos.h1
-rw-r--r--gcc/config/mmix/mmix.c10
-rw-r--r--gcc/config/mmix/mmix.h3
-rw-r--r--gcc/config/mn10300/mn10300.h7
-rw-r--r--gcc/config/moxie/moxie.h4
-rw-r--r--gcc/config/msp430/msp430.h1
-rw-r--r--gcc/config/nds32/nds32.h2
-rw-r--r--gcc/config/nios2/nios2.h1
-rw-r--r--gcc/config/nvptx/nvptx.h1
-rw-r--r--gcc/config/pa/pa.c23
-rw-r--r--gcc/config/pa/pa.h11
-rw-r--r--gcc/config/pdp11/pdp11.h6
-rw-r--r--gcc/config/powerpcspe/aix.h12
-rw-r--r--gcc/config/powerpcspe/darwin.h10
-rw-r--r--gcc/config/powerpcspe/powerpcspe.c13
-rw-r--r--gcc/config/powerpcspe/powerpcspe.h16
-rw-r--r--gcc/config/riscv/riscv.h2
-rw-r--r--gcc/config/rl78/rl78.h1
-rw-r--r--gcc/config/rs6000/aix.h12
-rw-r--r--gcc/config/rs6000/darwin.h10
-rw-r--r--gcc/config/rs6000/rs6000.c13
-rw-r--r--gcc/config/rs6000/rs6000.h16
-rw-r--r--gcc/config/rx/rx.h1
-rw-r--r--gcc/config/s390/s390.h3
-rw-r--r--gcc/config/sh/sh.h4
-rw-r--r--gcc/config/sparc/sparc.c5
-rw-r--r--gcc/config/sparc/sparc.h6
-rw-r--r--gcc/config/spu/spu.h2
-rw-r--r--gcc/config/stormy16/stormy16.h2
-rw-r--r--gcc/config/tilegx/tilegx.h1
-rw-r--r--gcc/config/tilepro/tilepro.h1
-rw-r--r--gcc/config/v850/v850.h7
-rw-r--r--gcc/config/vax/elf.h4
-rw-r--r--gcc/config/vax/vax.c15
-rw-r--r--gcc/config/vax/vax.h6
-rw-r--r--gcc/config/visium/visium.h11
-rw-r--r--gcc/config/xtensa/xtensa.c14
-rw-r--r--gcc/config/xtensa/xtensa.h4
-rw-r--r--gcc/doc/rtl.texi4
-rw-r--r--gcc/doc/tm.texi19
-rw-r--r--gcc/doc/tm.texi.in13
-rw-r--r--gcc/function.c6
-rw-r--r--gcc/hooks.c6
-rw-r--r--gcc/hooks.h2
-rw-r--r--gcc/reload1.c2
-rw-r--r--gcc/rtlanal.c4
-rw-r--r--gcc/system.h3
-rw-r--r--gcc/target.def10
84 files changed, 370 insertions, 302 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3fc03ad08cd..ebda3cd5500 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,135 @@
2017-10-23 Richard Sandiford <richard.sandiford@linaro.org>
+ * target.def (starting_frame_offset): New hook.
+ * doc/tm.texi (STARTING_FRAME_OFFSET): Remove in favor of...
+ (TARGET_STARTING_FRAME_OFFSET): ...this new hook.
+ * doc/tm.texi.in: Regenerate.
+ * hooks.h (hook_hwi_void_0): Declare.
+ * hooks.c (hook_hwi_void_0): New function.
+ * doc/rtl.texi: Refer to TARGET_STARTING_FRAME_OFFSET instead of
+ STARTING_FRAME_OFFSET.
+ * builtins.c (expand_builtin_setjmp_receiver): Likewise.
+ * reload1.c (reload): Likewise.
+ * cfgexpand.c (expand_used_vars): Use targetm.starting_frame_offset
+ instead of STARTING_FRAME_OFFSET.
+ * function.c (try_fit_stack_local): Likewise.
+ (assign_stack_local_1): Likewise
+ (instantiate_virtual_regs): Likewise.
+ * rtlanal.c (rtx_addr_can_trap_p_1): Likewise.
+ * config/avr/avr.md (nonlocal_goto_receiver): Likewise.
+ * config/aarch64/aarch64.h (STARTING_FRAME_OFFSET): Delete.
+ * config/alpha/alpha.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/arc/arc.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/arm/arm.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/bfin/bfin.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/c6x/c6x.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/cr16/cr16.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/cris/cris.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/fr30/fr30.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/frv/frv.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/ft32/ft32.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/h8300/h8300.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/i386/i386.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/ia64/ia64.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/m32c/m32c.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/m68k/m68k.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/mcore/mcore.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/mn10300/mn10300.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/moxie/moxie.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/msp430/msp430.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/nds32/nds32.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/nios2/nios2.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/nvptx/nvptx.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/pdp11/pdp11.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/riscv/riscv.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/rl78/rl78.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/rx/rx.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/s390/s390.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/sh/sh.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/sparc/sparc.c (sparc_compute_frame_size): Likewise.
+ * config/sparc/sparc.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/spu/spu.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/stormy16/stormy16.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/tilegx/tilegx.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/tilepro/tilepro.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/v850/v850.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/visium/visium.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/avr/avr.h (STARTING_FRAME_OFFSET): Likewise.
+ * config/avr/avr-protos.h (avr_starting_frame_offset): Likewise.
+ * config/avr/avr.c (avr_starting_frame_offset): Make static and
+ return a HOST_WIDE_INT.
+ (avr_builtin_setjmp_frame_value): Use it instead of
+ STARTING_FRAME_OFFSET.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/epiphany/epiphany.h (STARTING_FRAME_OFFSET): Delete.
+ * config/epiphany/epiphany.c (epiphany_starting_frame_offset):
+ New function.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/iq2000/iq2000.h (STARTING_FRAME_OFFSET): Delete.
+ * config/iq2000/iq2000.c (iq2000_starting_frame_offset): New function.
+ (TARGET_CONSTANT_ALIGNMENT): Redefine.
+ * config/lm32/lm32.h (STARTING_FRAME_OFFSET): Delete.
+ * config/lm32/lm32.c (lm32_starting_frame_offset): New function.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/m32r/m32r.h (STARTING_FRAME_OFFSET): Delete.
+ * config/m32r/m32r.c (m32r_starting_frame_offset): New function.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/microblaze/microblaze.h (STARTING_FRAME_OFFSET): Delete.
+ * config/microblaze/microblaze.c (microblaze_starting_frame_offset):
+ New function.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/mips/mips.h (STARTING_FRAME_OFFSET): Delete.
+ * config/mips/mips.c (mips_compute_frame_info): Refer to
+ TARGET_STARTING_FRAME_OFFSET instead of STARTING_FRAME_OFFSET.
+ (mips_starting_frame_offset): New function.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/mmix/mmix.h (STARTING_FRAME_OFFSET): Delete.
+ * config/mmix/mmix-protos.h (mmix_starting_frame_offset): Delete.
+ * config/mmix/mmix.c (mmix_starting_frame_offset): Make static
+ and return a HOST_WIDE_INT.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ (mmix_initial_elimination_offset): Refer to
+ TARGET_STARTING_FRAME_OFFSET instead of STARTING_FRAME_OFFSET.
+ * config/pa/pa.h (STARTING_FRAME_OFFSET): Delete.
+ * config/pa/pa.c (pa_starting_frame_offset): New function.
+ (pa_compute_frame_size): Use it instead of STARTING_FRAME_OFFSET.
+ (pa_expand_prologue): Likewise.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/powerpcspe/aix.h (STARTING_FRAME_OFFSET): Split out
+ !FRAME_GROWS_DOWNWARD handling to...
+ (RS6000_STARTING_FRAME_OFFSET): ...this new macro.
+ * config/powerpcspe/darwin.h (STARTING_FRAME_OFFSET): Split out
+ !FRAME_GROWS_DOWNWARD handling to...
+ (RS6000_STARTING_FRAME_OFFSET): ...this new macro.
+ * config/powerpcspe/powerpcspe.h (STARTING_FRAME_OFFSET): Split out
+ !FRAME_GROWS_DOWNWARD handling to...
+ (RS6000_STARTING_FRAME_OFFSET): ...this new macro.
+ * config/powerpcspe/powerpcspe.c (TARGET_STARTING_FRAME_OFFSET):
+ Redefine.
+ (rs6000_starting_frame_offset): New function.
+ * config/rs6000/aix.h (STARTING_FRAME_OFFSET): Split out
+ !FRAME_GROWS_DOWNWARD handling to...
+ (RS6000_STARTING_FRAME_OFFSET): ...this new macro.
+ * config/rs6000/darwin.h (STARTING_FRAME_OFFSET): Split out
+ !FRAME_GROWS_DOWNWARD handling to...
+ (RS6000_STARTING_FRAME_OFFSET): ...this new macro.
+ * config/rs6000/rs6000.h (STARTING_FRAME_OFFSET): Split out
+ !FRAME_GROWS_DOWNWARD handling to...
+ (RS6000_STARTING_FRAME_OFFSET): ...this new macro.
+ * config/rs6000/rs6000.c (TARGET_STARTING_FRAME_OFFSET): Refine.
+ (rs6000_starting_frame_offset): New function.
+ * config/vax/elf.h (STARTING_FRAME_OFFSET): Delete.
+ * config/vax/vax.h (STARTING_FRAME_OFFSET): Delete.
+ * config/vax/vax.c (vax_starting_frame_offset): New function.
+ (vax_expand_prologue): Use it instead of STARTING_FRAME_OFFSET.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * config/xtensa/xtensa.h (STARTING_FRAME_OFFSET): Delete.
+ * config/xtensa/xtensa.c (xtensa_starting_frame_offset): New function.
+ (TARGET_STARTING_FRAME_OFFSET): Redefine.
+ * system.h (STARTING_FRAME_OFFSET): Poison.
+
+2017-10-23 Richard Sandiford <richard.sandiford@linaro.org>
+
* tree-vect-loop.c (vect_create_epilog_for_reduction): Use
SCALAR_TYPE_MODE instead of TYPE_MODE.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index d3498bb16c4..29778fc50c3 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -900,7 +900,7 @@ expand_builtin_setjmp_receiver (rtx receiver_label)
to the underlying register (fp in this case) that makes
the original assignment true.
So the following insn will actually be decrementing fp by
- STARTING_FRAME_OFFSET. */
+ TARGET_STARTING_FRAME_OFFSET. */
emit_move_insn (virtual_stack_vars_rtx, hard_frame_pointer_rtx);
/* Restoring the frame pointer also modifies the hard frame pointer.
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 79204bd49e4..00efe141213 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2025,7 +2025,7 @@ expand_used_vars (void)
/* Compute the phase of the stack frame for this function. */
{
int align = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
- int off = STARTING_FRAME_OFFSET % align;
+ int off = targetm.starting_frame_offset () % align;
frame_phase = off ? align - off : 0;
}
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 98d93c69e23..75fda01a6f4 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -541,8 +541,6 @@ extern enum aarch64_processor aarch64_tune;
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
-
#define ACCUMULATE_OUTGOING_ARGS 1
#define FIRST_PARM_OFFSET(FNDECL) 0
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index a2878c64e94..257c1de2422 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -493,13 +493,6 @@ enum reg_class {
goes at a more negative offset in the frame. */
/* #define FRAME_GROWS_DOWNWARD 0 */
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-
-#define STARTING_FRAME_OFFSET 0
-
/* If we generate an insn to push BYTES bytes,
this says how many the stack pointer really advances by.
On Alpha, don't define this because there are no push insns. */
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index 91a4c90ac93..1d9063ad74a 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -658,12 +658,6 @@ extern enum reg_class arc_regno_reg_class[];
goes at a more negative offset in the frame. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* Offset from the stack pointer register to the first location at which
outgoing arguments are placed. */
#define STACK_POINTER_OFFSET (0)
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index 7e1eeb5254c..9567f6df73a 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1256,12 +1256,6 @@ enum reg_class
&& crtl->outgoing_args_size != 0 \
? UNITS_PER_WORD : 0)
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* If we generate an insn to push BYTES bytes,
this says how many the stack pointer really advances by. */
/* The push insns do not do this rounding implicitly.
diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index e4306ea5d63..9ed94800797 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -84,7 +84,6 @@ extern void avr_expand_prologue (void);
extern void avr_expand_epilogue (bool);
extern bool avr_emit_movmemhi (rtx*);
extern int avr_epilogue_uses (int regno);
-extern int avr_starting_frame_offset (void);
extern void avr_output_addr_vec (rtx_insn*, rtx);
extern const char *avr_out_sbxx_branch (rtx_insn *insn, rtx operands[]);
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index d9c8277eff5..b1d8a84d154 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -1153,11 +1153,11 @@ avr_outgoing_args_size (void)
}
-/* Implement `STARTING_FRAME_OFFSET'. */
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
/* This is the offset from the frame pointer register to the first stack slot
that contains a variable living in the frame. */
-int
+static HOST_WIDE_INT
avr_starting_frame_offset (void)
{
return 1 + avr_outgoing_args_size ();
@@ -1314,8 +1314,8 @@ avr_build_builtin_va_list (void)
/* Implement `TARGET_BUILTIN_SETJMP_FRAME_VALUE'. */
/* Actual start of frame is virtual_stack_vars_rtx this is offset from
- frame pointer by +STARTING_FRAME_OFFSET.
- Using saved frame = virtual_stack_vars_rtx - STARTING_FRAME_OFFSET
+ frame pointer by +TARGET_STARTING_FRAME_OFFSET.
+ Using saved frame = virtual_stack_vars_rtx - TARGET_STARTING_FRAME_OFFSET
avoids creating add/sub of offset in nonlocal goto and setjmp. */
static rtx
@@ -1323,7 +1323,7 @@ avr_builtin_setjmp_frame_value (void)
{
rtx xval = gen_reg_rtx (Pmode);
emit_insn (gen_subhi3 (xval, virtual_stack_vars_rtx,
- gen_int_mode (STARTING_FRAME_OFFSET, Pmode)));
+ gen_int_mode (avr_starting_frame_offset (), Pmode)));
return xval;
}
@@ -14789,6 +14789,9 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg,
#undef TARGET_LEGITIMATE_COMBINED_INSN
#define TARGET_LEGITIMATE_COMBINED_INSN avr_legitimate_combined_insn
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET avr_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 6d00dbd5d6e..2272df4afcc 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -284,8 +284,6 @@ enum reg_class {
#define STACK_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET avr_starting_frame_offset()
-
#define STACK_POINTER_OFFSET 1
#define FIRST_PARM_OFFSET(FUNDECL) 0
diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md
index 436f036704a..14f9298f305 100644
--- a/gcc/config/avr/avr.md
+++ b/gcc/config/avr/avr.md
@@ -334,10 +334,9 @@
(unspec_volatile:HI [(const_int 0)] UNSPECV_GOTO_RECEIVER))]
""
{
+ rtx offset = gen_int_mode (targetm.starting_frame_offset (), Pmode);
emit_move_insn (virtual_stack_vars_rtx,
- gen_rtx_PLUS (Pmode, hard_frame_pointer_rtx,
- gen_int_mode (STARTING_FRAME_OFFSET,
- Pmode)));
+ gen_rtx_PLUS (Pmode, hard_frame_pointer_rtx, offset));
/* ; This might change the hard frame pointer in ways that aren't
; apparent to early optimization passes, so force a clobber. */
emit_clobber (hard_frame_pointer_rtx);
diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
index 787600f3308..e15a05d8784 100644
--- a/gcc/config/bfin/bfin.h
+++ b/gcc/config/bfin/bfin.h
@@ -252,12 +252,6 @@ extern const char *bfin_library_id_string;
it. */
#define FIRST_PARM_OFFSET(DECL) 0
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* Register to use for pushing function arguments. */
#define STACK_POINTER_REGNUM REG_P6
diff --git a/gcc/config/c6x/c6x.h b/gcc/config/c6x/c6x.h
index c8c407369d3..233ac13fc8c 100644
--- a/gcc/config/c6x/c6x.h
+++ b/gcc/config/c6x/c6x.h
@@ -298,7 +298,6 @@ enum reg_class
#define STACK_POINTER_OFFSET 4
/* Likewise for AP (which is the incoming stack pointer). */
#define FIRST_PARM_OFFSET(fundecl) 4
-#define STARTING_FRAME_OFFSET 0
#define FRAME_GROWS_DOWNWARD 1
#define STACK_GROWS_DOWNWARD 1
diff --git a/gcc/config/cr16/cr16.h b/gcc/config/cr16/cr16.h
index 143a1dbfda3..29f5b852ff6 100644
--- a/gcc/config/cr16/cr16.h
+++ b/gcc/config/cr16/cr16.h
@@ -349,8 +349,6 @@ enum reg_class
/* Stack layout and calling conventions. */
#define STACK_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
-
#define STACK_POINTER_REGNUM 15
#define FRAME_POINTER_REGNUM 13
diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h
index 570e2d9defe..f9149c717a7 100644
--- a/gcc/config/cris/cris.h
+++ b/gcc/config/cris/cris.h
@@ -589,10 +589,6 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
#define FRAME_GROWS_DOWNWARD 1
-/* It seems to be indicated in the code (at least 2.1) that this is
- better a constant, and best 0. */
-#define STARTING_FRAME_OFFSET 0
-
#define FIRST_PARM_OFFSET(FNDECL) 0
#define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \
diff --git a/gcc/config/epiphany/epiphany.c b/gcc/config/epiphany/epiphany.c
index d1d9ee9998d..26b0f3cca74 100644
--- a/gcc/config/epiphany/epiphany.c
+++ b/gcc/config/epiphany/epiphany.c
@@ -176,6 +176,9 @@ static rtx_insn *frame_insn (rtx);
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT epiphany_constant_alignment
+
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET epiphany_starting_frame_offset
bool
epiphany_is_interrupt_p (tree decl)
@@ -3028,4 +3031,12 @@ epiphany_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return align;
}
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
+
+static HOST_WIDE_INT
+epiphany_starting_frame_offset (void)
+{
+ return epiphany_stack_offset;
+}
+
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/epiphany/epiphany.h b/gcc/config/epiphany/epiphany.h
index 290ea20a583..c0767b4642a 100644
--- a/gcc/config/epiphany/epiphany.h
+++ b/gcc/config/epiphany/epiphany.h
@@ -447,12 +447,6 @@ typedef struct GTY (()) machine_function
goes at a more negative offset in the frame. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET epiphany_stack_offset
-
/* Offset from the stack pointer register to the first location at which
outgoing arguments are placed. */
#define STACK_POINTER_OFFSET epiphany_stack_offset
diff --git a/gcc/config/fr30/fr30.h b/gcc/config/fr30/fr30.h
index c4485096f0f..8bcabf59299 100644
--- a/gcc/config/fr30/fr30.h
+++ b/gcc/config/fr30/fr30.h
@@ -345,15 +345,6 @@ enum reg_class
are at negative offsets from the frame pointer. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset from the frame pointer to the first local variable slot to be
- allocated.
-
- If `FRAME_GROWS_DOWNWARD', find the next slot's offset by subtracting the
- first slot's length from `STARTING_FRAME_OFFSET'. Otherwise, it is found by
- adding the length of the first slot to the value `STARTING_FRAME_OFFSET'. */
-/* #define STARTING_FRAME_OFFSET -4 */
-#define STARTING_FRAME_OFFSET 0
-
/* Offset from the stack pointer register to the first location at which
outgoing arguments are placed. If not specified, the default value of zero
is used. This is the proper value for most machines.
diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
index 44a73e08f90..7403e1ae621 100644
--- a/gcc/config/frv/frv.h
+++ b/gcc/config/frv/frv.h
@@ -966,14 +966,6 @@ typedef struct frv_stack {
are at negative offsets from the frame pointer. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset from the frame pointer to the first local variable slot to be
- allocated.
-
- If `FRAME_GROWS_DOWNWARD', find the next slot's offset by subtracting the
- first slot's length from `STARTING_FRAME_OFFSET'. Otherwise, it is found by
- adding the length of the first slot to the value `STARTING_FRAME_OFFSET'. */
-#define STARTING_FRAME_OFFSET 0
-
/* Offset from the stack pointer register to the first location at which
outgoing arguments are placed. If not specified, the default value of zero
is used. This is the proper value for most machines.
diff --git a/gcc/config/ft32/ft32.h b/gcc/config/ft32/ft32.h
index 32aa32095ea..d52bb9af17c 100644
--- a/gcc/config/ft32/ft32.h
+++ b/gcc/config/ft32/ft32.h
@@ -233,10 +233,6 @@ enum reg_class
pointer to a smaller address. */
#define STACK_GROWS_DOWNWARD 1
-/* Offset from the frame pointer to the first local variable slot to
- be allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* Offset from the argument pointer register to the first argument's
address. On some machines it may depend on the data type of the
function. */
diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h
index 8ff38605a23..9ba82a76ab9 100644
--- a/gcc/config/h8300/h8300.h
+++ b/gcc/config/h8300/h8300.h
@@ -352,13 +352,6 @@ enum reg_class {
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-
-#define STARTING_FRAME_OFFSET 0
-
/* If we generate an insn to push BYTES bytes,
this says how many the stack pointer really advances by.
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 8fbad16b408..4a71977808e 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1523,12 +1523,6 @@ enum reg_class
goes at a more negative offset in the frame. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* If we generate an insn to push BYTES bytes, this says how many the stack
pointer really advances by. On 386, we have pushw instruction that
decrements by exactly 2 no matter what the position was, there is no pushb.
diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
index 4a9313e1d49..e7073d1cf20 100644
--- a/gcc/config/ia64/ia64.h
+++ b/gcc/config/ia64/ia64.h
@@ -779,10 +779,6 @@ enum reg_class
are at negative offsets from the frame pointer. */
#define FRAME_GROWS_DOWNWARD 0
-/* Offset from the frame pointer to the first local variable slot to
- be allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* Offset from the stack pointer register to the first location at which
outgoing arguments are placed. If not specified, the default value of zero
is used. This is the proper value for most machines. */
diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c
index 297bd2bb0d4..2e0c6f6a975 100644
--- a/gcc/config/iq2000/iq2000.c
+++ b/gcc/config/iq2000/iq2000.c
@@ -181,6 +181,7 @@ static bool iq2000_print_operand_punct_valid_p (unsigned char code);
static bool iq2000_hard_regno_mode_ok (unsigned int, machine_mode);
static bool iq2000_modes_tieable_p (machine_mode, machine_mode);
static HOST_WIDE_INT iq2000_constant_alignment (const_tree, HOST_WIDE_INT);
+static HOST_WIDE_INT iq2000_starting_frame_offset (void);
#undef TARGET_INIT_BUILTINS
#define TARGET_INIT_BUILTINS iq2000_init_builtins
@@ -268,6 +269,9 @@ static HOST_WIDE_INT iq2000_constant_alignment (const_tree, HOST_WIDE_INT);
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT iq2000_constant_alignment
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET iq2000_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Return nonzero if we split the address into high and low parts. */
@@ -3546,4 +3550,12 @@ iq2000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return align;
}
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
+
+static HOST_WIDE_INT
+iq2000_starting_frame_offset (void)
+{
+ return crtl->outgoing_args_size;
+}
+
#include "gt-iq2000.h"
diff --git a/gcc/config/iq2000/iq2000.h b/gcc/config/iq2000/iq2000.h
index 58c3597fd78..72122e27577 100644
--- a/gcc/config/iq2000/iq2000.h
+++ b/gcc/config/iq2000/iq2000.h
@@ -215,9 +215,6 @@ enum reg_class
#define FRAME_GROWS_DOWNWARD 0
-#define STARTING_FRAME_OFFSET \
- (crtl->outgoing_args_size)
-
/* Use the default value zero. */
/* #define STACK_POINTER_OFFSET 0 */
diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c
index a4aade494d6..1d6cfa0dc8a 100644
--- a/gcc/config/lm32/lm32.c
+++ b/gcc/config/lm32/lm32.c
@@ -79,6 +79,7 @@ static void lm32_function_arg_advance (cumulative_args_t cum,
const_tree type, bool named);
static bool lm32_hard_regno_mode_ok (unsigned int, machine_mode);
static bool lm32_modes_tieable_p (machine_mode, machine_mode);
+static HOST_WIDE_INT lm32_starting_frame_offset (void);
#undef TARGET_OPTION_OVERRIDE
#define TARGET_OPTION_OVERRIDE lm32_option_override
@@ -116,6 +117,9 @@ static bool lm32_modes_tieable_p (machine_mode, machine_mode);
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET lm32_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Current frame information calculated by lm32_compute_frame_size. */
@@ -1249,3 +1253,11 @@ lm32_modes_tieable_p (machine_mode mode1, machine_mode mode2)
&& GET_MODE_SIZE (mode1) <= UNITS_PER_WORD
&& GET_MODE_SIZE (mode2) <= UNITS_PER_WORD);
}
+
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
+
+static HOST_WIDE_INT
+lm32_starting_frame_offset (void)
+{
+ return UNITS_PER_WORD;
+}
diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
index 605bd68ca7c..8f2035455ae 100644
--- a/gcc/config/lm32/lm32.h
+++ b/gcc/config/lm32/lm32.h
@@ -204,8 +204,6 @@ enum reg_class
#define STACK_POINTER_OFFSET (UNITS_PER_WORD)
-#define STARTING_FRAME_OFFSET (UNITS_PER_WORD)
-
#define FIRST_PARM_OFFSET(FNDECL) (UNITS_PER_WORD)
#define STACK_POINTER_REGNUM SP_REGNUM
diff --git a/gcc/config/m32c/m32c.h b/gcc/config/m32c/m32c.h
index 594288b76e9..4bf67fb9c67 100644
--- a/gcc/config/m32c/m32c.h
+++ b/gcc/config/m32c/m32c.h
@@ -421,7 +421,6 @@ enum reg_class
#define STACK_PUSH_CODE PRE_DEC
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
#define FIRST_PARM_OFFSET(F) 0
#define RETURN_ADDR_RTX(COUNT,FA) m32c_return_addr_rtx (COUNT)
diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c
index aefab935c34..f1044575550 100644
--- a/gcc/config/m32r/m32r.c
+++ b/gcc/config/m32r/m32r.c
@@ -104,6 +104,7 @@ static bool m32r_legitimate_constant_p (machine_mode, rtx);
static bool m32r_attribute_identifier (const_tree);
static bool m32r_hard_regno_mode_ok (unsigned int, machine_mode);
static bool m32r_modes_tieable_p (machine_mode, machine_mode);
+static HOST_WIDE_INT m32r_starting_frame_offset (void);
/* M32R specific attributes. */
@@ -220,6 +221,9 @@ static const struct attribute_spec m32r_attribute_table[] =
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET m32r_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Called by m32r_option_override to initialize various things. */
@@ -2959,3 +2963,12 @@ m32r_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
&& CONST_INT_P (XEXP (XEXP (x, 0), 1))
&& UINTVAL (XEXP (XEXP (x, 0), 1)) > 32767);
}
+
+/* Implement TARGET_STARTING_FRAME_OFFSET. The frame pointer points at
+ the same place as the stack pointer, except if alloca has been called. */
+
+static HOST_WIDE_INT
+m32r_starting_frame_offset (void)
+{
+ return M32R_STACK_ALIGN (crtl->outgoing_args_size);
+}
diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h
index 5b2a93bfca8..0fa4c5f24e1 100644
--- a/gcc/config/m32r/m32r.h
+++ b/gcc/config/m32r/m32r.h
@@ -492,15 +492,6 @@ extern enum reg_class m32r_regno_reg_class[FIRST_PSEUDO_REGISTER];
pointer to a smaller address. */
#define STACK_GROWS_DOWNWARD 1
-/* Offset from frame pointer to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-/* The frame pointer points at the same place as the stack pointer, except if
- alloca has been called. */
-#define STARTING_FRAME_OFFSET \
- M32R_STACK_ALIGN (crtl->outgoing_args_size)
-
/* Offset from the stack pointer register to the first location at which
outgoing arguments are placed. */
#define STACK_POINTER_OFFSET 0
diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h
index 2fefc7251ba..97693cbf549 100644
--- a/gcc/config/m68k/m68k.h
+++ b/gcc/config/m68k/m68k.h
@@ -467,7 +467,6 @@ extern enum reg_class regno_reg_class[];
#define STACK_GROWS_DOWNWARD 1
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
/* On the 680x0, sp@- in a byte insn really pushes a word.
On the ColdFire, sp@- in a byte insn pushes just a byte. */
diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h
index f411186e567..50d087c1cd5 100644
--- a/gcc/config/mcore/mcore.h
+++ b/gcc/config/mcore/mcore.h
@@ -390,12 +390,6 @@ extern const enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
makes the stack pointer a smaller address. */
#define STACK_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* If defined, the maximum amount of space required for outgoing arguments
will be computed and placed into the variable
`crtl->outgoing_args_size'. No space will be pushed
diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
index 53ca016ce65..74875238774 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -3810,6 +3810,14 @@ microblaze_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return MAX (align, BITS_PER_WORD);
return align;
}
+
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
+
+static HOST_WIDE_INT
+microblaze_starting_frame_offset (void)
+{
+ return (crtl->outgoing_args_size + FIRST_PARM_OFFSET(FNDECL));
+}
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO microblaze_encode_section_info
@@ -3917,6 +3925,9 @@ microblaze_constant_alignment (const_tree exp, HOST_WIDE_INT align)
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT microblaze_constant_alignment
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET microblaze_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-microblaze.h"
diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
index 2fc7fc50a15..59cc1cc2e37 100644
--- a/gcc/config/microblaze/microblaze.h
+++ b/gcc/config/microblaze/microblaze.h
@@ -402,10 +402,6 @@ extern enum reg_class microblaze_regno_to_class[];
#define STACK_GROWS_DOWNWARD 1
-/* Changed the starting frame offset to including the new link stuff */
-#define STARTING_FRAME_OFFSET \
- (crtl->outgoing_args_size + FIRST_PARM_OFFSET(FNDECL))
-
/* The return address for the current frame is in r31 if this is a leaf
function. Otherwise, it is on the stack. It is at a variable offset
from sp/fp/ap, so we define a fake hard register rap which is a
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 41333755b84..149ad8ebd81 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -10956,7 +10956,7 @@ mips_compute_frame_info (void)
if we know that none of the called functions will use this space.
But if the target-independent frame size is nonzero, we have already
- committed to allocating these in STARTING_FRAME_OFFSET for
+ committed to allocating these in TARGET_STARTING_FRAME_OFFSET for
!FRAME_GROWS_DOWNWARD. */
if ((size == 0 || FRAME_GROWS_DOWNWARD)
@@ -22346,6 +22346,17 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return MAX (align, BITS_PER_WORD);
return align;
}
+
+/* Implement TARGET_STARTING_FRAME_OFFSET. See mips_compute_frame_info
+ for details about the frame layout. */
+
+static HOST_WIDE_INT
+mips_starting_frame_offset (void)
+{
+ if (FRAME_GROWS_DOWNWARD)
+ return 0;
+ return crtl->outgoing_args_size + MIPS_GP_SAVE_AREA_SIZE;
+}
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
@@ -22647,6 +22658,9 @@ mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT mips_constant_alignment
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET mips_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-mips.h"
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index a2d8c7c1350..550d283158e 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -2298,14 +2298,6 @@ enum reg_class
#define MIPS_GP_SAVE_AREA_SIZE \
(TARGET_CALL_CLOBBERED_GP ? MIPS_STACK_ALIGN (UNITS_PER_WORD) : 0)
-/* The offset of the first local variable from the frame pointer. See
- mips_compute_frame_info for details about the frame layout. */
-
-#define STARTING_FRAME_OFFSET \
- (FRAME_GROWS_DOWNWARD \
- ? 0 \
- : crtl->outgoing_args_size + MIPS_GP_SAVE_AREA_SIZE)
-
#define RETURN_ADDR_RTX mips_return_addr
/* Mask off the MIPS16 ISA bit in unwind addresses.
diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h
index 6c38924f479..4e3a7520765 100644
--- a/gcc/config/mmix/mmix-protos.h
+++ b/gcc/config/mmix/mmix-protos.h
@@ -21,7 +21,6 @@ along with GCC; see the file COPYING3. If not see
extern void mmix_init_expanders (void);
extern int mmix_eh_return_data_regno (int);
extern int mmix_initial_elimination_offset (int, int);
-extern int mmix_starting_frame_offset (void);
extern int mmix_function_arg_regno_p (int, int);
extern void mmix_function_profiler (FILE *, int);
extern int mmix_reversible_cc_mode (machine_mode);
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index 09e752dca0d..e9115941e1e 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -169,6 +169,7 @@ static void mmix_print_operand_address (FILE *, machine_mode, rtx);
static bool mmix_print_operand_punct_valid_p (unsigned char);
static void mmix_conditional_register_usage (void);
static HOST_WIDE_INT mmix_constant_alignment (const_tree, HOST_WIDE_INT);
+static HOST_WIDE_INT mmix_starting_frame_offset (void);
/* Target structure macros. Listed by node. See `Using and Porting GCC'
for a general description. */
@@ -286,6 +287,9 @@ static HOST_WIDE_INT mmix_constant_alignment (const_tree, HOST_WIDE_INT);
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT mmix_constant_alignment
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET mmix_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Functions that are expansions for target macros.
@@ -498,9 +502,9 @@ mmix_dynamic_chain_address (rtx frame)
return plus_constant (Pmode, frame, -8);
}
-/* STARTING_FRAME_OFFSET. */
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
-int
+static HOST_WIDE_INT
mmix_starting_frame_offset (void)
{
/* The old frame pointer is in the slot below the new one, so
@@ -566,7 +570,7 @@ mmix_initial_elimination_offset (int fromreg, int toreg)
counted; the others go on the register stack.
The frame-pointer is counted too if it is what is eliminated, as we
- need to balance the offset for it from STARTING_FRAME_OFFSET.
+ need to balance the offset for it from TARGET_STARTING_FRAME_OFFSET.
Also add in the slot for the register stack pointer we save if we
have a landing pad.
diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
index 7d1e83c28e0..5dafe2dbf98 100644
--- a/gcc/config/mmix/mmix.h
+++ b/gcc/config/mmix/mmix.h
@@ -437,9 +437,6 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET \
- mmix_starting_frame_offset ()
-
#define FIRST_PARM_OFFSET(FUNDECL) 0
#define DYNAMIC_CHAIN_ADDRESS(FRAMEADDR) \
diff --git a/gcc/config/mn10300/mn10300.h b/gcc/config/mn10300/mn10300.h
index 1078b45c30a..b074540f7b1 100644
--- a/gcc/config/mn10300/mn10300.h
+++ b/gcc/config/mn10300/mn10300.h
@@ -392,13 +392,6 @@ enum reg_class
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-
-#define STARTING_FRAME_OFFSET 0
-
/* Offset of first parameter from the argument pointer register value. */
/* Is equal to the size of the saved fp + pc, even if an fp isn't
saved since the value is used before we know. */
diff --git a/gcc/config/moxie/moxie.h b/gcc/config/moxie/moxie.h
index 29442fb47e8..3742967d01c 100644
--- a/gcc/config/moxie/moxie.h
+++ b/gcc/config/moxie/moxie.h
@@ -226,10 +226,6 @@ enum reg_class
pointer to a smaller address. */
#define STACK_GROWS_DOWNWARD 1
-/* Offset from the frame pointer to the first local variable slot to
- be allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* Define this if the above stack space is to be considered part of the
space allocated by the caller. */
#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1
diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h
index 5a997670700..d4227259148 100644
--- a/gcc/config/msp430/msp430.h
+++ b/gcc/config/msp430/msp430.h
@@ -196,7 +196,6 @@ extern const char * msp430_select_hwmult_lib (int, const char **);
#define WORD_REGISTER_OPERATIONS 1
#define MOVE_MAX 8
-#define STARTING_FRAME_OFFSET 0
#define INCOMING_RETURN_ADDR_RTX \
msp430_incoming_return_addr_rtx ()
diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h
index d33237c004c..81522b848c8 100644
--- a/gcc/config/nds32/nds32.h
+++ b/gcc/config/nds32/nds32.h
@@ -681,8 +681,6 @@ enum reg_class
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
-
#define STACK_POINTER_OFFSET 0
#define FIRST_PARM_OFFSET(fundecl) \
diff --git a/gcc/config/nios2/nios2.h b/gcc/config/nios2/nios2.h
index 10bebfbcdd3..420543e4f46 100644
--- a/gcc/config/nios2/nios2.h
+++ b/gcc/config/nios2/nios2.h
@@ -252,7 +252,6 @@ enum reg_class
/* Stack layout. */
#define STACK_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
#define FIRST_PARM_OFFSET(FUNDECL) 0
/* Before the prologue, RA lives in r31. */
diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index d02e8541b6b..f81b9e2ae69 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -122,7 +122,6 @@ enum reg_class { NO_REGS, ALL_REGS, LIM_REG_CLASSES };
/* Stack and Calling. */
-#define STARTING_FRAME_OFFSET 0
#define FRAME_GROWS_DOWNWARD 0
#define STACK_GROWS_DOWNWARD 1
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index 5e945fc2f3b..3e2ef9d865c 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -203,6 +203,7 @@ static unsigned int pa_hard_regno_nregs (unsigned int, machine_mode);
static bool pa_hard_regno_mode_ok (unsigned int, machine_mode);
static bool pa_modes_tieable_p (machine_mode, machine_mode);
static bool pa_can_change_mode_class (machine_mode, machine_mode, reg_class_t);
+static HOST_WIDE_INT pa_starting_frame_offset (void);
/* The following extra sections are only used for SOM. */
static GTY(()) section *som_readonly_data_section;
@@ -422,6 +423,9 @@ static size_t n_deferred_plabels = 0;
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET pa_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Parse the -mfixed-range= option string. */
@@ -3779,11 +3783,11 @@ pa_compute_frame_size (HOST_WIDE_INT size, int *fregs_live)
size = (size + UNITS_PER_WORD - 1) & ~(UNITS_PER_WORD - 1);
/* Space for previous frame pointer + filler. If any frame is
- allocated, we need to add in the STARTING_FRAME_OFFSET. We
+ allocated, we need to add in the TARGET_STARTING_FRAME_OFFSET. We
waste some space here for the sake of HP compatibility. The
first slot is only used when the frame pointer is needed. */
if (size || frame_pointer_needed)
- size += STARTING_FRAME_OFFSET;
+ size += pa_starting_frame_offset ();
/* If the current function calls __builtin_eh_return, then we need
to allocate stack space for registers that will hold data for
@@ -3918,7 +3922,7 @@ pa_expand_prologue (void)
and must be changed in tandem with this code. */
local_fsize = (size + UNITS_PER_WORD - 1) & ~(UNITS_PER_WORD - 1);
if (local_fsize || frame_pointer_needed)
- local_fsize += STARTING_FRAME_OFFSET;
+ local_fsize += pa_starting_frame_offset ();
actual_fsize = pa_compute_frame_size (size, &save_fregs);
if (flag_stack_usage_info)
@@ -10809,4 +10813,17 @@ pa_hard_regno_mode_ok (unsigned int regno, machine_mode mode)
return PA_HARD_REGNO_MODE_OK (regno, mode);
}
+/* Implement TARGET_STARTING_FRAME_OFFSET.
+
+ On the 32-bit ports, we reserve one slot for the previous frame
+ pointer and one fill slot. The fill slot is for compatibility
+ with HP compiled programs. On the 64-bit ports, we reserve one
+ slot for the previous frame pointer. */
+
+static HOST_WIDE_INT
+pa_starting_frame_offset (void)
+{
+ return 8;
+}
+
#include "gt-pa.h"
diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
index cf95789b599..7bd1f112471 100644
--- a/gcc/config/pa/pa.h
+++ b/gcc/config/pa/pa.h
@@ -494,17 +494,6 @@ extern rtx hppa_pic_save_rtx (void);
goes at a more negative offset in the frame. */
#define FRAME_GROWS_DOWNWARD 0
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated.
-
- On the 32-bit ports, we reserve one slot for the previous frame
- pointer and one fill slot. The fill slot is for compatibility
- with HP compiled programs. On the 64-bit ports, we reserve one
- slot for the previous frame pointer. */
-#define STARTING_FRAME_OFFSET 8
-
/* Define STACK_ALIGNMENT_NEEDED to zero to disable final alignment
of the stack. The default is to align it to STACK_BOUNDARY. */
#define STACK_ALIGNMENT_NEEDED 0
diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
index 3c89327c983..115bb5b83a0 100644
--- a/gcc/config/pdp11/pdp11.h
+++ b/gcc/config/pdp11/pdp11.h
@@ -257,12 +257,6 @@ enum reg_class { NO_REGS, MUL_REGS, GENERAL_REGS, LOAD_FPU_REGS, NO_LOAD_FPU_REG
*/
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* If we generate an insn to push BYTES bytes,
this says how many the stack pointer really advances by.
On the pdp11, the stack is on an even boundary */
diff --git a/gcc/config/powerpcspe/aix.h b/gcc/config/powerpcspe/aix.h
index 6c91a90cc00..607b42c0a40 100644
--- a/gcc/config/powerpcspe/aix.h
+++ b/gcc/config/powerpcspe/aix.h
@@ -54,13 +54,11 @@
sizes of the fixed area and the parameter area must be a multiple of
STACK_BOUNDARY. */
-#undef STARTING_FRAME_OFFSET
-#define STARTING_FRAME_OFFSET \
- (FRAME_GROWS_DOWNWARD \
- ? 0 \
- : (cfun->calls_alloca \
- ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \
- : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA)))
+#undef RS6000_STARTING_FRAME_OFFSET
+#define RS6000_STARTING_FRAME_OFFSET \
+ (cfun->calls_alloca \
+ ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \
+ : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA))
/* Offset from the stack pointer register to an item dynamically
allocated on the stack, e.g., by `alloca'.
diff --git a/gcc/config/powerpcspe/darwin.h b/gcc/config/powerpcspe/darwin.h
index 51474ae00c7..ac268dcab23 100644
--- a/gcc/config/powerpcspe/darwin.h
+++ b/gcc/config/powerpcspe/darwin.h
@@ -148,12 +148,10 @@ extern int darwin_emit_branch_islands;
/* Pad the outgoing args area to 16 bytes instead of the usual 8. */
-#undef STARTING_FRAME_OFFSET
-#define STARTING_FRAME_OFFSET \
- (FRAME_GROWS_DOWNWARD \
- ? 0 \
- : (RS6000_ALIGN (crtl->outgoing_args_size, 16) \
- + RS6000_SAVE_AREA))
+#undef RS6000_STARTING_FRAME_OFFSET
+#define RS6000_STARTING_FRAME_OFFSET \
+ (RS6000_ALIGN (crtl->outgoing_args_size, 16) \
+ + RS6000_SAVE_AREA)
#undef STACK_DYNAMIC_OFFSET
#define STACK_DYNAMIC_OFFSET(FUNDECL) \
diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index 0f90e95f1e0..b39a8f8559f 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -1987,6 +1987,9 @@ static const struct attribute_spec rs6000_attribute_table[] =
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment
+
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET rs6000_starting_frame_offset
/* Processor table. */
@@ -43772,6 +43775,16 @@ rs6000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return MAX (align, BITS_PER_WORD);
return align;
}
+
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
+
+static HOST_WIDE_INT
+rs6000_starting_frame_offset (void)
+{
+ if (FRAME_GROWS_DOWNWARD)
+ return 0;
+ return RS6000_STARTING_FRAME_OFFSET;
+}
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/powerpcspe/powerpcspe.h b/gcc/config/powerpcspe/powerpcspe.h
index 8381785067c..bc37c6f17e5 100644
--- a/gcc/config/powerpcspe/powerpcspe.h
+++ b/gcc/config/powerpcspe/powerpcspe.h
@@ -1648,15 +1648,13 @@ extern enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
sizes of the fixed area and the parameter area must be a multiple of
STACK_BOUNDARY. */
-#define STARTING_FRAME_OFFSET \
- (FRAME_GROWS_DOWNWARD \
- ? 0 \
- : (cfun->calls_alloca \
- ? (RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, \
- (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8 )) \
- : (RS6000_ALIGN (crtl->outgoing_args_size, \
- (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8) \
- + RS6000_SAVE_AREA)))
+#define RS6000_STARTING_FRAME_OFFSET \
+ (cfun->calls_alloca \
+ ? (RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, \
+ (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8 )) \
+ : (RS6000_ALIGN (crtl->outgoing_args_size, \
+ (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8) \
+ + RS6000_SAVE_AREA))
/* Offset from the stack pointer register to an item dynamically
allocated on the stack, e.g., by `alloca'.
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index c31d2cc9957..e53555efe82 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -446,8 +446,6 @@ enum reg_class
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
-
#define RETURN_ADDR_RTX riscv_return_addr
#define ELIMINABLE_REGS \
diff --git a/gcc/config/rl78/rl78.h b/gcc/config/rl78/rl78.h
index 30dfee89e6b..e6b64098653 100644
--- a/gcc/config/rl78/rl78.h
+++ b/gcc/config/rl78/rl78.h
@@ -149,7 +149,6 @@
#define HAS_LONG_UNCOND_BRANCH 0
#define MOVE_MAX 2
-#define STARTING_FRAME_OFFSET 0
#define ADDR_SPACE_NEAR 1
#define ADDR_SPACE_FAR 2
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
index 6c91a90cc00..607b42c0a40 100644
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
@@ -54,13 +54,11 @@
sizes of the fixed area and the parameter area must be a multiple of
STACK_BOUNDARY. */
-#undef STARTING_FRAME_OFFSET
-#define STARTING_FRAME_OFFSET \
- (FRAME_GROWS_DOWNWARD \
- ? 0 \
- : (cfun->calls_alloca \
- ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \
- : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA)))
+#undef RS6000_STARTING_FRAME_OFFSET
+#define RS6000_STARTING_FRAME_OFFSET \
+ (cfun->calls_alloca \
+ ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \
+ : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA))
/* Offset from the stack pointer register to an item dynamically
allocated on the stack, e.g., by `alloca'.
diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h
index aeb4762387f..9a88a8d9e5e 100644
--- a/gcc/config/rs6000/darwin.h
+++ b/gcc/config/rs6000/darwin.h
@@ -148,12 +148,10 @@ extern int darwin_emit_branch_islands;
/* Pad the outgoing args area to 16 bytes instead of the usual 8. */
-#undef STARTING_FRAME_OFFSET
-#define STARTING_FRAME_OFFSET \
- (FRAME_GROWS_DOWNWARD \
- ? 0 \
- : (RS6000_ALIGN (crtl->outgoing_args_size, 16) \
- + RS6000_SAVE_AREA))
+#undef RS6000_STARTING_FRAME_OFFSET
+#define RS6000_STARTING_FRAME_OFFSET \
+ (RS6000_ALIGN (crtl->outgoing_args_size, 16) \
+ + RS6000_SAVE_AREA)
#undef STACK_DYNAMIC_OFFSET
#define STACK_DYNAMIC_OFFSET(FUNDECL) \
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4837e14a0e6..06713ad2b32 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1958,6 +1958,9 @@ static const struct attribute_spec rs6000_attribute_table[] =
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment
+
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET rs6000_starting_frame_offset
/* Processor table. */
@@ -39497,6 +39500,16 @@ rs6000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return MAX (align, BITS_PER_WORD);
return align;
}
+
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
+
+static HOST_WIDE_INT
+rs6000_starting_frame_offset (void)
+{
+ if (FRAME_GROWS_DOWNWARD)
+ return 0;
+ return RS6000_STARTING_FRAME_OFFSET;
+}
struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 5a5244aff85..198110485c8 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -1550,15 +1550,13 @@ extern enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
sizes of the fixed area and the parameter area must be a multiple of
STACK_BOUNDARY. */
-#define STARTING_FRAME_OFFSET \
- (FRAME_GROWS_DOWNWARD \
- ? 0 \
- : (cfun->calls_alloca \
- ? (RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, \
- (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8 )) \
- : (RS6000_ALIGN (crtl->outgoing_args_size, \
- (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8) \
- + RS6000_SAVE_AREA)))
+#define RS6000_STARTING_FRAME_OFFSET \
+ (cfun->calls_alloca \
+ ? (RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, \
+ (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8 )) \
+ : (RS6000_ALIGN (crtl->outgoing_args_size, \
+ (TARGET_ALTIVEC || TARGET_VSX) ? 16 : 8) \
+ + RS6000_SAVE_AREA))
/* Offset from the stack pointer register to an item dynamically
allocated on the stack, e.g., by `alloca'.
diff --git a/gcc/config/rx/rx.h b/gcc/config/rx/rx.h
index 4bc43c2ef5c..850033c1ee7 100644
--- a/gcc/config/rx/rx.h
+++ b/gcc/config/rx/rx.h
@@ -169,7 +169,6 @@
#define HAS_LONG_UNCOND_BRANCH 0
#define MOVE_MAX 4
-#define STARTING_FRAME_OFFSET 0
#define HAVE_PRE_DECREMENT 1
#define HAVE_POST_INCREMENT 1
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index 52eee948bdf..15d33906023 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -590,9 +590,6 @@ extern const enum reg_class regclass_map[FIRST_PSEUDO_REGISTER];
/* Offset from stack-pointer to first location of outgoing args. */
#define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
-/* Offset within stack frame to start allocating local variables at. */
-#define STARTING_FRAME_OFFSET 0
-
/* Offset from the stack pointer register to an item dynamically
allocated on the stack, e.g., by `alloca'. */
#define STACK_DYNAMIC_OFFSET(FUNDECL) \
diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
index 339bf284862..f5d80da1451 100644
--- a/gcc/config/sh/sh.h
+++ b/gcc/config/sh/sh.h
@@ -1109,10 +1109,6 @@ extern enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
are at negative offsets from the frame pointer. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset from the frame pointer to the first local variable slot to
- be allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* If we generate an insn to push BYTES bytes,
this says how many the stack pointer really advances by. */
/* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index d3f002d8198..a9945e2b13b 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -5276,8 +5276,9 @@ sparc_compute_frame_size (HOST_WIDE_INT size, int leaf_function)
frame_size = apparent_frame_size = 0;
else
{
- /* We subtract STARTING_FRAME_OFFSET, remember it's negative. */
- apparent_frame_size = ROUND_UP (size - STARTING_FRAME_OFFSET, 8);
+ /* We subtract TARGET_STARTING_FRAME_OFFSET, remember it's negative. */
+ apparent_frame_size
+ = ROUND_UP (size - targetm.starting_frame_offset (), 8);
apparent_frame_size += n_global_fp_regs * 4;
/* We need to add the size of the outgoing argument area. */
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index 9ac741f569b..a0b56126fd5 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -1043,12 +1043,6 @@ extern char leaf_reg_remap[];
goes at a more negative offset in the frame. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* Offset of first parameter from the argument pointer register value.
!v9: This is 64 for the ins and locals, plus 4 for the struct-return reg
even if this function isn't going to use it.
diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
index de4aa99f276..cf99b88b6ac 100644
--- a/gcc/config/spu/spu.h
+++ b/gcc/config/spu/spu.h
@@ -222,8 +222,6 @@ targetm.resolve_overloaded_builtin = spu_resolve_overloaded_builtin; \
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET (0)
-
#define STACK_POINTER_OFFSET 32
#define FIRST_PARM_OFFSET(FNDECL) (0)
diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h
index 31d6156cc26..3f8a5355175 100644
--- a/gcc/config/stormy16/stormy16.h
+++ b/gcc/config/stormy16/stormy16.h
@@ -216,8 +216,6 @@ enum reg_class
#define ARGS_GROW_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
-
#define FIRST_PARM_OFFSET(FUNDECL) 0
#define RETURN_ADDR_RTX(COUNT, FRAMEADDR) \
diff --git a/gcc/config/tilegx/tilegx.h b/gcc/config/tilegx/tilegx.h
index 066c34d2155..ea3c1b308c7 100644
--- a/gcc/config/tilegx/tilegx.h
+++ b/gcc/config/tilegx/tilegx.h
@@ -242,7 +242,6 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
#define DYNAMIC_CHAIN_ADDRESS(FRAME) \
plus_constant (Pmode, (FRAME), UNITS_PER_WORD)
diff --git a/gcc/config/tilepro/tilepro.h b/gcc/config/tilepro/tilepro.h
index 5ab8be49be0..3aa6dc8cd67 100644
--- a/gcc/config/tilepro/tilepro.h
+++ b/gcc/config/tilepro/tilepro.h
@@ -205,7 +205,6 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
#define FRAME_GROWS_DOWNWARD 1
-#define STARTING_FRAME_OFFSET 0
#define DYNAMIC_CHAIN_ADDRESS(FRAME) \
plus_constant (Pmode, (FRAME), UNITS_PER_WORD)
diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h
index da096f708b4..5eb2e8828fa 100644
--- a/gcc/config/v850/v850.h
+++ b/gcc/config/v850/v850.h
@@ -398,13 +398,6 @@ enum reg_class
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-
-#define STARTING_FRAME_OFFSET 0
-
/* Offset of first parameter from the argument pointer register value. */
/* Is equal to the size of the saved fp + pc, even if an fp isn't
saved since the value is used before we know. */
diff --git a/gcc/config/vax/elf.h b/gcc/config/vax/elf.h
index 1ff1814cc1a..e699c12943c 100644
--- a/gcc/config/vax/elf.h
+++ b/gcc/config/vax/elf.h
@@ -66,10 +66,6 @@ along with GCC; see the file COPYING3. If not see
16))
-/* Reserve the top of the stack for exception handler stackadj value. */
-#undef STARTING_FRAME_OFFSET
-#define STARTING_FRAME_OFFSET -4
-
/* The VAX wants no space between the case instruction and the jump table. */
#undef ASM_OUTPUT_BEFORE_CASE_LABEL
#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE)
diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c
index 5989607be75..82f13da1c99 100644
--- a/gcc/config/vax/vax.c
+++ b/gcc/config/vax/vax.c
@@ -62,6 +62,7 @@ static void vax_asm_trampoline_template (FILE *);
static void vax_trampoline_init (rtx, tree, rtx);
static int vax_return_pops_args (tree, tree, int);
static bool vax_mode_dependent_address_p (const_rtx, addr_space_t);
+static HOST_WIDE_INT vax_starting_frame_offset (void);
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
@@ -120,6 +121,9 @@ static bool vax_mode_dependent_address_p (const_rtx, addr_space_t);
#undef TARGET_OPTION_OVERRIDE
#define TARGET_OPTION_OVERRIDE vax_option_override
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET vax_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
/* Set global variables as needed for the options enabled. */
@@ -208,7 +212,7 @@ vax_expand_prologue (void)
/* Allocate the local stack frame. */
size = get_frame_size ();
- size -= STARTING_FRAME_OFFSET;
+ size -= vax_starting_frame_offset ();
emit_insn (gen_addsi3 (stack_pointer_rtx,
stack_pointer_rtx, GEN_INT (-size)));
@@ -2179,3 +2183,12 @@ vax_function_arg_advance (cumulative_args_t cum_v, machine_mode mode,
? (GET_MODE_SIZE (mode) + 3) & ~3
: (int_size_in_bytes (type) + 3) & ~3);
}
+
+static HOST_WIDE_INT
+vax_starting_frame_offset (void)
+{
+ /* On ELF targets, reserve the top of the stack for exception handler
+ stackadj value. */
+ return TARGET_ELF ? -4 : 0;
+}
+
diff --git a/gcc/config/vax/vax.h b/gcc/config/vax/vax.h
index 04a865cfa64..990140df869 100644
--- a/gcc/config/vax/vax.h
+++ b/gcc/config/vax/vax.h
@@ -228,12 +228,6 @@ enum reg_class { NO_REGS, ALL_REGS, LIM_REG_CLASSES };
goes at a more negative offset in the frame. */
#define FRAME_GROWS_DOWNWARD 1
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-#define STARTING_FRAME_OFFSET 0
-
/* Given an rtx for the address of a frame,
return an rtx for the address of the word in the frame
that holds the dynamic chain--the previous frame's address. */
diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
index 3cc0bc41280..3b229f1a1e6 100644
--- a/gcc/config/visium/visium.h
+++ b/gcc/config/visium/visium.h
@@ -727,17 +727,6 @@ enum reg_class
pointer to a smaller address. */
#define STACK_GROWS_DOWNWARD 1
-/* `STARTING_FRAME_OFFSET'
-
- Offset from the frame pointer to the first local variable slot to
- be allocated.
-
- If `FRAME_GROWS_DOWNWARD', find the next slot's offset by
- subtracting the first slot's length from `STARTING_FRAME_OFFSET'.
- Otherwise, it is found by adding the length of the first slot to
- the value `STARTING_FRAME_OFFSET'. */
-#define STARTING_FRAME_OFFSET 0
-
/* `FIRST_PARM_OFFSET (FUNDECL)'
Offset from the argument pointer register to the first argument's
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 3d60e317e6c..1e73b2f4405 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -182,6 +182,7 @@ static unsigned int xtensa_hard_regno_nregs (unsigned int, machine_mode);
static bool xtensa_hard_regno_mode_ok (unsigned int, machine_mode);
static bool xtensa_modes_tieable_p (machine_mode, machine_mode);
static HOST_WIDE_INT xtensa_constant_alignment (const_tree, HOST_WIDE_INT);
+static HOST_WIDE_INT xtensa_starting_frame_offset (void);
@@ -321,6 +322,9 @@ static HOST_WIDE_INT xtensa_constant_alignment (const_tree, HOST_WIDE_INT);
#undef TARGET_CONSTANT_ALIGNMENT
#define TARGET_CONSTANT_ALIGNMENT xtensa_constant_alignment
+#undef TARGET_STARTING_FRAME_OFFSET
+#define TARGET_STARTING_FRAME_OFFSET xtensa_starting_frame_offset
+
struct gcc_target targetm = TARGET_INITIALIZER;
@@ -4399,4 +4403,14 @@ xtensa_constant_alignment (const_tree exp, HOST_WIDE_INT align)
return align;
}
+/* Implement TARGET_STARTING_FRAME_OFFSET. */
+
+static HOST_WIDE_INT
+xtensa_starting_frame_offset (void)
+{
+ if (FRAME_GROWS_DOWNWARD)
+ return 0;
+ return crtl->outgoing_args_size;
+}
+
#include "gt-xtensa.h"
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index f9216391e25..b4cf53708b3 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -432,10 +432,6 @@ enum reg_class
#define FRAME_GROWS_DOWNWARD flag_stack_protect
-/* Offset within stack frame to start allocating local variables at. */
-#define STARTING_FRAME_OFFSET \
- (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. */
#define ELIMINABLE_REGS \
diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index 8b474160030..7f676850746 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -1786,11 +1786,11 @@ If @code{FRAME_GROWS_DOWNWARD} is defined to a nonzero value, this points
to immediately above the first variable on the stack. Otherwise, it points
to the first variable on the stack.
-@cindex @code{STARTING_FRAME_OFFSET} and virtual registers
+@cindex @code{TARGET_STARTING_FRAME_OFFSET} and virtual registers
@cindex @code{FRAME_POINTER_REGNUM} and virtual registers
@code{VIRTUAL_STACK_VARS_REGNUM} is replaced with the sum of the
register given by @code{FRAME_POINTER_REGNUM} and the value
-@code{STARTING_FRAME_OFFSET}.
+@code{TARGET_STARTING_FRAME_OFFSET}.
@findex VIRTUAL_STACK_DYNAMIC_REGNUM
@item VIRTUAL_STACK_DYNAMIC_REGNUM
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 03772177d0d..8484c1d3602 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -2966,22 +2966,19 @@ Define this macro if successive arguments to a function occupy decreasing
addresses on the stack.
@end defmac
-@defmac STARTING_FRAME_OFFSET
-Offset from the frame pointer to the first local variable slot to be allocated.
-
-If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
-subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
-Otherwise, it is found by adding the length of the first slot to the
-value @code{STARTING_FRAME_OFFSET}.
-@c i'm not sure if the above is still correct.. had to change it to get
-@c rid of an overfull. --mew 2feb93
-@end defmac
+@deftypefn {Target Hook} HOST_WIDE_INT TARGET_STARTING_FRAME_OFFSET (void)
+This hook returns the offset from the frame pointer to the first local
+variable slot to be allocated. If @code{FRAME_GROWS_DOWNWARD}, it is the
+offset to @emph{end} of the first slot allocated, otherwise it is the
+offset to @emph{beginning} of the first slot allocated. The default
+implementation returns 0.
+@end deftypefn
@defmac STACK_ALIGNMENT_NEEDED
Define to zero to disable final alignment of the stack during reload.
The nonzero default for this macro is suitable for most ports.
-On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
+On ports where @code{TARGET_STARTING_FRAME_OFFSET} is nonzero or where there
is a register save block following the local block that doesn't require
alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
stack alignment and do it in the backend.
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index d2cf68fee00..015f59eac2e 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -2411,22 +2411,13 @@ Define this macro if successive arguments to a function occupy decreasing
addresses on the stack.
@end defmac
-@defmac STARTING_FRAME_OFFSET
-Offset from the frame pointer to the first local variable slot to be allocated.
-
-If @code{FRAME_GROWS_DOWNWARD}, find the next slot's offset by
-subtracting the first slot's length from @code{STARTING_FRAME_OFFSET}.
-Otherwise, it is found by adding the length of the first slot to the
-value @code{STARTING_FRAME_OFFSET}.
-@c i'm not sure if the above is still correct.. had to change it to get
-@c rid of an overfull. --mew 2feb93
-@end defmac
+@hook TARGET_STARTING_FRAME_OFFSET
@defmac STACK_ALIGNMENT_NEEDED
Define to zero to disable final alignment of the stack during reload.
The nonzero default for this macro is suitable for most ports.
-On ports where @code{STARTING_FRAME_OFFSET} is nonzero or where there
+On ports where @code{TARGET_STARTING_FRAME_OFFSET} is nonzero or where there
is a register save block following the local block that doesn't require
alignment to @code{STACK_BOUNDARY}, it may be beneficial to disable
stack alignment and do it in the backend.
diff --git a/gcc/function.c b/gcc/function.c
index 10bcefb2cfe..339419ee1da 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -294,7 +294,7 @@ try_fit_stack_local (HOST_WIDE_INT start, HOST_WIDE_INT length,
/* Calculate how many bytes the start of local variables is off from
stack alignment. */
frame_alignment = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
- frame_off = STARTING_FRAME_OFFSET % frame_alignment;
+ frame_off = targetm.starting_frame_offset () % frame_alignment;
frame_phase = frame_off ? frame_alignment - frame_off : 0;
/* Round the frame offset to the specified alignment. */
@@ -499,7 +499,7 @@ assign_stack_local_1 (machine_mode mode, HOST_WIDE_INT size,
addr = plus_constant (Pmode, frame_pointer_rtx,
trunc_int_for_mode
(slot_offset + bigend_correction
- + STARTING_FRAME_OFFSET, Pmode));
+ + targetm.starting_frame_offset (), Pmode));
else
addr = plus_constant (Pmode, virtual_stack_vars_rtx,
trunc_int_for_mode
@@ -1930,7 +1930,7 @@ instantiate_virtual_regs (void)
/* Compute the offsets to use for this function. */
in_arg_offset = FIRST_PARM_OFFSET (current_function_decl);
- var_offset = STARTING_FRAME_OFFSET;
+ var_offset = targetm.starting_frame_offset ();
dynamic_offset = STACK_DYNAMIC_OFFSET (current_function_decl);
out_arg_offset = STACK_POINTER_OFFSET;
#ifdef FRAME_POINTER_CFA_OFFSET
diff --git a/gcc/hooks.c b/gcc/hooks.c
index d383926c329..61ff890b45b 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -259,6 +259,12 @@ hook_uint_void_0 (void)
return 0;
}
+HOST_WIDE_INT
+hook_hwi_void_0 (void)
+{
+ return 0;
+}
+
void
hook_void_tree (tree)
{
diff --git a/gcc/hooks.h b/gcc/hooks.h
index 711d0e2bf0c..8dbfd78717f 100644
--- a/gcc/hooks.h
+++ b/gcc/hooks.h
@@ -98,6 +98,8 @@ extern int hook_int_rtx_bool_0 (rtx, bool);
extern int hook_int_rtx_mode_as_bool_0 (rtx, machine_mode, addr_space_t,
bool);
+extern HOST_WIDE_INT hook_hwi_void_0 (void);
+
extern tree hook_tree_const_tree_null (const_tree);
extern tree hook_tree_void_null (void);
diff --git a/gcc/reload1.c b/gcc/reload1.c
index 27f37166b03..e2ee2feda93 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -963,7 +963,7 @@ reload (rtx_insn *first, int global)
then repeat the elimination bookkeeping. We don't
realign when there is no stack, as that will cause a
stack frame when none is needed should
- STARTING_FRAME_OFFSET not be already aligned to
+ TARGET_STARTING_FRAME_OFFSET not be already aligned to
STACK_BOUNDARY. */
assign_stack_local (BLKmode, 0, crtl->stack_alignment_needed);
}
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 92fc7b81ceb..560bfd43c1c 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -551,12 +551,12 @@ rtx_addr_can_trap_p_1 (const_rtx x, HOST_WIDE_INT offset, HOST_WIDE_INT size,
{
if (FRAME_GROWS_DOWNWARD)
{
- high_bound = STARTING_FRAME_OFFSET;
+ high_bound = targetm.starting_frame_offset ();
low_bound = high_bound - get_frame_size ();
}
else
{
- low_bound = STARTING_FRAME_OFFSET;
+ low_bound = targetm.starting_frame_offset ();
high_bound = low_bound + get_frame_size ();
}
}
diff --git a/gcc/system.h b/gcc/system.h
index f0664e93fc8..01bc134d1cc 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -915,7 +915,8 @@ extern void fancy_abort (const char *, int, const char *)
MODES_TIEABLE_P FUNCTION_ARG_PADDING SLOW_UNALIGNED_ACCESS \
HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE \
SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS \
- TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT
+ TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT \
+ STARTING_FRAME_OFFSET
/* Target macros only used for code built for the target, that have
moved to libgcc-tm.h or have never been present elsewhere. */
diff --git a/gcc/target.def b/gcc/target.def
index aac5d2711a8..b7dda5b5f2e 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -5688,6 +5688,16 @@ five otherwise. This is best for most machines.",
unsigned int, (void),
default_case_values_threshold)
+DEFHOOK
+(starting_frame_offset,
+ "This hook returns the offset from the frame pointer to the first local\n\
+variable slot to be allocated. If @code{FRAME_GROWS_DOWNWARD}, it is the\n\
+offset to @emph{end} of the first slot allocated, otherwise it is the\n\
+offset to @emph{beginning} of the first slot allocated. The default\n\
+implementation returns 0.",
+ HOST_WIDE_INT, (void),
+ hook_hwi_void_0)
+
/* Optional callback to advise the target to compute the frame layout. */
DEFHOOK
(compute_frame_layout,