From 581edfa33d5b78fef85442b3135521ada320070d Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Fri, 22 May 2015 01:03:42 +0000 Subject: [PATCH] remove most ifdef STACK_GROWS_DOWNWARD gcc/c-family/ChangeLog: 2015-05-20 Trevor Saunders * c-cppbuiltin.c (c_cpp_builtins): Use if instead of #if with STACK_GROWS_DOWNWARD. gcc/ChangeLog: 2015-05-20 Trevor Saunders * builtins.c, dwarf2cfi.c, explow.c, expr.c, recog.c, sched-deps.c: Use if instead of preprocessor checks with STACK_GROWS_DOWNWARD. From-SVN: r223514 --- gcc/ChangeLog | 6 ++++ gcc/builtins.c | 30 +++++++++---------- gcc/c-family/ChangeLog | 5 ++++ gcc/c-family/c-cppbuiltin.c | 5 ++-- gcc/dwarf2cfi.c | 12 ++++---- gcc/explow.c | 33 ++++++++++----------- gcc/expr.c | 58 +++++++++++++++---------------------- gcc/recog.c | 8 ++--- gcc/sched-deps.c | 9 +++--- 9 files changed, 79 insertions(+), 87 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3fadbaf0e4c..ad68d6c0931 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-05-20 Trevor Saunders + + * builtins.c, dwarf2cfi.c, explow.c, expr.c, recog.c, + sched-deps.c: Use if instead of preprocessor checks with + STACK_GROWS_DOWNWARD. + 2015-05-20 Trevor Saunders * *.c: Check the value of STACK_GROWS_DOWNWARD rather than if it diff --git a/gcc/builtins.c b/gcc/builtins.c index e81ab04ae7a..d92535eeb4d 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -1521,14 +1521,14 @@ expand_builtin_apply_args_1 (void) /* Save the arg pointer to the block. */ tem = copy_to_reg (crtl->args.internal_arg_pointer); -#if STACK_GROWS_DOWNWARD /* We need the pointer as the caller actually passed them to us, not as we might have pretended they were passed. Make sure it's a valid operand, as emit_move_insn isn't expected to handle a PLUS. */ - tem - = force_operand (plus_constant (Pmode, tem, crtl->args.pretend_args_size), - NULL_RTX); -#endif + if (STACK_GROWS_DOWNWARD) + tem + = force_operand (plus_constant (Pmode, tem, + crtl->args.pretend_args_size), + NULL_RTX); emit_move_insn (adjust_address (registers, Pmode, 0), tem); size = GET_MODE_SIZE (Pmode); @@ -1613,10 +1613,9 @@ expand_builtin_apply (rtx function, rtx arguments, rtx argsize) /* Fetch the arg pointer from the ARGUMENTS block. */ incoming_args = gen_reg_rtx (Pmode); emit_move_insn (incoming_args, gen_rtx_MEM (Pmode, arguments)); -#if !STACK_GROWS_DOWNWARD - incoming_args = expand_simple_binop (Pmode, MINUS, incoming_args, argsize, - incoming_args, 0, OPTAB_LIB_WIDEN); -#endif + if (!STACK_GROWS_DOWNWARD) + incoming_args = expand_simple_binop (Pmode, MINUS, incoming_args, argsize, + incoming_args, 0, OPTAB_LIB_WIDEN); /* Push a new argument block and copy the arguments. Do not allow the (potential) memcpy call below to interfere with our stack @@ -1646,12 +1645,13 @@ expand_builtin_apply (rtx function, rtx arguments, rtx argsize) crtl->need_drap = true; dest = virtual_outgoing_args_rtx; -#if !STACK_GROWS_DOWNWARD - if (CONST_INT_P (argsize)) - dest = plus_constant (Pmode, dest, -INTVAL (argsize)); - else - dest = gen_rtx_PLUS (Pmode, dest, negate_rtx (Pmode, argsize)); -#endif + if (!STACK_GROWS_DOWNWARD) + { + if (CONST_INT_P (argsize)) + dest = plus_constant (Pmode, dest, -INTVAL (argsize)); + else + dest = gen_rtx_PLUS (Pmode, dest, negate_rtx (Pmode, argsize)); + } dest = gen_rtx_MEM (BLKmode, dest); set_mem_align (dest, PARM_BOUNDARY); src = gen_rtx_MEM (BLKmode, incoming_args); diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 5408a12b24b..126301bf4cd 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2015-05-20 Trevor Saunders + + * c-cppbuiltin.c (c_cpp_builtins): Use if instead of #if with + STACK_GROWS_DOWNWARD. + 2015-05-20 Trevor Saunders * c-cppbuiltin.c (c_cpp_builtins): Check the value of diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index da9cb2f355c..4170154e590 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -1138,9 +1138,8 @@ c_cpp_builtins (cpp_reader *pfile) TRAMPOLINE_SIZE); /* For libgcc generic-morestack.c and unwinder code. */ -#if STACK_GROWS_DOWNWARD - cpp_define (pfile, "__LIBGCC_STACK_GROWS_DOWNWARD__"); -#endif + if (STACK_GROWS_DOWNWARD) + cpp_define (pfile, "__LIBGCC_STACK_GROWS_DOWNWARD__"); /* For libgcc unwinder code. */ #ifdef DONT_USE_BUILTIN_SETJMP diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c index 8b8931f1d68..4b6929e4bc8 100644 --- a/gcc/dwarf2cfi.c +++ b/gcc/dwarf2cfi.c @@ -944,9 +944,9 @@ notice_args_size (rtx_insn *insn) /* Convert a change in args_size (always a positive in the direction of stack growth) to a change in stack pointer. */ -#if !STACK_GROWS_DOWNWARD - delta = -delta; -#endif + if (!STACK_GROWS_DOWNWARD) + delta = -delta; + cur_cfa->offset += delta; } } @@ -2347,9 +2347,9 @@ maybe_record_trace_start_abnormal (rtx_insn *start, rtx_insn *origin) { /* Convert a change in args_size (always a positive in the direction of stack growth) to a change in stack pointer. */ -#if !STACK_GROWS_DOWNWARD - delta = -delta; -#endif + if (!STACK_GROWS_DOWNWARD) + delta = -delta; + cur_row->cfa.offset += delta; } diff --git a/gcc/explow.c b/gcc/explow.c index 39b63ed7e39..d1a2bf851fd 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -866,10 +866,9 @@ adjust_stack_1 (rtx adjust, bool anti_p) rtx temp; rtx_insn *insn; -#if !STACK_GROWS_DOWNWARD /* Hereafter anti_p means subtract_p. */ - anti_p = !anti_p; -#endif + if (!STACK_GROWS_DOWNWARD) + anti_p = !anti_p; temp = expand_binop (Pmode, anti_p ? sub_optab : add_optab, @@ -1414,24 +1413,23 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, { int saved_stack_pointer_delta; -#if !STACK_GROWS_DOWNWARD - emit_move_insn (target, virtual_stack_dynamic_rtx); -#endif + if (!STACK_GROWS_DOWNWARD) + emit_move_insn (target, virtual_stack_dynamic_rtx); /* Check stack bounds if necessary. */ if (crtl->limit_stack) { rtx available; rtx_code_label *space_available = gen_label_rtx (); -#if STACK_GROWS_DOWNWARD - available = expand_binop (Pmode, sub_optab, - stack_pointer_rtx, stack_limit_rtx, - NULL_RTX, 1, OPTAB_WIDEN); -#else - available = expand_binop (Pmode, sub_optab, - stack_limit_rtx, stack_pointer_rtx, - NULL_RTX, 1, OPTAB_WIDEN); -#endif + if (STACK_GROWS_DOWNWARD) + available = expand_binop (Pmode, sub_optab, + stack_pointer_rtx, stack_limit_rtx, + NULL_RTX, 1, OPTAB_WIDEN); + else + available = expand_binop (Pmode, sub_optab, + stack_limit_rtx, stack_pointer_rtx, + NULL_RTX, 1, OPTAB_WIDEN); + emit_cmp_and_jump_insns (available, size, GEU, NULL_RTX, Pmode, 1, space_available); #ifdef HAVE_trap @@ -1456,9 +1454,8 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align, crtl->preferred_stack_boundary alignment. */ stack_pointer_delta = saved_stack_pointer_delta; -#if STACK_GROWS_DOWNWARD - emit_move_insn (target, virtual_stack_dynamic_rtx); -#endif + if (STACK_GROWS_DOWNWARD) + emit_move_insn (target, virtual_stack_dynamic_rtx); } suppress_reg_args_size = false; diff --git a/gcc/expr.c b/gcc/expr.c index 3d691de6baa..09fc69473e2 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -869,11 +869,10 @@ move_by_pieces (rtx to, rtx from, unsigned HOST_WIDE_INT len, to_addr = NULL_RTX; data.to = NULL_RTX; data.autinc_to = 1; -#if STACK_GROWS_DOWNWARD - data.reverse = 1; -#else - data.reverse = 0; -#endif + if (STACK_GROWS_DOWNWARD) + data.reverse = 1; + else + data.reverse = 0; } data.to_addr = to_addr; data.from = from; @@ -4000,9 +3999,9 @@ fixup_args_size_notes (rtx_insn *prev, rtx_insn *last, int end_args_size) saw_unknown = true; add_reg_note (insn, REG_ARGS_SIZE, GEN_INT (args_size)); -#if STACK_GROWS_DOWNWARD - this_delta = -(unsigned HOST_WIDE_INT) this_delta; -#endif + if (STACK_GROWS_DOWNWARD) + this_delta = -(unsigned HOST_WIDE_INT) this_delta; + args_size -= this_delta; } @@ -4045,42 +4044,38 @@ emit_single_push_insn_1 (machine_mode mode, rtx x, tree type) emit_move_insn (stack_pointer_rtx, expand_binop (Pmode, -#if STACK_GROWS_DOWNWARD - sub_optab, -#else - add_optab, -#endif + STACK_GROWS_DOWNWARD ? sub_optab + : add_optab, stack_pointer_rtx, gen_int_mode (rounded_size, Pmode), NULL_RTX, 0, OPTAB_LIB_WIDEN)); offset = (HOST_WIDE_INT) padding_size; -#if STACK_GROWS_DOWNWARD - if (STACK_PUSH_CODE == POST_DEC) + if (STACK_GROWS_DOWNWARD && STACK_PUSH_CODE == POST_DEC) /* We have already decremented the stack pointer, so get the previous value. */ offset += (HOST_WIDE_INT) rounded_size; -#else - if (STACK_PUSH_CODE == POST_INC) + + if (!STACK_GROWS_DOWNWARD && STACK_PUSH_CODE == POST_INC) /* We have already incremented the stack pointer, so get the previous value. */ offset -= (HOST_WIDE_INT) rounded_size; -#endif + dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, gen_int_mode (offset, Pmode)); } else { -#if STACK_GROWS_DOWNWARD - /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC. */ - dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, - gen_int_mode (-(HOST_WIDE_INT) rounded_size, - Pmode)); -#else - /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC. */ - dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, - gen_int_mode (rounded_size, Pmode)); -#endif + if (STACK_GROWS_DOWNWARD) + /* ??? This seems wrong if STACK_PUSH_CODE == POST_DEC. */ + dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, + gen_int_mode (-(HOST_WIDE_INT) rounded_size, + Pmode)); + else + /* ??? This seems wrong if STACK_PUSH_CODE == POST_INC. */ + dest_addr = gen_rtx_PLUS (Pmode, stack_pointer_rtx, + gen_int_mode (rounded_size, Pmode)); + dest_addr = gen_rtx_PRE_MODIFY (Pmode, stack_pointer_rtx, dest_addr); } @@ -4163,12 +4158,7 @@ emit_push_insn (rtx x, machine_mode mode, tree type, rtx size, rtx alignment_pad) { rtx xinner; - enum direction stack_direction -#if STACK_GROWS_DOWNWARD - = downward; -#else - = upward; -#endif + enum direction stack_direction = STACK_GROWS_DOWNWARD ? downward : upward; /* Decide where to pad the argument: `downward' for below, `upward' for above, or `none' for don't pad it. diff --git a/gcc/recog.c b/gcc/recog.c index 4a7aa67cf9a..524be673f02 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -1332,12 +1332,8 @@ push_operand (rtx op, machine_mode mode) || GET_CODE (XEXP (op, 1)) != PLUS || XEXP (XEXP (op, 1), 0) != XEXP (op, 0) || !CONST_INT_P (XEXP (XEXP (op, 1), 1)) -#if STACK_GROWS_DOWNWARD - || INTVAL (XEXP (XEXP (op, 1), 1)) != - (int) rounded_size -#else - || INTVAL (XEXP (XEXP (op, 1), 1)) != (int) rounded_size -#endif - ) + || INTVAL (XEXP (XEXP (op, 1), 1)) + != ((STACK_GROWS_DOWNWARD ? -1 : 1) * (int) rounded_size)) return 0; } diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c index 206da5a55f2..c1cfc1f3b70 100644 --- a/gcc/sched-deps.c +++ b/gcc/sched-deps.c @@ -4734,11 +4734,10 @@ parse_add_or_inc (struct mem_inc_info *mii, rtx_insn *insn, bool before_mem) if (regs_equal && REGNO (SET_DEST (pat)) == STACK_POINTER_REGNUM) { /* Note that the sign has already been reversed for !before_mem. */ -#if STACK_GROWS_DOWNWARD - return mii->inc_constant > 0; -#else - return mii->inc_constant < 0; -#endif + if (STACK_GROWS_DOWNWARD) + return mii->inc_constant > 0; + else + return mii->inc_constant < 0; } return true; }