rs6000.h (RS6000_ALIGN): Implement using ROUND_UP macro.
authorUros Bizjak <ubizjak@gmail.com>
Mon, 12 Oct 2015 13:59:10 +0000 (15:59 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Mon, 12 Oct 2015 13:59:10 +0000 (15:59 +0200)
* 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
gcc/config/aarch64/aarch64.c
gcc/config/aarch64/aarch64.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/rs6000.h

index 9f4e5ab32bef3b15165d1df378a5b8c4548e65c6..f9389f80cb8921b383890a71628cdfa60a3d0529 100644 (file)
@@ -1,3 +1,20 @@
+2015-10-12  Uros Bizjak  <ubizjak@gmail.com>
+
+       * 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  <ubizjak@gmail.com>
+
+       * 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  <rguenther@suse.de>
 
        PR ipa/67783
index c9fe368eeb7816e27d21d1346ee11b61fd36af7f..5130e379c6b0d3facd66f62a7c197698afec93db 100644 (file)
@@ -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);
 }
 
index b2a1394eba2c33b985c6dbace89a88dd438f27cb..b041a1e38d068c0a7d2448077efc84eda655779f 100644 (file)
@@ -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
 {
index e8d9c7f7e53ed878cf3050d8b8ce51dc822aaf29..f4d957ecbd8d8b304bd959b15d0e5d82ad61734c 100644 (file)
@@ -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.  */
index e4f2937325290efc1f35fe4caa0a29895b84ea2c..95768228946aba31299f1b80bc1b127fc995bfb8 100644 (file)
@@ -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