This fixes the RISC-V bootstrap failure, based on a suggestion/question from Serge Belyshev asking why the patch wasn't using PREFERRED_STACK_BOUNDARY, which turns out to be a good solution. So the patch renames STACK_BOUNDARY to PREFERRED_STACK_BOUNDARY, and renames MIN_STACK_BOUNDARY to STACK_BOUNDARY.
This was tested with a cross compiler build with extra warning option to force the failure, and a cross make check. Tested with a native build. Tested by dissembling code with and without the patch to verify that I didn't accidentally change the ABI. And hand testing to verify that the option -mpreferred-stack-boundary was still working. Committed. Jim gcc/ PR bootstrap/84856 * config/riscv/riscv.c (riscv_function_arg_boundary): Use PREFERRED_STACK_BOUNDARY instead of STACK_BOUNDARY. (riscv_first_stack_step): Likewise. (riscv_option_override): Use STACK_BOUNDARY instead of MIN_STACK_BOUNDARY. * config/riscv/riscv.h (STACK_BOUNDARY): Renamed from MIN_STACK_BOUNDARY. (BIGGEST_ALIGNMENT): Set to 128. (PREFERRED_STACK_BOUNDARY): Renamed from STACK_BOUNDARY. (RISCV_STACK_ALIGN): Use PREFERRED_STACK_BOUNDARY instead of STACK_BOUNDARY. --- gcc/config/riscv/riscv.c | 8 ++++---- gcc/config/riscv/riscv.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index c38f6c394d5..0a75c8ae17f 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -2202,7 +2202,7 @@ riscv_expand_conditional_branch (rtx label, rtx_code code, rtx op0, rtx op1) /* Implement TARGET_FUNCTION_ARG_BOUNDARY. Every parameter gets at least PARM_BOUNDARY bits of alignment, but will be given anything up - to STACK_BOUNDARY bits if the type requires it. */ + to PREFERRED_STACK_BOUNDARY bits if the type requires it. */ static unsigned int riscv_function_arg_boundary (machine_mode mode, const_tree type) @@ -2215,7 +2215,7 @@ riscv_function_arg_boundary (machine_mode mode, const_tree type) else alignment = type ? TYPE_ALIGN (type) : GET_MODE_ALIGNMENT (mode); - return MIN (STACK_BOUNDARY, MAX (PARM_BOUNDARY, alignment)); + return MIN (PREFERRED_STACK_BOUNDARY, MAX (PARM_BOUNDARY, alignment)); } /* If MODE represents an argument that can be passed or returned in @@ -3506,7 +3506,7 @@ riscv_first_stack_step (struct riscv_frame_info *frame) return frame->total_size; HOST_WIDE_INT min_first_step = frame->total_size - frame->fp_sp_offset; - HOST_WIDE_INT max_first_step = IMM_REACH / 2 - STACK_BOUNDARY / 8; + HOST_WIDE_INT max_first_step = IMM_REACH / 2 - PREFERRED_STACK_BOUNDARY / 8; HOST_WIDE_INT min_second_step = frame->total_size - max_first_step; gcc_assert (min_first_step <= max_first_step); @@ -4137,7 +4137,7 @@ riscv_option_override (void) riscv_stack_boundary = ABI_STACK_BOUNDARY; if (riscv_preferred_stack_boundary_arg) { - int min = ctz_hwi (MIN_STACK_BOUNDARY / 8); + int min = ctz_hwi (STACK_BOUNDARY / 8); int max = 8; if (!IN_RANGE (riscv_preferred_stack_boundary_arg, min, max)) diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 6144e267727..ebd80c0a5f2 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -124,13 +124,13 @@ along with GCC; see the file COPYING3. If not see #define FUNCTION_BOUNDARY (TARGET_RVC ? 16 : 32) /* The smallest supported stack boundary the calling convention supports. */ -#define MIN_STACK_BOUNDARY (2 * BITS_PER_WORD) +#define STACK_BOUNDARY (2 * BITS_PER_WORD) /* The ABI stack alignment. */ #define ABI_STACK_BOUNDARY 128 /* There is no point aligning anything to a rounder boundary than this. */ -#define BIGGEST_ALIGNMENT STACK_BOUNDARY +#define BIGGEST_ALIGNMENT 128 /* The user-level ISA permits unaligned accesses, but they are not required of the privileged architecture. */ @@ -482,7 +482,7 @@ enum reg_class `crtl->outgoing_args_size'. */ #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 -#define STACK_BOUNDARY riscv_stack_boundary +#define PREFERRED_STACK_BOUNDARY riscv_stack_boundary /* Symbolic macros for the registers used to return integer and floating point values. */ @@ -540,7 +540,7 @@ typedef struct { /* Align based on stack boundary, which might have been set by the user. */ #define RISCV_STACK_ALIGN(LOC) \ - (((LOC) + ((STACK_BOUNDARY/8)-1)) & -(STACK_BOUNDARY/8)) + (((LOC) + ((PREFERRED_STACK_BOUNDARY/8)-1)) & -(PREFERRED_STACK_BOUNDARY/8)) /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, the stack pointer does not matter. The value is tested only in -- 2.14.1