From: Richard Kenner Date: Tue, 31 Aug 2004 22:46:31 +0000 (+0000) Subject: c-common.c (c_alignof_expr): Use DECL_ALIGN_UNIT and TYPE_ALIGN_UNIT. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a4e9ffe59171f4ae43e329f0cc1dd919bac27226;p=gcc.git c-common.c (c_alignof_expr): Use DECL_ALIGN_UNIT and TYPE_ALIGN_UNIT. * c-common.c (c_alignof_expr): Use DECL_ALIGN_UNIT and TYPE_ALIGN_UNIT. (c_sizeof_of_alignof_type): Likewise. * expr.c (array_ref_element_size): Likewise. (highest_pow2_factor_for_target): Likewise. * gimplify.c (canonicalize_addr_expr): Likewise. (gimplify_compound_lval): Likewise. * stor-layout.c (finalize_record_size, finalize_type_size): Likewise. * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise. * varasm.c (assemble_variable): Likewise. (output_constant_def_contents): Alignments are unsigned. From-SVN: r86848 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1cddc302288..33ecad55a40 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2004-08-31 Richard Kenner + + * c-common.c (c_alignof_expr): Use DECL_ALIGN_UNIT and TYPE_ALIGN_UNIT. + (c_sizeof_of_alignof_type): Likewise. + * expr.c (array_ref_element_size): Likewise. + (highest_pow2_factor_for_target): Likewise. + * gimplify.c (canonicalize_addr_expr): Likewise. + (gimplify_compound_lval): Likewise. + * stor-layout.c (finalize_record_size, finalize_type_size): Likewise. + * tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise. + * varasm.c (assemble_variable): Likewise. + (output_constant_def_contents): Alignments are unsigned. + 2004-08-31 Richard Kenner Jeff Law diff --git a/gcc/c-common.c b/gcc/c-common.c index d3d03782cbb..a47385b2e05 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2774,7 +2774,7 @@ c_sizeof_or_alignof_type (tree type, enum tree_code op, int complain) size_int (TYPE_PRECISION (char_type_node) / BITS_PER_UNIT)); else - value = size_int (TYPE_ALIGN (type) / BITS_PER_UNIT); + value = size_int (TYPE_ALIGN_UNIT (type)); } /* VALUE will have an integer type with TYPE_IS_SIZETYPE set. @@ -2798,7 +2798,7 @@ c_alignof_expr (tree expr) tree t; if (TREE_CODE (expr) == VAR_DECL) - t = size_int (DECL_ALIGN (expr) / BITS_PER_UNIT); + t = size_int (DECL_ALIGN_UNIT (expr)); else if (TREE_CODE (expr) == COMPONENT_REF && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1))) @@ -2808,7 +2808,7 @@ c_alignof_expr (tree expr) } else if (TREE_CODE (expr) == COMPONENT_REF && TREE_CODE (TREE_OPERAND (expr, 1)) == FIELD_DECL) - t = size_int (DECL_ALIGN (TREE_OPERAND (expr, 1)) / BITS_PER_UNIT); + t = size_int (DECL_ALIGN_UNIT (TREE_OPERAND (expr, 1))); else if (TREE_CODE (expr) == INDIRECT_REF) { diff --git a/gcc/expr.c b/gcc/expr.c index ca19b7a62c1..f5c229d80b9 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5487,7 +5487,7 @@ array_ref_element_size (tree exp) if (TREE_TYPE (aligned_size) != sizetype) aligned_size = fold_convert (sizetype, aligned_size); return size_binop (MULT_EXPR, aligned_size, - size_int (TYPE_ALIGN (elmt_type) / BITS_PER_UNIT)); + size_int (TYPE_ALIGN_UNIT (elmt_type))); } /* Otherwise, take the size from that of the element type. Substitute @@ -6006,9 +6006,9 @@ highest_pow2_factor_for_target (tree target, tree exp) factor = highest_pow2_factor (exp); if (TREE_CODE (target) == COMPONENT_REF) - target_align = DECL_ALIGN (TREE_OPERAND (target, 1)) / BITS_PER_UNIT; + target_align = DECL_ALIGN_UNIT (TREE_OPERAND (target, 1)); else - target_align = TYPE_ALIGN (TREE_TYPE (target)) / BITS_PER_UNIT; + target_align = TYPE_ALIGN_UNIT (TREE_TYPE (target)); return MAX (factor, target_align); } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2de6cf6e091..050f97c9601 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1392,8 +1392,7 @@ canonicalize_addr_expr (tree *expr_p) TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), TYPE_MIN_VALUE (TYPE_DOMAIN (datype)), size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype), - size_int (TYPE_ALIGN (dctype) - / BITS_PER_UNIT))); + size_int (TYPE_ALIGN_UNIT (dctype)))); *expr_p = build1 (ADDR_EXPR, ctype, *expr_p); } @@ -1520,7 +1519,7 @@ gimplify_compound_lval (tree *expr_p, tree *pre_p, { tree elmt_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0))); tree elmt_size = unshare_expr (array_ref_element_size (t)); - tree factor = size_int (TYPE_ALIGN (elmt_type) / BITS_PER_UNIT); + tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type)); /* Divide the element size by the alignment of the element type (above). */ diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 30eec879f53..395a5f948cb 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1195,8 +1195,8 @@ finalize_record_size (record_layout_info rli) /* Round the size up to be a multiple of the required alignment. */ TYPE_SIZE (rli->t) = round_up (unpadded_size, TYPE_ALIGN (rli->t)); - TYPE_SIZE_UNIT (rli->t) = round_up (unpadded_size_unit, - TYPE_ALIGN (rli->t) / BITS_PER_UNIT); + TYPE_SIZE_UNIT (rli->t) + = round_up (unpadded_size_unit, TYPE_ALIGN_UNIT (rli->t)); if (warn_padded && TREE_CONSTANT (unpadded_size) && simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0) @@ -1357,8 +1357,8 @@ finalize_type_size (tree type) if (TYPE_SIZE (type) != 0) { TYPE_SIZE (type) = round_up (TYPE_SIZE (type), TYPE_ALIGN (type)); - TYPE_SIZE_UNIT (type) - = round_up (TYPE_SIZE_UNIT (type), TYPE_ALIGN (type) / BITS_PER_UNIT); + TYPE_SIZE_UNIT (type) = round_up (TYPE_SIZE_UNIT (type), + TYPE_ALIGN_UNIT (type)); } /* Evaluate nonconstant sizes only once, either now or as soon as safe. */ diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 928e8c4fcb7..62c8d0271ad 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1378,7 +1378,7 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type) return build (ARRAY_REF, orig_type, base, idx, min_idx, size_int (tree_low_cst (elt_size, 1) - / (TYPE_ALIGN (elt_type) / BITS_PER_UNIT))); + / (TYPE_ALIGN_UNIT (elt_type)))); } diff --git a/gcc/varasm.c b/gcc/varasm.c index 693196eaca8..37996c06e82 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1643,7 +1643,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); #if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS) - if ((unsigned HOST_WIDE_INT) DECL_ALIGN (decl) / BITS_PER_UNIT > rounded) + if ((unsigned HOST_WIDE_INT) DECL_ALIGN_UNIT (decl) > rounded) warning ("%Jrequested alignment for '%D' is greater than " "implemented alignment of %d", decl, decl, rounded); #endif @@ -1671,10 +1671,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, /* Output the alignment of this data. */ if (align > BITS_PER_UNIT) - { - ASM_OUTPUT_ALIGN (asm_out_file, - floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT)); - } + ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (DECL_ALIGN_UNIT (decl))); /* Do any machine/system dependent processing of the object. */ #ifdef ASM_DECLARE_OBJECT_NAME @@ -2659,7 +2656,7 @@ output_constant_def_contents (rtx symbol) int reloc = compute_reloc_for_constant (exp); /* Align the location counter as required by EXP's data type. */ - int align = TYPE_ALIGN (TREE_TYPE (exp)); + unsigned int align = TYPE_ALIGN (TREE_TYPE (exp)); #ifdef CONSTANT_ALIGNMENT align = CONSTANT_ALIGNMENT (exp, align); #endif