From 4f59f9f2155491918d6d1fbb9287a01f9c0e2f79 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Mon, 12 Oct 2015 15:59:10 +0200 Subject: [PATCH] rs6000.h (RS6000_ALIGN): Implement using ROUND_UP macro. * config/rs6000/rs6000.h (RS6000_ALIGN): Implement using ROUND_UP macro. * config/rs6000/rs6000.c (rs6000_darwin64_record_arg_advance_flush): Use ROUND_UP and ROUND_DOWN macros where applicable. (rs6000_darwin64_record_arg_flush): Ditto. (rs6000_function_arg): Use ROUND_UP to calculate align_words. (rs6000_emit_probe_stack_range): Use ROUND_DOWN to calculate rounded_size. * config/aarch/aarch64.h (AARCH64_ROUND_UP): Remove. (AARCH64_ROUND_DOWN): Ditto. * config/aarch64/aarch64.c: Use ROUND_UP instead of AARCH64_ROUND_UP. From-SVN: r228715 --- gcc/ChangeLog | 17 +++++++++++++++ gcc/config/aarch64/aarch64.c | 40 ++++++++++++++++++------------------ gcc/config/aarch64/aarch64.h | 6 ------ gcc/config/rs6000/rs6000.c | 18 ++++++++-------- gcc/config/rs6000/rs6000.h | 2 +- 5 files changed, 47 insertions(+), 36 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9f4e5ab32be..f9389f80cb8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2015-10-12 Uros Bizjak + + * config/rs6000/rs6000.h (RS6000_ALIGN): Implement using + ROUND_UP macro. + * config/rs6000/rs6000.c (rs6000_darwin64_record_arg_advance_flush): + Use ROUND_UP and ROUND_DOWN macros where applicable. + (rs6000_darwin64_record_arg_flush): Ditto. + (rs6000_function_arg): Use ROUND_UP to calculate align_words. + (rs6000_emit_probe_stack_range): Use ROUND_DOWN to calculate + rounded_size. + +2015-10-12 Uros Bizjak + + * config/aarch/aarch64.h (AARCH64_ROUND_UP): Remove. + (AARCH64_ROUND_DOWN): Ditto. + * config/aarch64/aarch64.c: Use ROUND_UP instead of AARCH64_ROUND_UP. + 2015-10-12 Richard Biener PR ipa/67783 diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index c9fe368eeb7..5130e379c6b 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1860,8 +1860,8 @@ aarch64_layout_arg (cumulative_args_t pcum_v, machine_mode mode, /* Size in bytes, rounded to the nearest multiple of 8 bytes. */ size - = AARCH64_ROUND_UP (type ? int_size_in_bytes (type) : GET_MODE_SIZE (mode), - UNITS_PER_WORD); + = ROUND_UP (type ? int_size_in_bytes (type) : GET_MODE_SIZE (mode), + UNITS_PER_WORD); allocate_ncrn = (type) ? !(FLOAT_TYPE_P (type)) : !FLOAT_MODE_P (mode); allocate_nvrn = aarch64_vfp_is_call_candidate (pcum_v, @@ -1969,8 +1969,8 @@ aarch64_layout_arg (cumulative_args_t pcum_v, machine_mode mode, on_stack: pcum->aapcs_stack_words = size / UNITS_PER_WORD; if (aarch64_function_arg_alignment (mode, type) == 16 * BITS_PER_UNIT) - pcum->aapcs_stack_size = AARCH64_ROUND_UP (pcum->aapcs_stack_size, - 16 / UNITS_PER_WORD); + pcum->aapcs_stack_size = ROUND_UP (pcum->aapcs_stack_size, + 16 / UNITS_PER_WORD); return; } @@ -2237,21 +2237,21 @@ aarch64_layout_frame (void) } cfun->machine->frame.padding0 = - (AARCH64_ROUND_UP (offset, STACK_BOUNDARY / BITS_PER_UNIT) - offset); - offset = AARCH64_ROUND_UP (offset, STACK_BOUNDARY / BITS_PER_UNIT); + (ROUND_UP (offset, STACK_BOUNDARY / BITS_PER_UNIT) - offset); + offset = ROUND_UP (offset, STACK_BOUNDARY / BITS_PER_UNIT); cfun->machine->frame.saved_regs_size = offset; cfun->machine->frame.hard_fp_offset - = AARCH64_ROUND_UP (cfun->machine->frame.saved_varargs_size - + get_frame_size () - + cfun->machine->frame.saved_regs_size, - STACK_BOUNDARY / BITS_PER_UNIT); + = ROUND_UP (cfun->machine->frame.saved_varargs_size + + get_frame_size () + + cfun->machine->frame.saved_regs_size, + STACK_BOUNDARY / BITS_PER_UNIT); cfun->machine->frame.frame_size - = AARCH64_ROUND_UP (cfun->machine->frame.hard_fp_offset - + crtl->outgoing_args_size, - STACK_BOUNDARY / BITS_PER_UNIT); + = ROUND_UP (cfun->machine->frame.hard_fp_offset + + crtl->outgoing_args_size, + STACK_BOUNDARY / BITS_PER_UNIT); cfun->machine->frame.laid_out = true; } @@ -9024,8 +9024,8 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED) This address is gr_save_area_bytes below GRTOP, rounded down to the next 16-byte boundary. */ t = make_tree (TREE_TYPE (vrtop), virtual_incoming_args_rtx); - vr_offset = AARCH64_ROUND_UP (gr_save_area_size, - STACK_BOUNDARY / BITS_PER_UNIT); + vr_offset = ROUND_UP (gr_save_area_size, + STACK_BOUNDARY / BITS_PER_UNIT); if (vr_offset) t = fold_build_pointer_plus_hwi (t, -vr_offset); @@ -9118,7 +9118,7 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, unshare_expr (valist), f_grtop, NULL_TREE); f_off = build3 (COMPONENT_REF, TREE_TYPE (f_groff), unshare_expr (valist), f_groff, NULL_TREE); - rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD; + rsize = ROUND_UP (size, UNITS_PER_WORD); nregs = rsize / UNITS_PER_WORD; if (align > 8) @@ -9357,8 +9357,8 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v, machine_mode mode, /* Set OFF to the offset from virtual_incoming_args_rtx of the first vector register. The VR save area lies below the GR one, and is aligned to 16 bytes. */ - off = -AARCH64_ROUND_UP (gr_saved * UNITS_PER_WORD, - STACK_BOUNDARY / BITS_PER_UNIT); + off = -ROUND_UP (gr_saved * UNITS_PER_WORD, + STACK_BOUNDARY / BITS_PER_UNIT); off -= vr_saved * UNITS_PER_VREG; for (i = local_cum.aapcs_nvrn; i < NUM_FP_ARG_REGS; ++i) @@ -9377,8 +9377,8 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v, machine_mode mode, /* We don't save the size into *PRETEND_SIZE because we want to avoid any complication of having crtl->args.pretend_args_size changed. */ cfun->machine->frame.saved_varargs_size - = (AARCH64_ROUND_UP (gr_saved * UNITS_PER_WORD, - STACK_BOUNDARY / BITS_PER_UNIT) + = (ROUND_UP (gr_saved * UNITS_PER_WORD, + STACK_BOUNDARY / BITS_PER_UNIT) + vr_saved * UNITS_PER_VREG); } diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index b2a1394eba2..b041a1e38d0 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -513,12 +513,6 @@ extern enum aarch64_processor aarch64_tune; #define DEFAULT_PCC_STRUCT_RETURN 0 -#define AARCH64_ROUND_UP(X, ALIGNMENT) \ - (((X) + ((ALIGNMENT) - 1)) & ~((ALIGNMENT) - 1)) - -#define AARCH64_ROUND_DOWN(X, ALIGNMENT) \ - ((X) & ~((ALIGNMENT) - 1)) - #ifdef HOST_WIDE_INT struct GTY (()) aarch64_frame { diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index e8d9c7f7e53..f4d957ecbd8 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -9790,12 +9790,12 @@ rs6000_darwin64_record_arg_advance_flush (CUMULATIVE_ARGS *cum, e.g., in packed structs when there are 3 bytes to load. Back intoffset back to the beginning of the word in this case. */ - intoffset = intoffset & -BITS_PER_WORD; + intoffset = ROUND_DOWN (intoffset, BITS_PER_WORD); } } - startbit = intoffset & -BITS_PER_WORD; - endbit = (bitpos + BITS_PER_WORD - 1) & -BITS_PER_WORD; + startbit = ROUND_DOWN (intoffset, BITS_PER_WORD); + endbit = ROUND_UP (bitpos, BITS_PER_WORD); intregs = (endbit - startbit) / BITS_PER_WORD; cum->words += intregs; /* words should be unsigned. */ @@ -10255,15 +10255,15 @@ rs6000_darwin64_record_arg_flush (CUMULATIVE_ARGS *cum, e.g., in packed structs when there are 3 bytes to load. Back intoffset back to the beginning of the word in this case. */ - intoffset = intoffset & -BITS_PER_WORD; - mode = word_mode; + intoffset = ROUND_DOWN (intoffset, BITS_PER_WORD); + mode = word_mode; } } else mode = word_mode; - startbit = intoffset & -BITS_PER_WORD; - endbit = (bitpos + BITS_PER_WORD - 1) & -BITS_PER_WORD; + startbit = ROUND_DOWN (intoffset, BITS_PER_WORD); + endbit = ROUND_UP (bitpos, BITS_PER_WORD); intregs = (endbit - startbit) / BITS_PER_WORD; this_regno = cum->words + intoffset / BITS_PER_WORD; @@ -10622,7 +10622,7 @@ rs6000_function_arg (cumulative_args_t cum_v, machine_mode mode, save area? */ if (TARGET_64BIT && ! cum->prototype) { - int align_words = (cum->words + 1) & ~1; + int align_words = ROUND_UP (cum->words, 2); k = rs6000_psave_function_arg (mode, type, align_words, rvec); } @@ -23336,7 +23336,7 @@ rs6000_emit_probe_stack_range (HOST_WIDE_INT first, HOST_WIDE_INT size) /* Step 1: round SIZE to the previous multiple of the interval. */ - rounded_size = size & -PROBE_INTERVAL; + rounded_size = ROUND_DOWN (size, PROBE_INTERVAL); /* Step 2: compute initial and final value of the loop counter. */ diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index e4f29373252..95768228946 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -1615,7 +1615,7 @@ extern enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX]; ((DEFAULT_ABI == ABI_ELFv2 ? 12 : 20) << (TARGET_64BIT ? 1 : 0)) /* Align an address */ -#define RS6000_ALIGN(n,a) (((n) + (a) - 1) & ~((a) - 1)) +#define RS6000_ALIGN(n,a) ROUND_UP ((n), (a)) /* Offset within stack frame to start allocating local variables at. If FRAME_GROWS_DOWNWARD, this is the offset to the END of the -- 2.30.2