@@ -2117,7 +2117,8 @@ xtensa_function_arg_1 (cumulative_args_t cum_v, machine_mode mode,
if (type && (TYPE_ALIGN (type) > BITS_PER_WORD))
{
- int align = MIN (TYPE_ALIGN (type), STACK_BOUNDARY) / BITS_PER_WORD;
+ int align = MIN (TYPE_ALIGN (type),
+ PREFERRED_STACK_BOUNDARY) / BITS_PER_WORD;
*arg_words = (*arg_words + align - 1) & -align;
}
@@ -2158,8 +2159,8 @@ xtensa_function_arg_boundary (machine_mode mode, const_tree type)
alignment = type ? TYPE_ALIGN (type) : GET_MODE_ALIGNMENT (mode);
if (alignment < PARM_BOUNDARY)
alignment = PARM_BOUNDARY;
- if (alignment > STACK_BOUNDARY)
- alignment = STACK_BOUNDARY;
+ if (alignment > PREFERRED_STACK_BOUNDARY)
+ alignment = PREFERRED_STACK_BOUNDARY;
return alignment;
}
@@ -2624,7 +2625,7 @@ xtensa_call_save_reg(int regno)
/* Return the bytes needed to compute the frame pointer from the current
stack pointer. */
-#define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
+#define STACK_BYTES (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
#define XTENSA_STACK_ALIGN(LOC) (((LOC) + STACK_BYTES-1) & ~(STACK_BYTES-1))
long
@@ -3184,7 +3185,8 @@ xtensa_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
if (TYPE_ALIGN (type) > BITS_PER_WORD)
{
- int align = MIN (TYPE_ALIGN (type), STACK_BOUNDARY) / BITS_PER_UNIT;
+ int align = MIN (TYPE_ALIGN (type),
+ PREFERRED_STACK_BOUNDARY) / BITS_PER_UNIT;
t = build2 (PLUS_EXPR, integer_type_node, unshare_expr (orig_ndx),
build_int_cst (integer_type_node, align - 1));
@@ -504,9 +504,19 @@ enum reg_class
location above the first argument's address. */
#define FIRST_PARM_OFFSET(FNDECL) 0
-/* Align stack frames on 128 bits for Xtensa. This is necessary for
- 128-bit datatypes defined in TIE (e.g., for Vectra). */
-#define STACK_BOUNDARY 128
+/* Align stack frames on 32 bits for call0 ABI or on 64 bits for windowed
+ ABI on Xtensa. These are the absolute minimums dictated by the hardware
+ (windowed is 64 bits because the entry instruction moves SP in multiples
+ of 8 bytes). ABIs require alignment to be 128 bits to support datatypes
+ defined in TIE (e.g., for Vectra). */
+#define STACK_BOUNDARY (TARGET_WINDOWED_ABI ? 64 : 32)
+
+/* Align stack frames on 128 bits in accordance with ABI. This alignment
+ may be reduced when stack space conservation is preferred over ABI
+ compliance with -mpreferred-stack-boundary option. */
+#define PREFERRED_STACK_BOUNDARY \
+ MAX (STACK_BOUNDARY, \
+ (BITS_PER_UNIT << xtensa_preferred_stack_boundary))
/* Use a fixed register window size of 8. */
#define WINDOW_SIZE (TARGET_WINDOWED_ABI ? 8 : 0)
@@ -45,3 +45,7 @@ Relax literals in assembler and place them automatically in the text section.
mserialize-volatile
Target Report Mask(SERIALIZE_VOLATILE)
-mno-serialize-volatile Do not serialize volatile memory references with MEMW instructions.
+
+mpreferred-stack-boundary=
+Target RejectNegative Joined UInteger Var(xtensa_preferred_stack_boundary) Init(4)
+Attempt to keep stack aligned to this power of 2.
@@ -1202,6 +1202,7 @@ See RS/6000 and PowerPC Options.
-mtext-section-literals -mno-text-section-literals @gol
-mauto-litpools -mno-auto-litpools @gol
-mtarget-align -mno-target-align @gol
+-mpreferred-stack-boundary=@var{num} @gol
-mlongcalls -mno-longcalls}
@emph{zSeries Options}
@@ -25337,6 +25338,21 @@ treatment of auto-aligned instructions like @code{LOOP}, which the
assembler always aligns, either by widening density instructions or
by inserting NOP instructions.
+@item -mpreferred-stack-boundary=@var{num}
+@opindex mpreferred-stack-boundary
+Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
+byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
+the default is 4 (16 bytes or 128 bits).
+
+@strong{Warning:} When generating code for the Xtensa architecture that
+does not use TIE types, @option{-mpreferred-stack-boundary=3} can be
+used to keep the stack boundary aligned to 8 byte boundary in windowed
+ABI, and @option{-mpreferred-stack-boundary=2} can be used to keep the
+stack boundary aligned to 4 byte boundary in call0 ABI. Since both
+windowed and call0 ABI require 16 byte stack alignment, this is ABI
+incompatible and intended to be used in controlled environment where
+stack space is important limitation.
+
@item -mlongcalls
@itemx -mno-longcalls
@opindex mlongcalls