diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2000-03-07 11:41:32 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2000-03-07 06:41:32 -0500 |
commit | 05bccae2efd712562a20afadfc2889d87323e7ca (patch) | |
tree | eedf389b906e1f6d1fda0e405c46b8b47fb6d064 /gcc | |
parent | ddf0fc6c9f1eb8747c9cf6b69e48f11f779632d2 (diff) | |
download | gcc-05bccae2efd712562a20afadfc2889d87323e7ca.zip gcc-05bccae2efd712562a20afadfc2889d87323e7ca.tar.gz gcc-05bccae2efd712562a20afadfc2889d87323e7ca.tar.bz2 |
tree.h (INT_CST_LT, [...]): Remove unneeded casts.
* tree.h (INT_CST_LT, INT_CST_LT_UNSIGNED): Remove unneeded casts.
(struct tree_int_cst): int_cst_low is now unsigned HOST_WIDE_INT.
(attribute_hash_list, type_hash_canon): hashcode is now unsigned.
(type_hash_lookup, type_hash_add, type_hash_list): Likewise.
(min_precision): Result is unsignd.
(add_double, neg_double, mul_double): Low word is unsigned.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double): Likewise.
(tree_floor_log2, compare_tree_int): New functions.
(preserve_rtl_expr_temps): New declaration.
* c-common.c (declare_hidden_char_array): Use compare_tree_int.
(decl_attributes): Use tree_log2 to find alignment.
Check for TREE_INT_CST_HIGH for format args.
(min_precision): Now unsigned.
Use tree_floor_log2.
(truthvalue_conversion): Delete long-disabled code.
* c-decl.c (finish_struct): Clean up tests on field width.
(finish_function): Use compare_tree_int.
* c-pragma.c (handle_pragma_token): Use tree_log2 for alignment.
* c-typeck.c (comptypes): Use tree_int_cst_equal.
(default_conversion, digest_init): Use compare_tree_int.
(build_binary_op): Use integer_all_onesp and compare_tree_int.
Fix type errors in forming masks.
* calls.c (initialize_argument_information): Use compare_tree_int.
* dbxout.c (dbxout_type): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* except.c (expand_eh_region_start_tree): Use compare_tree_int.
* expr.c (is_zeros_p, case INTEGER_CST): Use integer_zerop.
(store_field): Use compare_tree_int.
(expand_expr, case CONSTRUCTOR): Use TYPE_SIZE_UNIT.
(expand_expr, case ARRAY_REF): Use compare_tree_int.
(do_jump, case BIT_AND_EXPR): Use tree_floor_log2.
(do_store_flag): Use compare_tree_int.
* fold-const.c (encode, decode): Low part is always unsigned.
(force_fit_type, add_double, neg_double, mul_double): Likewise.
(lshift_double, rshift_double, lrotate_double): Likewise.
(rrotate_double, div_and_round_double, int_const_binop): Likewise.
(fold_convert): Use compare_tree_int.
(operand_equal_p, case INTEGER_CST): Use tree_int_cst_equal.
(invert_truthvalue, case INTEGER_CST): Likewise.
(fold): Use compare_tree_int; add casts for unsigned TREE_INT_CST_LOW.
* mkdeps.c (deps_dummy_targets): Make I unsigned.
* rtl.h (add_double, neg_double, mul_double): Low words are unsigned.
(lshift_double, rshift_double, lrotate_double, rrotate_double):
Likewise.
* stmt.c (expand_decl): Use compare_tree_int and mode_for_size_tree.
(expand_end_case): Use compare_tree_int.
(estimate_case_costs): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* stor-layout.c (mode_for_size_tree): Use compare_tree_int.
(layout_decl): Likewise.
(layout_record, layout_union): Make sizes unsigned.
(layout_type, case VOID_TYPE): TYPE_SIZE must be bitsizetype.
(layout_type, case QUAL_UNION_TYPE): Use compare_tree_int.
* tree.c (struct type_hash): hashcode is unsigned.
(build_type_attribute_variant, type_hash_list): Likewise.
(type_hash_lookup, type_hash_add, type_hash_canon): Likewise.
(attribute_hash_list, build_array_type, build_method_type): Likewise.
(build_complex_type): Likewise.
(real_value_from_int_cst): Remove unneeded casts.
(integer_all_onesp): Add casts.
(tree_floor_log2, compare_tree_int): New functions.
(build_index_type): Use tree_int_cst_sgn.
* varasm.c (assemble_variable): Use compare_tree_int.
* ch/actions.c (chill_convert_for_assignment): INDEX is unsigned
HOST_WIDE_INT.
* ch/ch-tree.h (DECL_NESTING_LEVEL): Use TREE_INT_CST_HIGH
since unsigned.
* ch/except.c (chill_handle_on_labels): ALTERNATIVE is unsigned.
Use compare_tree_int.
(expand_goto_except_cleanup): Likewise.
* cp/class.c (dfs_modify_vtables): I is now unsigned.
(check_bitfield_decl): Use tree_int_cst_sgn and compare_tree_int.
(build_base_field): Add casts of TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/error.c (dump_expr): Cast TREE_INT_CST_HIGH to unsigned.
* cp/init.c (build_vec_init): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
* cp/method.c (build_overload_int): Cast TREE_INT_CST_HIGH to unsigned.
* cp/typeck.c (build_binary_op, case TRUNC_DIV_EXPR):
Call integer_all_onesp.
* cp/typeck2.c (process_init_constructor): Use compare_tree_int.
* f/com.c (ffecom_f2c_set_lio_code_): Use compare_tree_int.
(ffecom_sym_transform_, ffecom_transform_common_): Likewise.
(ffecom_transform_equiv_): Likewise.
* java/decl.c (emit_init_test_initialization): Mark KEY as unused.
* java/expr.c (build_newarray): Cast TREE_INT_CST_LOW to HOST_WIDE_INT.
(build_anewarray): Likewise.
* java/parse.y (patch_newarray): Likewise.
* java/parse.c: Regenerated.
From-SVN: r32383
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 65 | ||||
-rw-r--r-- | gcc/c-common.c | 93 | ||||
-rw-r--r-- | gcc/c-decl.c | 115 | ||||
-rw-r--r-- | gcc/c-lex.c | 1 | ||||
-rw-r--r-- | gcc/c-pragma.c | 20 | ||||
-rw-r--r-- | gcc/c-typeck.c | 115 | ||||
-rw-r--r-- | gcc/calls.c | 5 | ||||
-rw-r--r-- | gcc/ch/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ch/actions.c | 4 | ||||
-rw-r--r-- | gcc/ch/ch-tree.h | 2 | ||||
-rw-r--r-- | gcc/ch/except.c | 14 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/class.c | 35 | ||||
-rw-r--r-- | gcc/cp/error.c | 5 | ||||
-rw-r--r-- | gcc/cp/init.c | 5 | ||||
-rw-r--r-- | gcc/cp/method.c | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 7 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 12 | ||||
-rw-r--r-- | gcc/dbxout.c | 2 | ||||
-rw-r--r-- | gcc/except.c | 3 | ||||
-rw-r--r-- | gcc/expr.c | 137 | ||||
-rw-r--r-- | gcc/f/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/f/com.c | 21 | ||||
-rw-r--r-- | gcc/fold-const.c | 385 | ||||
-rw-r--r-- | gcc/java/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/java/decl.c | 3 | ||||
-rw-r--r-- | gcc/java/expr.c | 18 | ||||
-rw-r--r-- | gcc/java/parse.c | 8 | ||||
-rw-r--r-- | gcc/java/parse.y | 8 | ||||
-rw-r--r-- | gcc/mkdeps.c | 7 | ||||
-rw-r--r-- | gcc/print-tree.c | 2 | ||||
-rw-r--r-- | gcc/rtl.h | 48 | ||||
-rw-r--r-- | gcc/stmt.c | 21 | ||||
-rw-r--r-- | gcc/stor-layout.c | 29 | ||||
-rw-r--r-- | gcc/tree.c | 132 | ||||
-rw-r--r-- | gcc/tree.h | 87 | ||||
-rw-r--r-- | gcc/varasm.c | 5 |
37 files changed, 823 insertions, 630 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cce837f..0b560ca 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,68 @@ +Mon Mar 6 15:22:29 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * tree.h (INT_CST_LT, INT_CST_LT_UNSIGNED): Remove unneeded casts. + (struct tree_int_cst): int_cst_low is now unsigned HOST_WIDE_INT. + (attribute_hash_list, type_hash_canon): hashcode is now unsigned. + (type_hash_lookup, type_hash_add, type_hash_list): Likewise. + (min_precision): Result is unsignd. + (add_double, neg_double, mul_double): Low word is unsigned. + (lshift_double, rshift_double, lrotate_double): Likewise. + (rrotate_double, div_and_round_double): Likewise. + (tree_floor_log2, compare_tree_int): New functions. + (preserve_rtl_expr_temps): New declaration. + * c-common.c (declare_hidden_char_array): Use compare_tree_int. + (decl_attributes): Use tree_log2 to find alignment. + Check for TREE_INT_CST_HIGH for format args. + (min_precision): Now unsigned. + Use tree_floor_log2. + (truthvalue_conversion): Delete long-disabled code. + * c-decl.c (finish_struct): Clean up tests on field width. + (finish_function): Use compare_tree_int. + * c-pragma.c (handle_pragma_token): Use tree_log2 for alignment. + * c-typeck.c (comptypes): Use tree_int_cst_equal. + (default_conversion, digest_init): Use compare_tree_int. + (build_binary_op): Use integer_all_onesp and compare_tree_int. + Fix type errors in forming masks. + * calls.c (initialize_argument_information): Use compare_tree_int. + * dbxout.c (dbxout_type): Cast TREE_INT_CST_LOW to HOST_WIDE_INT. + * except.c (expand_eh_region_start_tree): Use compare_tree_int. + * expr.c (is_zeros_p, case INTEGER_CST): Use integer_zerop. + (store_field): Use compare_tree_int. + (expand_expr, case CONSTRUCTOR): Use TYPE_SIZE_UNIT. + (expand_expr, case ARRAY_REF): Use compare_tree_int. + (do_jump, case BIT_AND_EXPR): Use tree_floor_log2. + (do_store_flag): Use compare_tree_int. + * fold-const.c (encode, decode): Low part is always unsigned. + (force_fit_type, add_double, neg_double, mul_double): Likewise. + (lshift_double, rshift_double, lrotate_double): Likewise. + (rrotate_double, div_and_round_double, int_const_binop): Likewise. + (fold_convert): Use compare_tree_int. + (operand_equal_p, case INTEGER_CST): Use tree_int_cst_equal. + (invert_truthvalue, case INTEGER_CST): Likewise. + (fold): Use compare_tree_int; add casts for unsigned TREE_INT_CST_LOW. + * mkdeps.c (deps_dummy_targets): Make I unsigned. + * rtl.h (add_double, neg_double, mul_double): Low words are unsigned. + (lshift_double, rshift_double, lrotate_double, rrotate_double): + Likewise. + * stmt.c (expand_decl): Use compare_tree_int and mode_for_size_tree. + (expand_end_case): Use compare_tree_int. + (estimate_case_costs): Cast TREE_INT_CST_LOW to HOST_WIDE_INT. + * stor-layout.c (mode_for_size_tree): Use compare_tree_int. + (layout_decl): Likewise. + (layout_record, layout_union): Make sizes unsigned. + (layout_type, case VOID_TYPE): TYPE_SIZE must be bitsizetype. + (layout_type, case QUAL_UNION_TYPE): Use compare_tree_int. + * tree.c (struct type_hash): hashcode is unsigned. + (build_type_attribute_variant, type_hash_list): Likewise. + (type_hash_lookup, type_hash_add, type_hash_canon): Likewise. + (attribute_hash_list, build_array_type, build_method_type): Likewise. + (build_complex_type): Likewise. + (real_value_from_int_cst): Remove unneeded casts. + (integer_all_onesp): Add casts. + (tree_floor_log2, compare_tree_int): New functions. + (build_index_type): Use tree_int_cst_sgn. + * varasm.c (assemble_variable): Use compare_tree_int. + 2000-03-06 Jason Merrill <jason@casey.cygnus.com> * cpphash.c (collect_expansion): Also catch ## at start of macro. diff --git a/gcc/c-common.c b/gcc/c-common.c index 262022f..35e2b02 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -282,16 +282,17 @@ declare_hidden_char_array (name, value) const char *name, *value; { tree decl, type, init; - int vlen; + unsigned int vlen; /* If the default size of char arrays isn't big enough for the name, or if we want to give warnings for large objects, make a bigger one. */ vlen = strlen (value) + 1; type = char_array_type_node; - if (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < vlen + if (compare_tree_int (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), vlen) < 0 || warn_larger_than) type = build_array_type (char_type_node, build_index_type (build_int_2 (vlen, 0))); + decl = build_decl (VAR_DECL, get_identifier (name), type); TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; @@ -775,7 +776,7 @@ decl_attributes (node, attributes, prefix_attributes) tree align_expr = (args ? TREE_VALUE (args) : size_int (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); - int align; + int i; /* Strip any NOPs of any kind. */ while (TREE_CODE (align_expr) == NOP_EXPR @@ -789,18 +790,18 @@ decl_attributes (node, attributes, prefix_attributes) continue; } - align = TREE_INT_CST_LOW (align_expr) * BITS_PER_UNIT; - - if (exact_log2 (align) == -1) + if ((i = tree_log2 (align_expr)) == -1) error ("requested alignment is not a power of 2"); + else if (i > HOST_BITS_PER_INT - 2) + error ("requested alignment is too large"); else if (is_type) - TYPE_ALIGN (type) = align; + TYPE_ALIGN (type) = (1 << i) * BITS_PER_UNIT; else if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FIELD_DECL) error_with_decl (decl, "alignment may not be specified for `%s'"); else - DECL_ALIGN (decl) = align; + DECL_ALIGN (decl) = (1 << i) * BITS_PER_UNIT; } break; @@ -810,11 +811,10 @@ decl_attributes (node, attributes, prefix_attributes) tree format_num_expr = TREE_VALUE (TREE_CHAIN (args)); tree first_arg_num_expr = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args))); - int format_num; - int first_arg_num; + unsigned HOST_WIDE_INT format_num, first_arg_num; enum format_type format_type; tree argument; - int arg_num; + unsigned int arg_num; if (TREE_CODE (decl) != FUNCTION_DECL) { @@ -859,9 +859,11 @@ decl_attributes (node, attributes, prefix_attributes) first_arg_num_expr = TREE_OPERAND (first_arg_num_expr, 0); if (TREE_CODE (format_num_expr) != INTEGER_CST - || TREE_CODE (first_arg_num_expr) != INTEGER_CST) + || TREE_INT_CST_HIGH (format_num_expr) != 0 + || TREE_CODE (first_arg_num_expr) != INTEGER_CST + || TREE_INT_CST_HIGH (first_arg_num_expr) != 0) { - error ("format string has non-constant operand number"); + error ("format string has invalid operand number"); continue; } @@ -879,12 +881,10 @@ decl_attributes (node, attributes, prefix_attributes) argument = TYPE_ARG_TYPES (type); if (argument) { - for (arg_num = 1; ; ++arg_num) - { - if (argument == 0 || arg_num == format_num) - break; - argument = TREE_CHAIN (argument); - } + for (arg_num = 1; argument != 0 && arg_num != format_num; + ++arg_num, argument = TREE_CHAIN (argument)) + ; + if (! argument || TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (argument))) @@ -893,17 +893,19 @@ decl_attributes (node, attributes, prefix_attributes) error ("format string arg not a string type"); continue; } - if (first_arg_num != 0) + + else if (first_arg_num != 0) { /* Verify that first_arg_num points to the last arg, the ... */ while (argument) arg_num++, argument = TREE_CHAIN (argument); - if (arg_num != first_arg_num) - { - error ("args to be formatted is not ..."); - continue; - } + + if (arg_num != first_arg_num) + { + error ("args to be formatted is not '...'"); + continue; + } } } @@ -916,7 +918,8 @@ decl_attributes (node, attributes, prefix_attributes) case A_FORMAT_ARG: { tree format_num_expr = TREE_VALUE (args); - int format_num, arg_num; + unsigned HOST_WIDE_INT format_num; + unsigned int arg_num; tree argument; if (TREE_CODE (decl) != FUNCTION_DECL) @@ -933,9 +936,10 @@ decl_attributes (node, attributes, prefix_attributes) || TREE_CODE (format_num_expr) == NON_LVALUE_EXPR) format_num_expr = TREE_OPERAND (format_num_expr, 0); - if (TREE_CODE (format_num_expr) != INTEGER_CST) + if (TREE_CODE (format_num_expr) != INTEGER_CST + || TREE_INT_CST_HIGH (format_num_expr) != 0) { - error ("format string has non-constant operand number"); + error ("format string has invalid operand number"); continue; } @@ -947,12 +951,10 @@ decl_attributes (node, attributes, prefix_attributes) argument = TYPE_ARG_TYPES (type); if (argument) { - for (arg_num = 1; ; ++arg_num) - { - if (argument == 0 || arg_num == format_num) - break; - argument = TREE_CHAIN (argument); - } + for (arg_num = 1; argument != 0 && arg_num != format_num; + ++arg_num, argument = TREE_CHAIN (argument)) + ; + if (! argument || TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (argument))) @@ -2407,7 +2409,7 @@ signed_or_unsigned_type (unsignedp, type) /* Return the minimum number of bits needed to represent VALUE in a signed or unsigned type, UNSIGNEDP says which. */ -int +unsigned int min_precision (value, unsignedp) tree value; int unsignedp; @@ -2427,10 +2429,8 @@ min_precision (value, unsignedp) if (integer_zerop (value)) log = 0; - else if (TREE_INT_CST_HIGH (value) != 0) - log = HOST_BITS_PER_WIDE_INT + floor_log2 (TREE_INT_CST_HIGH (value)); else - log = floor_log2 (TREE_INT_CST_LOW (value)); + log = tree_floor_log2 (value); return log + 1 + ! unsignedp; } @@ -2888,24 +2888,7 @@ truthvalue_conversion (expr) switch (TREE_CODE (expr)) { - /* It is simpler and generates better code to have only TRUTH_*_EXPR - or comparison expressions as truth values at this level. */ -#if 0 - case COMPONENT_REF: - /* A one-bit unsigned bit-field is already acceptable. */ - if (1 == TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (expr, 1))) - && TREE_UNSIGNED (TREE_OPERAND (expr, 1))) - return expr; - break; -#endif - case EQ_EXPR: - /* It is simpler and generates better code to have only TRUTH_*_EXPR - or comparison expressions as truth values at this level. */ -#if 0 - if (integer_zerop (TREE_OPERAND (expr, 1))) - return build_unary_op (TRUTH_NOT_EXPR, TREE_OPERAND (expr, 0), 0); -#endif case NE_EXPR: case LE_EXPR: case GE_EXPR: case LT_EXPR: case GT_EXPR: case TRUTH_ANDIF_EXPR: case TRUTH_ORIF_EXPR: diff --git a/gcc/c-decl.c b/gcc/c-decl.c index ba632d0..6b5d295 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5182,57 +5182,50 @@ finish_struct (t, fieldlist, attributes) == TYPE_PRECISION (integer_type_node)))) pedwarn_with_decl (x, "bit-field `%s' type invalid in ANSI C"); - /* Detect and ignore out of range field width. */ + /* Detect and ignore out of range field width and process valid + field widths. */ if (DECL_INITIAL (x)) { if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0) - { - DECL_INITIAL (x) = NULL; - error_with_decl (x, "negative width in bit-field `%s'"); - } - else if (TREE_INT_CST_HIGH (DECL_INITIAL (x)) != 0 - || (TREE_INT_CST_LOW (DECL_INITIAL (x)) - > TYPE_PRECISION (TREE_TYPE (x)))) - { - DECL_INITIAL (x) = NULL; - pedwarn_with_decl (x, "width of `%s' exceeds its type"); - } + error_with_decl (x, "negative width in bit-field `%s'"); + else if (0 < compare_tree_int (DECL_INITIAL (x), + TYPE_PRECISION (TREE_TYPE (x)))) + pedwarn_with_decl (x, "width of `%s' exceeds its type"); else if (integer_zerop (DECL_INITIAL (x)) && DECL_NAME (x) != 0) + error_with_decl (x, "zero width for bit-field `%s'"); + else { - error_with_decl (x, "zero width for bit-field `%s'"); - DECL_INITIAL (x) = NULL; - } - } - - /* Process valid field width. */ - if (DECL_INITIAL (x)) - { - register int width = TREE_INT_CST_LOW (DECL_INITIAL (x)); - - if (TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE - && (width < min_precision (TYPE_MIN_VALUE (TREE_TYPE (x)), - TREE_UNSIGNED (TREE_TYPE (x))) - || width < min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)), - TREE_UNSIGNED (TREE_TYPE (x))))) - warning_with_decl (x, "`%s' is narrower than values of its type"); - - DECL_SIZE (x) = bitsize_int (width); - DECL_BIT_FIELD (x) = DECL_C_BIT_FIELD (x) = 1; - DECL_INITIAL (x) = NULL; - - if (width == 0) - { - /* field size 0 => force desired amount of alignment. */ + /* The test above has assured us that TREE_INT_CST_HIGH is 0. */ + unsigned HOST_WIDE_INT width + = TREE_INT_CST_LOW (DECL_INITIAL (x)); + + if (TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE + && (width < min_precision (TYPE_MIN_VALUE (TREE_TYPE (x)), + TREE_UNSIGNED (TREE_TYPE (x))) + || (width + < min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)), + TREE_UNSIGNED (TREE_TYPE (x)))))) + warning_with_decl (x, + "`%s' is narrower than values of its type"); + + DECL_SIZE (x) = bitsize_int (width); + DECL_BIT_FIELD (x) = DECL_C_BIT_FIELD (x) = 1; + + if (width == 0) + { + /* field size 0 => force desired amount of alignment. */ #ifdef EMPTY_FIELD_BOUNDARY - DECL_ALIGN (x) = MAX (DECL_ALIGN (x), EMPTY_FIELD_BOUNDARY); + DECL_ALIGN (x) = MAX (DECL_ALIGN (x), EMPTY_FIELD_BOUNDARY); #endif #ifdef PCC_BITFIELD_TYPE_MATTERS - if (PCC_BITFIELD_TYPE_MATTERS) - DECL_ALIGN (x) = MAX (DECL_ALIGN (x), - TYPE_ALIGN (TREE_TYPE (x))); + if (PCC_BITFIELD_TYPE_MATTERS) + DECL_ALIGN (x) = MAX (DECL_ALIGN (x), + TYPE_ALIGN (TREE_TYPE (x))); #endif + } } } + else if (TREE_TYPE (x) != error_mark_node) { unsigned int min_align = (DECL_PACKED (x) ? BITS_PER_UNIT @@ -5242,9 +5235,9 @@ finish_struct (t, fieldlist, attributes) fields which require only BITS_PER_UNIT alignment. */ DECL_ALIGN (x) = MAX (DECL_ALIGN (x), min_align); } - } - /* Now DECL_INITIAL is null on all members. */ + DECL_INITIAL (x) = 0; + } /* Delete all duplicate fields from the fieldlist */ for (x = fieldlist; x && TREE_CHAIN (x);) @@ -6489,34 +6482,36 @@ finish_function (nested) if (warn_larger_than && !DECL_EXTERNAL (fndecl) && TREE_TYPE (fndecl)) { - register tree ret_type = TREE_TYPE (TREE_TYPE (fndecl)); + tree ret_type = TREE_TYPE (TREE_TYPE (fndecl)); - if (ret_type) + if (ret_type && TREE_CODE (TYPE_SIZE_UNIT (ret_type)) == INTEGER_CST + && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type), + larger_than_size)) { - register tree ret_type_size = TYPE_SIZE (ret_type); + unsigned int size_as_int + = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type)); - if (TREE_CODE (ret_type_size) == INTEGER_CST) - { - unsigned units - = TREE_INT_CST_LOW (ret_type_size) / BITS_PER_UNIT; - - if (units > larger_than_size) - warning_with_decl (fndecl, - "size of return value of `%s' is %u bytes", - units); - } + if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0) + warning_with_decl (fndecl, + "size of return value of `%s' is %u bytes", + size_as_int); + else + warning_with_decl (fndecl, + "size of return value of `%s' is larger than %d bytes", + larger_than_size); } } if (DECL_SAVED_INSNS (fndecl) == 0 && ! nested) { - /* Stop pointing to the local nodes about to be freed. */ - /* But DECL_INITIAL must remain nonzero so we know this - was an actual function definition. */ - /* For a nested function, this is done in pop_c_function_context. */ - /* If rest_of_compilation set this to 0, leave it 0. */ + /* Stop pointing to the local nodes about to be freed. + But DECL_INITIAL must remain nonzero so we know this + was an actual function definition. + For a nested function, this is done in pop_c_function_context. + If rest_of_compilation set this to 0, leave it 0. */ if (DECL_INITIAL (fndecl) != 0) DECL_INITIAL (fndecl) = error_mark_node; + DECL_ARGUMENTS (fndecl) = 0; } diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 4b4968c..6597ffc 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -406,6 +406,7 @@ yyprint (file, yychar, yylval) /* Iff C is a carriage return, warn about it - if appropriate - and return nonzero. */ + static int whitespace_cr (c) int c; diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index 7ee2eb2..c85e6bf 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -163,25 +163,25 @@ pop_alignment (id) it needs to be preserved. If STRING is non-NULL, then the return value will be ignored, and there - will be futher calls to handle_pragma_token() in order to handle the rest of + will be futher calls to handle_pragma_token in order to handle the rest of the line containing the #pragma directive. If STRING is NULL, the entire - line has now been presented to handle_pragma_token() and the return value + line has now been presented to handle_pragma_token and the return value should be zero if the pragma flawed in some way, or if the pragma was not recognised, and non-zero if it was successfully handled. */ int handle_pragma_token (string, token) - const char * string; + const char *string; tree token; { static enum pragma_state state = ps_start; static enum pragma_state type; #ifdef HANDLE_PRAGMA_WEAK - static char * name; - static char * value; + static char *name; + static char *value; #endif #if defined(HANDLE_PRAGMA_PACK) || defined(HANDLE_PRAGMA_PACK_PUSH_POP) - static int align; + static unsigned int align; #endif static tree id; @@ -353,15 +353,15 @@ handle_pragma_token (string, token) break; handle_align: - align = TREE_INT_CST_LOW (token); - switch (align) + switch (tree_log2 (token)) { + case 0: case 1: case 2: + case 3: case 4: - case 8: - case 16: state = ps_align; + align = 1 << tree_log2 (token); break; default: diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 6d85c35..2cac887 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -514,15 +514,10 @@ comptypes (type1, type2) || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST) break; - if (! ((TREE_INT_CST_LOW (TYPE_MIN_VALUE (d1)) - == TREE_INT_CST_LOW (TYPE_MIN_VALUE (d2))) - && (TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d1)) - == TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d2))) - && (TREE_INT_CST_LOW (TYPE_MAX_VALUE (d1)) - == TREE_INT_CST_LOW (TYPE_MAX_VALUE (d2))) - && (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d1)) - == TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d2))))) - val = 0; + if (! tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2)) + || ! tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2))) + val = 0; + break; } @@ -884,8 +879,9 @@ default_conversion (exp) } /* Strip NON_LVALUE_EXPRs and no-op conversions, since we aren't using as - an lvalue. */ - /* Do not use STRIP_NOPS here! It will remove conversions from pointer + an lvalue. + + Do not use STRIP_NOPS here! It will remove conversions from pointer to integer and cause infinite recursion. */ while (TREE_CODE (exp) == NON_LVALUE_EXPR || (TREE_CODE (exp) == NOP_EXPR @@ -902,26 +898,19 @@ default_conversion (exp) || (TYPE_PRECISION (type) >= TYPE_PRECISION (integer_type_node))) && TREE_UNSIGNED (type))); + return convert (type, exp); } if (TREE_CODE (exp) == COMPONENT_REF - && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1))) - { - tree width = DECL_SIZE (TREE_OPERAND (exp, 1)); - HOST_WIDE_INT low = TREE_INT_CST_LOW (width); - + && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)) /* If it's thinner than an int, promote it like a C_PROMOTING_INTEGER_TYPE_P, otherwise leave it alone. */ - - if (low < TYPE_PRECISION (integer_type_node)) - { - if (flag_traditional && TREE_UNSIGNED (type)) - return convert (unsigned_type_node, exp); - else - return convert (integer_type_node, exp); - } - } + && 0 > compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)), + TYPE_PRECISION (integer_type_node))) + return convert (flag_traditional && TREE_UNSIGNED (type) + ? unsigned_type_node : integer_type_node, + exp); if (C_PROMOTING_INTEGER_TYPE_P (type)) { @@ -931,11 +920,14 @@ default_conversion (exp) && (flag_traditional || TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))) return convert (unsigned_type_node, exp); + return convert (integer_type_node, exp); } + if (flag_traditional && !flag_allow_single_precision && TYPE_MAIN_VARIANT (type) == float_type_node) return convert (double_type_node, exp); + if (code == VOID_TYPE) { error ("void value not ignored as it ought to be"); @@ -1914,17 +1906,14 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)) resultcode = RDIV_EXPR; else - { - /* Although it would be tempting to shorten always here, that - loses on some targets, since the modulo instruction is - undefined if the quotient can't be represented in the - computation mode. We shorten only if unsigned or if - dividing by something we know != -1. */ - shorten = (TREE_UNSIGNED (TREE_TYPE (orig_op0)) - || (TREE_CODE (op1) == INTEGER_CST - && (TREE_INT_CST_LOW (op1) != -1 - || TREE_INT_CST_HIGH (op1) != -1))); - } + /* Although it would be tempting to shorten always here, that + loses on some targets, since the modulo instruction is + undefined if the quotient can't be represented in the + computation mode. We shorten only if unsigned or if + dividing by something we know != -1. */ + shorten = (TREE_UNSIGNED (TREE_TYPE (orig_op0)) + || (TREE_CODE (op1) == INTEGER_CST + && ! integer_all_onesp (op1))); common = 1; } break; @@ -1970,8 +1959,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) only if unsigned or if dividing by something we know != -1. */ shorten = (TREE_UNSIGNED (TREE_TYPE (orig_op0)) || (TREE_CODE (op1) == INTEGER_CST - && (TREE_INT_CST_LOW (op1) != -1 - || TREE_INT_CST_HIGH (op1) != -1))); + && ! integer_all_onesp (op1))); common = 1; } break; @@ -2009,14 +1997,14 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) warning ("right shift count is negative"); else { - if (TREE_INT_CST_LOW (op1) | TREE_INT_CST_HIGH (op1)) + if (! integer_zerop (op1)) short_shift = 1; - if (TREE_INT_CST_HIGH (op1) != 0 - || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1) - >= TYPE_PRECISION (type0))) + + if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0) warning ("right shift count >= width of type"); } } + /* Use the type of the value to be shifted. This is what most traditional C compilers do. */ result_type = type0; @@ -2039,11 +2027,11 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) { if (tree_int_cst_sgn (op1) < 0) warning ("left shift count is negative"); - else if (TREE_INT_CST_HIGH (op1) != 0 - || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1) - >= TYPE_PRECISION (type0))) + + else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0) warning ("left shift count >= width of type"); } + /* Use the type of the value to be shifted. This is what most traditional C compilers do. */ result_type = type0; @@ -2067,11 +2055,10 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) { if (tree_int_cst_sgn (op1) < 0) warning ("shift count is negative"); - else if (TREE_INT_CST_HIGH (op1) != 0 - || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1) - >= TYPE_PRECISION (type0))) + else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0) warning ("shift count >= width of type"); } + /* Use the type of the value to be shifted. This is what most traditional C compilers do. */ result_type = type0; @@ -2343,8 +2330,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type) /* We can shorten only if the shift count is less than the number of bits in the smaller type size. */ - && TREE_INT_CST_HIGH (op1) == 0 - && TYPE_PRECISION (TREE_TYPE (arg0)) > TREE_INT_CST_LOW (op1) + && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0 /* If arg is sign-extended and then unsigned-shifted, we can simulate this with a signed shift in arg's type only if the extended result is at least twice as wide @@ -2354,7 +2340,8 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) it never happens because available widths are 2**N. */ && (!TREE_UNSIGNED (final_type) || unsigned_arg - || 2 * TYPE_PRECISION (TREE_TYPE (arg0)) <= TYPE_PRECISION (result_type))) + || (2 * TYPE_PRECISION (TREE_TYPE (arg0)) + <= TYPE_PRECISION (result_type)))) { /* Do an unsigned shift if the operand was zero-extended. */ result_type @@ -2469,7 +2456,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) || TREE_CODE (primop1) == INTEGER_CST) { tree primop; - long constant, mask; + HOST_WIDE_INT constant, mask; int unsignedp, bits; if (TREE_CODE (primop0) == INTEGER_CST) @@ -2487,9 +2474,9 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) bits = TYPE_PRECISION (TREE_TYPE (primop)); if (bits < TYPE_PRECISION (result_type) - && bits < HOST_BITS_PER_LONG && unsignedp) + && bits < HOST_BITS_PER_WIDE_INT && unsignedp) { - mask = (~0L) << bits; + mask = (~ (HOST_WIDE_INT) 0) << bits; if ((mask & constant) != mask) warning ("comparison of promoted ~unsigned with constant"); } @@ -4566,19 +4553,19 @@ digest_init (type, init, require_constant, constructor_constant) TREE_TYPE (inside_init) = type; if (TYPE_DOMAIN (type) != 0 - && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) - { - register int size = TREE_INT_CST_LOW (TYPE_SIZE (type)); - size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT; + && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST /* Subtract 1 (or sizeof (wchar_t)) because it's ok to ignore the terminating null char that is counted in the length of the constant. */ - if (size < TREE_STRING_LENGTH (inside_init) - - (TYPE_PRECISION (typ1) != TYPE_PRECISION (char_type_node) - ? TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT - : 1)) - pedwarn_init ("initializer-string for array of chars is too long"); - } + && 0 > compare_tree_int (TYPE_SIZE_UNIT (type), + TREE_STRING_LENGTH (inside_init) + - ((TYPE_PRECISION (typ1) + != TYPE_PRECISION (char_type_node)) + ? (TYPE_PRECISION (wchar_type_node) + / BITS_PER_UNIT) + : 1))) + pedwarn_init ("initializer-string for array of chars is too long"); + return inside_init; } } diff --git a/gcc/calls.c b/gcc/calls.c index 324cc7b..df891fc 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1040,9 +1040,8 @@ initialize_argument_information (num_actuals, args, args_size, n_named_args, if (TYPE_SIZE (type) == 0 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST || (flag_stack_check && ! STACK_CHECK_BUILTIN - && (TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0 - || (TREE_INT_CST_LOW (TYPE_SIZE (type)) - > STACK_CHECK_MAX_VAR_SIZE * BITS_PER_UNIT)))) + && (0 < compare_tree_int (TYPE_SIZE_UNIT (type), + STACK_CHECK_MAX_VAR_SIZE)))) { /* This is a variable-sized object. Make space on the stack for it. */ diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog index 50135e9..360fcc1 100644 --- a/gcc/ch/ChangeLog +++ b/gcc/ch/ChangeLog @@ -1,3 +1,12 @@ +Mon Mar 6 17:52:48 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * actions.c (chill_convert_for_assignment): INDEX is unsigned + HOST_WIDE_INT. + * ch-tree.h (DECL_NESTING_LEVEL): Use TREE_INT_CST_HIGH since unsigned. + * except.c (chill_handle_on_labels): ALTERNATIVE is unsigned. + Use compare_tree_int. + (expand_goto_except_cleanup): Likewise. + 2000-03-01 Martin von Loewis <loewis@informatik.hu-berlin.de> * decl.c (current_function_decl): Move to toplev.c. diff --git a/gcc/ch/actions.c b/gcc/ch/actions.c index c97c1b6..d7b10e6 100644 --- a/gcc/ch/actions.c +++ b/gcc/ch/actions.c @@ -567,7 +567,7 @@ chill_convert_for_assignment (type, expr, place) { tree domain_min = TYPE_MIN_VALUE (TYPE_DOMAIN (type)); tree new_list = NULL_TREE; - long index; + unsigned HOST_WIDE_INT index; tree element; for (element = TREE_OPERAND (result, 1); @@ -587,7 +587,7 @@ chill_convert_for_assignment (type, expr, place) new_list); break; case RANGE_EXPR: - for (index = TREE_INT_CST_LOW (TREE_OPERAND (purpose, 0)); + for (index = TREE_INT_CST_LOW (TREE_OPERAND (purpose, 0)); index <= TREE_INT_CST_LOW (TREE_OPERAND (purpose, 1)); index++) new_list = tree_cons (NULL_TREE, diff --git a/gcc/ch/ch-tree.h b/gcc/ch/ch-tree.h index 3aa7415..0483a1d 100644 --- a/gcc/ch/ch-tree.h +++ b/gcc/ch/ch-tree.h @@ -79,7 +79,7 @@ struct lang_identifier Predefined declarations have level -1; the global scope is level 0. */ #define DECL_NESTING_LEVEL(DECL) \ - ((DECL)->decl.vindex ? TREE_INT_CST_LOW((DECL)->decl.vindex) : -1) + ((DECL)->decl.vindex ? TREE_INT_CST_HIGH((DECL)->decl.vindex) : -1) /* Nesting of things that can have an ON-unit attached. */ extern int action_nesting_level; diff --git a/gcc/ch/except.c b/gcc/ch/except.c index a59e675..22abd04 100644 --- a/gcc/ch/except.c +++ b/gcc/ch/except.c @@ -500,7 +500,7 @@ void chill_handle_on_labels (labels) tree labels; { - int alternative = ++current_handler->prev_on_alternative; + unsigned int alternative = ++current_handler->prev_on_alternative; if (pass == 1) { tree handler_number = build_int_2 (alternative, 0); @@ -510,9 +510,13 @@ chill_handle_on_labels (labels) else { /* Find handler_number saved in pass 1. */ - tree tmp = current_handler->on_alt_list; - while (TREE_INT_CST_LOW (TREE_PURPOSE (tmp)) != alternative) - tmp = TREE_CHAIN (tmp); + tree tmp; + + for (tmp = current_handler->on_alt_list; + compare_tree_int (TREE_PURPOSE (tmp), alternative) != 0; + tmp = TREE_CHAIN (tmp)) + ; + if (expand_exit_needed) expand_exit_something (), expand_exit_needed = 0; chill_handle_case_label (TREE_PURPOSE (tmp), @@ -618,7 +622,7 @@ expand_goto_except_cleanup (label_level) tree last = NULL_TREE; for ( ; list != NULL_TREE; list = TREE_CHAIN (list)) { - if (TREE_INT_CST_LOW (TREE_PURPOSE (list)) > label_level) + if (compare_tree_int (TREE_PURPOSE (list), label_level) > 0) last = list; else break; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 05c2158..e6f17ea 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -5,6 +5,16 @@ Mon Mar 6 08:46:47 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + * class.c (dfs_modify_vtables): I is now unsigned. + (check_bitfield_decl): Use tree_int_cst_sgn and compare_tree_int. + (build_base_field): Add casts of TREE_INT_CST_LOW to HOST_WIDE_INT. + * error.c (dump_expr): Cast TREE_INT_CST_HIGH to unsigned. + * init.c (build_vec_init): Cast TREE_INT_CST_LOW to HOST_WIDE_INT. + * method.c (build_overload_int): Cast TREE_INT_CST_HIGH to unsigned. + * typeck.c (build_binary_op, case TRUNC_DIV_EXPR): + Call integer_all_onesp. + * typeck2.c (process_init_constructor): Use compare_tree_int. + * lang-specs.h (as): Don't call if -syntax-only. 2000-03-06 Mark Mitchell <mark@codesourcery.com> diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c76146a..d19172a 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3108,7 +3108,7 @@ dfs_modify_vtables (binfo, data) tree overrider; tree vindex; tree delta; - HOST_WIDE_INT i; + unsigned HOST_WIDE_INT i; /* Find the function which originally caused this vtable entry to be present. */ @@ -3627,7 +3627,6 @@ check_bitfield_decl (field) if (DECL_INITIAL (field)) { tree w = DECL_INITIAL (field); - register int width = 0; /* Avoid the non_lvalue wrapper added by fold for PLUS_EXPRs. */ STRIP_NOPS (w); @@ -3644,19 +3643,19 @@ check_bitfield_decl (field) field); DECL_INITIAL (field) = NULL_TREE; } - else if (width = TREE_INT_CST_LOW (w), - width < 0) + else if (tree_int_cst_sgn (w) < 0) { DECL_INITIAL (field) = NULL; cp_error_at ("negative width in bit-field `%D'", field); } - else if (width == 0 && DECL_NAME (field) != 0) + else if (integer_zerop (w) && DECL_NAME (field) != 0) { DECL_INITIAL (field) = NULL; cp_error_at ("zero width for bit-field `%D'", field); } - else if (width - > TYPE_PRECISION (long_long_unsigned_type_node)) + else if (0 < compare_tree_int (w, + TYPE_PRECISION + (long_long_unsigned_type_node))) { /* The backend will dump if you try to use something too big; avoid that. */ @@ -3665,25 +3664,28 @@ check_bitfield_decl (field) TYPE_PRECISION (long_long_unsigned_type_node)); cp_error_at (" in declaration of `%D'", field); } - else if (width > TYPE_PRECISION (type) + else if (compare_tree_int (w, TYPE_PRECISION (type)) > 0 && TREE_CODE (type) != ENUMERAL_TYPE && TREE_CODE (type) != BOOLEAN_TYPE) cp_warning_at ("width of `%D' exceeds its type", field); else if (TREE_CODE (type) == ENUMERAL_TYPE - && ((min_precision (TYPE_MIN_VALUE (type), - TREE_UNSIGNED (type)) > width) - || (min_precision (TYPE_MAX_VALUE (type), - TREE_UNSIGNED (type)) > width))) + && (0 > compare_tree_int (w, + min_precision (TYPE_MIN_VALUE (type), + TREE_UNSIGNED (type))) + || 0 > compare_tree_int (w, + min_precision + (TYPE_MAX_VALUE (type), + TREE_UNSIGNED (type))))) cp_warning_at ("`%D' is too small to hold all values of `%#T'", field, type); if (DECL_INITIAL (field)) { DECL_INITIAL (field) = NULL_TREE; - DECL_SIZE (field) = bitsize_int (width); + DECL_SIZE (field) = bitsize_int (TREE_INT_CST_LOW (w)); DECL_BIT_FIELD (field) = 1; - if (width == 0) + if (integer_zerop (w)) { #ifdef EMPTY_FIELD_BOUNDARY DECL_ALIGN (field) = MAX (DECL_ALIGN (field), @@ -4164,10 +4166,11 @@ build_base_field (t, binfo, empty_p, saw_empty_p, base_align) here. */ *base_align = MAX (*base_align, DECL_ALIGN (decl)); DECL_SIZE (decl) - = size_int (MAX (TREE_INT_CST_LOW (DECL_SIZE (decl)), + = size_int (MAX ((HOST_WIDE_INT) TREE_INT_CST_LOW (DECL_SIZE (decl)), (int) (*base_align))); DECL_SIZE_UNIT (decl) - = size_int (MAX (TREE_INT_CST_LOW (DECL_SIZE_UNIT (decl)), + = size_int (MAX (((HOST_WIDE_INT) TREE_INT_CST_LOW + (DECL_SIZE_UNIT (decl))), (int) *base_align / BITS_PER_UNIT)); } diff --git a/gcc/cp/error.c b/gcc/cp/error.c index ae6b511..0a26384 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1490,11 +1490,12 @@ dump_expr (t, flags) dump_char (TREE_INT_CST_LOW (t)); OB_PUTC ('\''); } - else if (TREE_INT_CST_HIGH (t) + else if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (t) != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1))) { tree val = t; - if (TREE_INT_CST_HIGH (val) < 0) + + if (tree_int_cst_sgn (val) < 0) { OB_PUTC ('-'); val = build_int_2 (~TREE_INT_CST_LOW (val), diff --git a/gcc/cp/init.c b/gcc/cp/init.c index fb6c4e6..a2e0d22 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2873,8 +2873,9 @@ build_vec_init (decl, base, maxindex, init, from_array) if (from_array || (TYPE_NEEDS_CONSTRUCTING (type) - && !(TREE_CODE (maxindex) == INTEGER_CST - && num_initialized_elts == TREE_INT_CST_LOW (maxindex) + 1))) + && ! (TREE_CODE (maxindex) == INTEGER_CST + && (num_initialized_elts + == (HOST_WIDE_INT) TREE_INT_CST_LOW (maxindex) + 1)))) { /* If the ITERATOR is equal to -1, then we don't have to loop; we've already initialized all the elements. */ diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 6fd98df..4a41e5a 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -600,7 +600,7 @@ build_overload_int (value, flags) /* If the high-order word is not merely a sign-extension of the low-order word, we must use a special output routine that can deal with this. */ - if (TREE_INT_CST_HIGH (value) + if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (value) != (TREE_INT_CST_LOW (value) >> (HOST_BITS_PER_WIDE_INT - 1))) { multiple_words_p = 1; @@ -608,8 +608,8 @@ build_overload_int (value, flags) multiple_digits_p = 1; } else - multiple_digits_p = (TREE_INT_CST_LOW (value) > 9 - || TREE_INT_CST_LOW (value) < -9); + multiple_digits_p = ((HOST_WIDE_INT) TREE_INT_CST_LOW (value) > 9 + || (HOST_WIDE_INT) TREE_INT_CST_LOW (value) < -9); /* If necessary, add a leading underscore. */ if (multiple_digits_p && (flags & mf_use_underscores_around_value)) diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 135378d..a47b088 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3436,8 +3436,8 @@ build_binary_op (code, orig_op0, orig_op1) shorten = ((TREE_CODE (op0) == NOP_EXPR && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0)))) || (TREE_CODE (op1) == INTEGER_CST - && (TREE_INT_CST_LOW (op1) != -1 - || TREE_INT_CST_HIGH (op1) != -1))); + && ! integer_all_onesp (op1))); + common = 1; } break; @@ -3491,8 +3491,7 @@ build_binary_op (code, orig_op0, orig_op1) shorten = ((TREE_CODE (op0) == NOP_EXPR && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0)))) || (TREE_CODE (op1) == INTEGER_CST - && (TREE_INT_CST_LOW (op1) != -1 - || TREE_INT_CST_HIGH (op1) != -1))); + && ! integer_all_onesp (op1))); common = 1; } break; diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 88ddc89..9c1a33e 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -754,7 +754,7 @@ process_init_constructor (type, init, elts) { if (TREE_PURPOSE (tail) && (TREE_CODE (TREE_PURPOSE (tail)) != INTEGER_CST - || TREE_INT_CST_LOW (TREE_PURPOSE (tail)) != i)) + || compare_tree_int (TREE_PURPOSE (tail), i) != 0)) sorry ("non-trivial labeled initializers"); if (TREE_VALUE (tail) != 0) @@ -1305,19 +1305,19 @@ enum_name_string (value, type) tree type; { register tree values = TYPE_VALUES (type); - register HOST_WIDE_INT intval = TREE_INT_CST_LOW (value); my_friendly_assert (TREE_CODE (type) == ENUMERAL_TYPE, 324); - while (values - && TREE_INT_CST_LOW (TREE_VALUE (values)) != intval) + + while (values && ! tree_int_cst_equal (TREE_VALUE (values), value)) values = TREE_CHAIN (values); + if (values == NULL_TREE) { - char *buf = (char *)oballoc (16 + TYPE_NAME_LENGTH (type)); + char *buf = (char *) oballoc (16 + TYPE_NAME_LENGTH (type)); /* Value must have been cast. */ sprintf (buf, "(enum %s)%ld", - TYPE_NAME_STRING (type), (long) intval); + TYPE_NAME_STRING (type), (long) TREE_INT_CST_LOW (value)); return buf; } return IDENTIFIER_POINTER (TREE_PURPOSE (values)); diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 213c66b..4c84c31 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -1508,7 +1508,7 @@ dbxout_type (type, full, show_arg_types) fprintf (asmfile, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (TREE_VALUE (tem))); else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1 - && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0) + && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0) fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, TREE_INT_CST_LOW (TREE_VALUE (tem))); else diff --git a/gcc/except.c b/gcc/except.c index 0a563b4..405a53f 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -1414,8 +1414,7 @@ expand_eh_region_start_tree (decl, cleanup) /* is the second argument 2? */ && TREE_CODE (TREE_VALUE (args)) == INTEGER_CST - && TREE_INT_CST_LOW (TREE_VALUE (args)) == 2 - && TREE_INT_CST_HIGH (TREE_VALUE (args)) == 0 + && compare_tree_int (TREE_VALUE (args), 2) == 0 /* Make sure there are no other arguments. */ && TREE_CHAIN (args) == NULL_TREE) @@ -3979,7 +3979,7 @@ is_zeros_p (exp) return is_zeros_p (TREE_OPERAND (exp, 0)); case INTEGER_CST: - return TREE_INT_CST_LOW (exp) == 0 && TREE_INT_CST_HIGH (exp) == 0; + return integer_zerop (exp); case COMPLEX_CST: return @@ -4317,14 +4317,15 @@ store_constructor (exp, target, align, cleared, size) { tree lo_index = TREE_OPERAND (index, 0); tree hi_index = TREE_OPERAND (index, 1); + if (TREE_CODE (lo_index) != INTEGER_CST || TREE_CODE (hi_index) != INTEGER_CST) { need_to_clear = 1; break; } - this_node_count = TREE_INT_CST_LOW (hi_index) - - TREE_INT_CST_LOW (lo_index) + 1; + this_node_count = (TREE_INT_CST_LOW (hi_index) + - TREE_INT_CST_LOW (lo_index) + 1); } else this_node_count = 1; @@ -4594,8 +4595,8 @@ store_constructor (exp, target, align, cleared, size) ? nbits != 1 : (TREE_CODE (TREE_VALUE (elt)) != INTEGER_CST || TREE_CODE (TREE_PURPOSE (elt)) != INTEGER_CST - || (TREE_INT_CST_LOW (TREE_VALUE (elt)) - - TREE_INT_CST_LOW (TREE_PURPOSE (elt)) + 1 + || ((HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (elt)) + - (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_PURPOSE (elt)) + 1 != nbits)))) clear_storage (target, expr_size (exp), TYPE_ALIGN (type) / BITS_PER_UNIT); @@ -4777,10 +4778,9 @@ store_field (target, bitsize, bitpos, mode, exp, value_mode, /* If the RHS and field are a constant size and the size of the RHS isn't the same size as the bitfield, we must use bitfield operations. */ - || ((bitsize >= 0 - && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST) - && (TREE_INT_CST_HIGH (TYPE_SIZE (TREE_TYPE (exp))) != 0 - || TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) != bitsize))) + || (bitsize >= 0 + && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST + && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0)) { rtx temp = expand_expr (exp, NULL_RTX, VOIDmode, 0); @@ -6008,8 +6008,7 @@ expand_expr (exp, target, tmode, modifier) case INTEGER_CST: return immed_double_const (TREE_INT_CST_LOW (exp), - TREE_INT_CST_HIGH (exp), - mode); + TREE_INT_CST_HIGH (exp), mode); case CONST_DECL: return expand_expr (DECL_INITIAL (exp), target, VOIDmode, @@ -6333,9 +6332,10 @@ expand_expr (exp, target, tmode, modifier) && ((mode == BLKmode && ! (target != 0 && safe_from_p (target, exp, 1))) || TREE_ADDRESSABLE (exp) - || (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && (!MOVE_BY_PIECES_P - (TREE_INT_CST_LOW (TYPE_SIZE (type))/BITS_PER_UNIT, + || (TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST + && TREE_INT_CST_HIGH (TYPE_SIZE_UNIT (type)) == 0 + && (! MOVE_BY_PIECES_P + (TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)), TYPE_ALIGN (type) / BITS_PER_UNIT)) && ! mostly_zeros_p (exp)))) || (modifier == EXPAND_INITIALIZER && TREE_CONSTANT (exp))) @@ -6385,18 +6385,17 @@ expand_expr (exp, target, tmode, modifier) tree exp2; tree index; tree string = string_constant (exp1, &index); - int i; /* Try to optimize reads from const strings. */ if (string && TREE_CODE (string) == STRING_CST && TREE_CODE (index) == INTEGER_CST - && !TREE_INT_CST_HIGH (index) - && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (string) + && compare_tree_int (index, TREE_STRING_LENGTH (string)) < 0 && GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1 && modifier != EXPAND_MEMORY_USE_WO) - return GEN_INT (TREE_STRING_POINTER (string)[i]); + return + GEN_INT (TREE_STRING_POINTER (string)[TREE_INT_CST_LOW (index)]); op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM); op0 = memory_address (mode, op0); @@ -6481,31 +6480,33 @@ expand_expr (exp, target, tmode, modifier) if (TREE_CODE (array) == STRING_CST && TREE_CODE (index) == INTEGER_CST - && !TREE_INT_CST_HIGH (index) - && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (array) + && compare_tree_int (index, TREE_STRING_LENGTH (array)) < 0 && GET_MODE_CLASS (mode) == MODE_INT && GET_MODE_SIZE (mode) == 1) - return GEN_INT (TREE_STRING_POINTER (array)[i]); + return + GEN_INT (TREE_STRING_POINTER (array)[TREE_INT_CST_LOW (index)]); /* If this is a constant index into a constant array, just get the value from the array. Handle both the cases when we have an explicit constructor and when our operand is a variable that was declared const. */ - if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array)) + if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array) + && TREE_CODE (index) == INTEGER_CST + && 0 > compare_tree_int (index, + list_length (CONSTRUCTOR_ELTS + (TREE_OPERAND (exp, 0))))) { - if (TREE_CODE (index) == INTEGER_CST - && TREE_INT_CST_HIGH (index) == 0) - { - tree elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)); - - i = TREE_INT_CST_LOW (index); - while (elem && i--) - elem = TREE_CHAIN (elem); - if (elem) - return expand_expr (fold (TREE_VALUE (elem)), target, - tmode, ro_modifier); - } + tree elem; + + for (elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)), + i = TREE_INT_CST_LOW (index); + elem != 0 && i != 0; i--, elem = TREE_CHAIN (elem)) + ; + + if (elem) + return expand_expr (fold (TREE_VALUE (elem)), target, + tmode, ro_modifier); } else if (optimize >= 1 @@ -6517,22 +6518,22 @@ expand_expr (exp, target, tmode, modifier) { tree init = DECL_INITIAL (array); - i = TREE_INT_CST_LOW (index); if (TREE_CODE (init) == CONSTRUCTOR) { tree elem = CONSTRUCTOR_ELTS (init); - while (elem - && !tree_int_cst_equal (TREE_PURPOSE (elem), index)) - elem = TREE_CHAIN (elem); + for (elem = CONSTRUCTOR_ELTS (init); + ! tree_int_cst_equal (TREE_PURPOSE (elem), index); + elem = TREE_CHAIN (elem)) + ; + if (elem) return expand_expr (fold (TREE_VALUE (elem)), target, tmode, ro_modifier); } else if (TREE_CODE (init) == STRING_CST - && TREE_INT_CST_HIGH (index) == 0 - && (TREE_INT_CST_LOW (index) - < TREE_STRING_LENGTH (init))) + && 0 > compare_tree_int (index, + TREE_STRING_LENGTH (init))) return (GEN_INT (TREE_STRING_POINTER (init)[TREE_INT_CST_LOW (index)])); @@ -6763,10 +6764,8 @@ expand_expr (exp, target, tmode, modifier) || ((bitsize >= 0 && (TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST) - && ((TREE_INT_CST_HIGH (TYPE_SIZE (TREE_TYPE (exp))) - != 0) - || (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) - != bitsize)))))) + && 0 != compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), + bitsize))))) || (modifier != EXPAND_CONST_ADDRESS && modifier != EXPAND_INITIALIZER && mode == BLKmode @@ -8153,8 +8152,8 @@ expand_expr (exp, target, tmode, modifier) || TREE_CODE (rhs) == BIT_AND_EXPR) && TREE_OPERAND (rhs, 0) == lhs && TREE_CODE (TREE_OPERAND (rhs, 1)) == COMPONENT_REF - && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (lhs, 1))) == 1 - && TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1))) == 1) + && integer_onep (DECL_SIZE (TREE_OPERAND (lhs, 1))) + && integer_onep (DECL_SIZE (TREE_OPERAND (TREE_OPERAND (rhs, 1), 1)))) { rtx label = gen_label_rtx (); @@ -8539,20 +8538,20 @@ expand_expr_unaligned (exp, palign) we have an explicit constructor and when our operand is a variable that was declared const. */ - if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array)) + if (TREE_CODE (array) == CONSTRUCTOR && ! TREE_SIDE_EFFECTS (array) + && 0 > compare_tree_int (index, + list_length (CONSTRUCTOR_ELTS + (TREE_OPERAND (exp, 0))))) { - if (TREE_CODE (index) == INTEGER_CST - && TREE_INT_CST_HIGH (index) == 0) - { - tree elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)); - - i = TREE_INT_CST_LOW (index); - while (elem && i--) - elem = TREE_CHAIN (elem); - if (elem) - return expand_expr_unaligned (fold (TREE_VALUE (elem)), - palign); - } + tree elem; + + for (elem = CONSTRUCTOR_ELTS (TREE_OPERAND (exp, 0)), + i = TREE_INT_CST_LOW (index); + elem != 0 && i != 0; i--, elem = TREE_CHAIN (elem)) + ; + + if (elem) + return expand_expr_unaligned (fold (TREE_VALUE (elem)), palign); } else if (optimize >= 1 @@ -8564,14 +8563,15 @@ expand_expr_unaligned (exp, palign) { tree init = DECL_INITIAL (array); - i = TREE_INT_CST_LOW (index); if (TREE_CODE (init) == CONSTRUCTOR) { - tree elem = CONSTRUCTOR_ELTS (init); + tree elem; + + for (elem = CONSTRUCTOR_ELTS (init); + ! tree_int_cst_equal (TREE_PURPOSE (elem), index); + elem = TREE_CHAIN (elem)) + ; - while (elem - && !tree_int_cst_equal (TREE_PURPOSE (elem), index)) - elem = TREE_CHAIN (elem); if (elem) return expand_expr_unaligned (fold (TREE_VALUE (elem)), palign); @@ -9289,7 +9289,7 @@ do_jump (exp, if_false_label, if_true_label) if (! SLOW_BYTE_ACCESS && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT - && (i = floor_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))) >= 0 + && (i = tree_floor_log2 (TREE_OPERAND (exp, 1))) >= 0 && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode && (type = type_for_mode (mode, 1)) != 0 && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp)) @@ -10204,8 +10204,9 @@ do_store_flag (exp, target, mode, only_cheap) if (TREE_CODE (inner) == RSHIFT_EXPR && TREE_CODE (TREE_OPERAND (inner, 1)) == INTEGER_CST && TREE_INT_CST_HIGH (TREE_OPERAND (inner, 1)) == 0 - && (bitnum + TREE_INT_CST_LOW (TREE_OPERAND (inner, 1)) - < TYPE_PRECISION (type))) + && bitnum < TYPE_PRECISION (type) + && 0 > compare_tree_int (TREE_OPERAND (inner, 1), + bitnum - TYPE_PRECISION (type))) { bitnum += TREE_INT_CST_LOW (TREE_OPERAND (inner, 1)); inner = TREE_OPERAND (inner, 0); diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 780482a..815b83f 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,9 @@ +Mon Mar 6 18:05:19 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * com.c (ffecom_f2c_set_lio_code_): Use compare_tree_int. + (ffecom_sym_transform_, ffecom_transform_common_): Likewise. + (ffecom_transform_equiv_): Likewise. + Mon Mar 6 13:01:19 2000 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * ansify.c (die_unless): Don't use ANSI string concatenation. diff --git a/gcc/f/com.c b/gcc/f/com.c index 2554cad..a13853d 100644 --- a/gcc/f/com.c +++ b/gcc/f/com.c @@ -6043,8 +6043,8 @@ ffecom_f2c_set_lio_code_ (ffeinfoBasictype bt, int size, tree t; for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j) - if (((t = ffecom_tree_type[bt][j]) != NULL_TREE) - && (TREE_INT_CST_LOW (TYPE_SIZE (t)) == size)) + if ((t = ffecom_tree_type[bt][j]) != NULL_TREE + && compare_tree_int (TYPE_SIZE (t), size) == 0) { assert (code != -1); ffecom_f2c_typecode_[bt][j] = code; @@ -7757,9 +7757,8 @@ ffecom_sym_transform_ (ffesymbol s) if (st != NULL && DECL_SIZE (t) != error_mark_node) { assert (TREE_CODE (DECL_SIZE_UNIT (t)) == INTEGER_CST); - assert (TREE_INT_CST_HIGH (DECL_SIZE_UNIT (t)) == 0); - assert (TREE_INT_CST_LOW (DECL_SIZE_UNIT (t)) - == ffestorag_size (st)); + assert (0 == compare_tree_int (DECL_SIZE_UNIT (t), + ffestorag_size (st))); } resume_momentary (yes); @@ -8817,9 +8816,9 @@ ffecom_transform_common_ (ffesymbol s) { assert (DECL_SIZE_UNIT (cbt) != NULL_TREE); assert (TREE_CODE (DECL_SIZE_UNIT (cbt)) == INTEGER_CST); - assert (TREE_INT_CST_HIGH (DECL_SIZE_UNIT (cbt)) == 0); - assert (TREE_INT_CST_LOW (DECL_SIZE_UNIT (cbt)) - == ffeglobal_common_size (g) + ffeglobal_common_pad (g)); + assert (0 == compare_tree_int (DECL_SIZE_UNIT (cbt), + (ffeglobal_common_size (g) + + ffeglobal_common_pad (g)))); } ffeglobal_set_hook (g, cbt); @@ -8951,9 +8950,9 @@ ffecom_transform_equiv_ (ffestorag eqst) { assert (TREE_CODE (DECL_SIZE_UNIT (eqt)) == INTEGER_CST); - assert (TREE_INT_CST_HIGH (DECL_SIZE_UNIT (eqt)) == 0); - assert (TREE_INT_CST_LOW (DECL_SIZE_UNIT (eqt)) - == ffestorag_size (eqst) + ffestorag_modulo (eqst)); + assert (0 == compare_tree_int (DECL_SIZE_UNIT (eqt), + (ffestorag_size (eqst) + + ffestorag_modulo (eqst)))); } ffestorag_set_hook (eqst, eqt); diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 7a4a485..d24a7d1 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -54,13 +54,10 @@ Boston, MA 02111-1307, USA. */ #include "ggc.h" static void encode PARAMS ((HOST_WIDE_INT *, - HOST_WIDE_INT, HOST_WIDE_INT)); + unsigned HOST_WIDE_INT, + HOST_WIDE_INT)); static void decode PARAMS ((HOST_WIDE_INT *, - HOST_WIDE_INT *, HOST_WIDE_INT *)); -int div_and_round_double PARAMS ((enum tree_code, int, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT *, - HOST_WIDE_INT *, HOST_WIDE_INT *, + unsigned HOST_WIDE_INT *, HOST_WIDE_INT *)); static tree negate_expr PARAMS ((tree)); static tree split_tree PARAMS ((tree, enum tree_code, tree *, tree *, @@ -136,7 +133,8 @@ static int count_cond PARAMS ((tree, int)); static void encode (words, low, hi) HOST_WIDE_INT *words; - HOST_WIDE_INT low, hi; + unsigned HOST_WIDE_INT low; + HOST_WIDE_INT hi; { words[0] = LOWPART (low); words[1] = HIGHPART (low); @@ -151,7 +149,8 @@ encode (words, low, hi) static void decode (words, low, hi) HOST_WIDE_INT *words; - HOST_WIDE_INT *low, *hi; + unsigned HOST_WIDE_INT *low; + HOST_WIDE_INT *hi; { *low = words[0] + words[1] * BASE; *hi = words[2] + words[3] * BASE; @@ -172,8 +171,9 @@ force_fit_type (t, overflow) tree t; int overflow; { - HOST_WIDE_INT low, high; - register int prec; + unsigned HOST_WIDE_INT low; + HOST_WIDE_INT high; + unsigned int prec; if (TREE_CODE (t) == REAL_CST) { @@ -206,7 +206,7 @@ force_fit_type (t, overflow) { TREE_INT_CST_HIGH (t) = 0; if (prec < HOST_BITS_PER_WIDE_INT) - TREE_INT_CST_LOW (t) &= ~((HOST_WIDE_INT) (-1) << prec); + TREE_INT_CST_LOW (t) &= ~((unsigned HOST_WIDE_INT) (-1) << prec); } /* Unsigned types do not suffer sign extension or overflow. */ @@ -216,9 +216,11 @@ force_fit_type (t, overflow) /* If the value's sign bit is set, extend the sign. */ if (prec != 2 * HOST_BITS_PER_WIDE_INT && (prec > HOST_BITS_PER_WIDE_INT - ? (TREE_INT_CST_HIGH (t) - & ((HOST_WIDE_INT) 1 << (prec - HOST_BITS_PER_WIDE_INT - 1))) - : TREE_INT_CST_LOW (t) & ((HOST_WIDE_INT) 1 << (prec - 1)))) + ? 0 != (TREE_INT_CST_HIGH (t) + & ((HOST_WIDE_INT) 1 + << (prec - HOST_BITS_PER_WIDE_INT - 1))) + : 0 != (TREE_INT_CST_LOW (t) + & ((unsigned HOST_WIDE_INT) 1 << (prec - 1))))) { /* Value is negative: set to 1 all the bits that are outside this type's precision. */ @@ -229,7 +231,7 @@ force_fit_type (t, overflow) { TREE_INT_CST_HIGH (t) = -1; if (prec < HOST_BITS_PER_WIDE_INT) - TREE_INT_CST_LOW (t) |= ((HOST_WIDE_INT) (-1) << prec); + TREE_INT_CST_LOW (t) |= ((unsigned HOST_WIDE_INT) (-1) << prec); } } @@ -246,13 +248,16 @@ force_fit_type (t, overflow) int add_double (l1, h1, l2, h2, lv, hv) - HOST_WIDE_INT l1, h1, l2, h2; - HOST_WIDE_INT *lv, *hv; + unsigned HOST_WIDE_INT l1, l2; + HOST_WIDE_INT h1, h2; + unsigned HOST_WIDE_INT *lv; + HOST_WIDE_INT *hv; { - HOST_WIDE_INT l, h; + unsigned HOST_WIDE_INT l; + HOST_WIDE_INT h; l = l1 + l2; - h = h1 + h2 + ((unsigned HOST_WIDE_INT) l < (unsigned HOST_WIDE_INT) l1); + h = h1 + h2 + (l < l1); *lv = l; *hv = h; @@ -266,8 +271,10 @@ add_double (l1, h1, l2, h2, lv, hv) int neg_double (l1, h1, lv, hv) - HOST_WIDE_INT l1, h1; - HOST_WIDE_INT *lv, *hv; + unsigned HOST_WIDE_INT l1; + HOST_WIDE_INT h1; + unsigned HOST_WIDE_INT *lv; + HOST_WIDE_INT *hv; { if (l1 == 0) { @@ -291,15 +298,18 @@ neg_double (l1, h1, lv, hv) int mul_double (l1, h1, l2, h2, lv, hv) - HOST_WIDE_INT l1, h1, l2, h2; - HOST_WIDE_INT *lv, *hv; + unsigned HOST_WIDE_INT l1, l2; + HOST_WIDE_INT h1, h2; + unsigned HOST_WIDE_INT *lv; + HOST_WIDE_INT *hv; { HOST_WIDE_INT arg1[4]; HOST_WIDE_INT arg2[4]; HOST_WIDE_INT prod[4 * 2]; register unsigned HOST_WIDE_INT carry; register int i, j, k; - HOST_WIDE_INT toplow, tophigh, neglow, neghigh; + unsigned HOST_WIDE_INT toplow, neglow; + HOST_WIDE_INT tophigh, neghigh; encode (arg1, l1, h1); encode (arg2, l2, h2); @@ -348,9 +358,11 @@ mul_double (l1, h1, l2, h2, lv, hv) void lshift_double (l1, h1, count, prec, lv, hv, arith) - HOST_WIDE_INT l1, h1, count; - int prec; - HOST_WIDE_INT *lv, *hv; + unsigned HOST_WIDE_INT l1; + HOST_WIDE_INT h1, count; + unsigned int prec; + unsigned HOST_WIDE_INT *lv; + HOST_WIDE_INT *hv; int arith; { if (count < 0) @@ -373,14 +385,14 @@ lshift_double (l1, h1, count, prec, lv, hv, arith) } else if (count >= HOST_BITS_PER_WIDE_INT) { - *hv = (unsigned HOST_WIDE_INT) l1 << (count - HOST_BITS_PER_WIDE_INT); + *hv = l1 << (count - HOST_BITS_PER_WIDE_INT); *lv = 0; } else { *hv = (((unsigned HOST_WIDE_INT) h1 << count) - | ((unsigned HOST_WIDE_INT) l1 >> (HOST_BITS_PER_WIDE_INT - count - 1) >> 1)); - *lv = (unsigned HOST_WIDE_INT) l1 << count; + | (l1 >> (HOST_BITS_PER_WIDE_INT - count - 1) >> 1)); + *lv = l1 << count; } } @@ -391,12 +403,15 @@ lshift_double (l1, h1, count, prec, lv, hv, arith) void rshift_double (l1, h1, count, prec, lv, hv, arith) - HOST_WIDE_INT l1, h1, count; - int prec ATTRIBUTE_UNUSED; - HOST_WIDE_INT *lv, *hv; + unsigned HOST_WIDE_INT l1; + HOST_WIDE_INT h1, count; + unsigned int prec ATTRIBUTE_UNUSED; + unsigned HOST_WIDE_INT *lv; + HOST_WIDE_INT *hv; int arith; { unsigned HOST_WIDE_INT signmask; + signmask = (arith ? -((unsigned HOST_WIDE_INT) h1 >> (HOST_BITS_PER_WIDE_INT - 1)) : 0); @@ -421,7 +436,7 @@ rshift_double (l1, h1, count, prec, lv, hv, arith) } else { - *lv = (((unsigned HOST_WIDE_INT) l1 >> count) + *lv = ((l1 >> count) | ((unsigned HOST_WIDE_INT) h1 << (HOST_BITS_PER_WIDE_INT - count - 1) << 1)); *hv = ((signmask << (HOST_BITS_PER_WIDE_INT - count)) | ((unsigned HOST_WIDE_INT) h1 >> count)); @@ -435,11 +450,14 @@ rshift_double (l1, h1, count, prec, lv, hv, arith) void lrotate_double (l1, h1, count, prec, lv, hv) - HOST_WIDE_INT l1, h1, count; - int prec; - HOST_WIDE_INT *lv, *hv; + unsigned HOST_WIDE_INT l1; + HOST_WIDE_INT h1, count; + unsigned int prec; + unsigned HOST_WIDE_INT *lv; + HOST_WIDE_INT *hv; { - HOST_WIDE_INT s1l, s1h, s2l, s2h; + unsigned HOST_WIDE_INT s1l, s2l; + HOST_WIDE_INT s1h, s2h; count %= prec; if (count < 0) @@ -457,11 +475,14 @@ lrotate_double (l1, h1, count, prec, lv, hv) void rrotate_double (l1, h1, count, prec, lv, hv) - HOST_WIDE_INT l1, h1, count; - int prec; - HOST_WIDE_INT *lv, *hv; + unsigned HOST_WIDE_INT l1; + HOST_WIDE_INT h1, count; + unsigned int prec; + unsigned HOST_WIDE_INT *lv; + HOST_WIDE_INT *hv; { - HOST_WIDE_INT s1l, s1h, s2l, s2h; + unsigned HOST_WIDE_INT s1l, s2l; + HOST_WIDE_INT s1h, s2h; count %= prec; if (count < 0) @@ -488,23 +509,26 @@ div_and_round_double (code, uns, lquo, hquo, lrem, hrem) enum tree_code code; int uns; - HOST_WIDE_INT lnum_orig, hnum_orig; /* num == numerator == dividend */ - HOST_WIDE_INT lden_orig, hden_orig; /* den == denominator == divisor */ - HOST_WIDE_INT *lquo, *hquo, *lrem, *hrem; + unsigned HOST_WIDE_INT lnum_orig; /* num == numerator == dividend */ + HOST_WIDE_INT hnum_orig; + unsigned HOST_WIDE_INT lden_orig; /* den == denominator == divisor */ + HOST_WIDE_INT hden_orig; + unsigned HOST_WIDE_INT *lquo, *lrem; + HOST_WIDE_INT *hquo, *hrem; { int quo_neg = 0; HOST_WIDE_INT num[4 + 1]; /* extra element for scaling. */ HOST_WIDE_INT den[4], quo[4]; register int i, j; unsigned HOST_WIDE_INT work; - register unsigned HOST_WIDE_INT carry = 0; - HOST_WIDE_INT lnum = lnum_orig; + unsigned HOST_WIDE_INT carry = 0; + unsigned HOST_WIDE_INT lnum = lnum_orig; HOST_WIDE_INT hnum = hnum_orig; - HOST_WIDE_INT lden = lden_orig; + unsigned HOST_WIDE_INT lden = lden_orig; HOST_WIDE_INT hden = hden_orig; int overflow = 0; - if ((hden == 0) && (lden == 0)) + if (hden == 0 && lden == 0) overflow = 1, lden = 1; /* calculate quotient sign and convert operands to unsigned. */ @@ -514,7 +538,8 @@ div_and_round_double (code, uns, { quo_neg = ~ quo_neg; /* (minimum integer) / (-1) is the only overflow case. */ - if (neg_double (lnum, hnum, &lnum, &hnum) && (lden & hden) == -1) + if (neg_double (lnum, hnum, &lnum, &hnum) + && ((HOST_WIDE_INT) lden & hden) == -1) overflow = 1; } if (hden < 0) @@ -528,7 +553,7 @@ div_and_round_double (code, uns, { /* single precision */ *hquo = *hrem = 0; /* This unsigned division rounds toward zero. */ - *lquo = lnum / (unsigned HOST_WIDE_INT) lden; + *lquo = lnum / lden; goto finish_up; } @@ -550,106 +575,113 @@ div_and_round_double (code, uns, encode (den, lden, hden); /* Special code for when the divisor < BASE. */ - if (hden == 0 && lden < (HOST_WIDE_INT) BASE) + if (hden == 0 && lden < (unsigned HOST_WIDE_INT) BASE) { /* hnum != 0 already checked. */ for (i = 4 - 1; i >= 0; i--) { work = num[i] + carry * BASE; - quo[i] = work / (unsigned HOST_WIDE_INT) lden; - carry = work % (unsigned HOST_WIDE_INT) lden; + quo[i] = work / lden; + carry = work % lden; } } else { /* Full double precision division, with thanks to Don Knuth's "Seminumerical Algorithms". */ - int num_hi_sig, den_hi_sig; - unsigned HOST_WIDE_INT quo_est, scale; - - /* Find the highest non-zero divisor digit. */ - for (i = 4 - 1; ; i--) - if (den[i] != 0) { - den_hi_sig = i; - break; - } - - /* Insure that the first digit of the divisor is at least BASE/2. - This is required by the quotient digit estimation algorithm. */ - - scale = BASE / (den[den_hi_sig] + 1); - if (scale > 1) { /* scale divisor and dividend */ - carry = 0; - for (i = 0; i <= 4 - 1; i++) { - work = (num[i] * scale) + carry; - num[i] = LOWPART (work); - carry = HIGHPART (work); - } num[4] = carry; - carry = 0; - for (i = 0; i <= 4 - 1; i++) { - work = (den[i] * scale) + carry; - den[i] = LOWPART (work); - carry = HIGHPART (work); - if (den[i] != 0) den_hi_sig = i; - } - } + int num_hi_sig, den_hi_sig; + unsigned HOST_WIDE_INT quo_est, scale; - num_hi_sig = 4; + /* Find the highest non-zero divisor digit. */ + for (i = 4 - 1; ; i--) + if (den[i] != 0) { + den_hi_sig = i; + break; + } - /* Main loop */ - for (i = num_hi_sig - den_hi_sig - 1; i >= 0; i--) { - /* guess the next quotient digit, quo_est, by dividing the first - two remaining dividend digits by the high order quotient digit. - quo_est is never low and is at most 2 high. */ - unsigned HOST_WIDE_INT tmp; + /* Insure that the first digit of the divisor is at least BASE/2. + This is required by the quotient digit estimation algorithm. */ - num_hi_sig = i + den_hi_sig + 1; - work = num[num_hi_sig] * BASE + num[num_hi_sig - 1]; - if (num[num_hi_sig] != den[den_hi_sig]) - quo_est = work / den[den_hi_sig]; - else - quo_est = BASE - 1; + scale = BASE / (den[den_hi_sig] + 1); + if (scale > 1) + { /* scale divisor and dividend */ + carry = 0; + for (i = 0; i <= 4 - 1; i++) + { + work = (num[i] * scale) + carry; + num[i] = LOWPART (work); + carry = HIGHPART (work); + } - /* refine quo_est so it's usually correct, and at most one high. */ - tmp = work - quo_est * den[den_hi_sig]; - if (tmp < BASE - && den[den_hi_sig - 1] * quo_est > (tmp * BASE + num[num_hi_sig - 2])) - quo_est--; + num[4] = carry; + carry = 0; + for (i = 0; i <= 4 - 1; i++) + { + work = (den[i] * scale) + carry; + den[i] = LOWPART (work); + carry = HIGHPART (work); + if (den[i] != 0) den_hi_sig = i; + } + } - /* Try QUO_EST as the quotient digit, by multiplying the - divisor by QUO_EST and subtracting from the remaining dividend. - Keep in mind that QUO_EST is the I - 1st digit. */ + num_hi_sig = 4; - carry = 0; - for (j = 0; j <= den_hi_sig; j++) + /* Main loop */ + for (i = num_hi_sig - den_hi_sig - 1; i >= 0; i--) { - work = quo_est * den[j] + carry; - carry = HIGHPART (work); - work = num[i + j] - LOWPART (work); - num[i + j] = LOWPART (work); - carry += HIGHPART (work) != 0; - } + /* Guess the next quotient digit, quo_est, by dividing the first + two remaining dividend digits by the high order quotient digit. + quo_est is never low and is at most 2 high. */ + unsigned HOST_WIDE_INT tmp; + + num_hi_sig = i + den_hi_sig + 1; + work = num[num_hi_sig] * BASE + num[num_hi_sig - 1]; + if (num[num_hi_sig] != den[den_hi_sig]) + quo_est = work / den[den_hi_sig]; + else + quo_est = BASE - 1; - /* if quo_est was high by one, then num[i] went negative and - we need to correct things. */ + /* Refine quo_est so it's usually correct, and at most one high. */ + tmp = work - quo_est * den[den_hi_sig]; + if (tmp < BASE + && (den[den_hi_sig - 1] * quo_est + > (tmp * BASE + num[num_hi_sig - 2]))) + quo_est--; - if (num[num_hi_sig] < carry) - { - quo_est--; - carry = 0; /* add divisor back in */ + /* Try QUO_EST as the quotient digit, by multiplying the + divisor by QUO_EST and subtracting from the remaining dividend. + Keep in mind that QUO_EST is the I - 1st digit. */ + + carry = 0; for (j = 0; j <= den_hi_sig; j++) { - work = num[i + j] + den[j] + carry; + work = quo_est * den[j] + carry; carry = HIGHPART (work); + work = num[i + j] - LOWPART (work); num[i + j] = LOWPART (work); + carry += HIGHPART (work) != 0; } - num [num_hi_sig] += carry; - } - /* store the quotient digit. */ - quo[i] = quo_est; + /* If quo_est was high by one, then num[i] went negative and + we need to correct things. */ + if (num[num_hi_sig] < carry) + { + quo_est--; + carry = 0; /* add divisor back in */ + for (j = 0; j <= den_hi_sig; j++) + { + work = num[i + j] + den[j] + carry; + carry = HIGHPART (work); + num[i + j] = LOWPART (work); + } + + num [num_hi_sig] += carry; + } + + /* Store the quotient digit. */ + quo[i] = quo_est; + } } - } decode (quo, lquo, hquo); @@ -678,7 +710,8 @@ div_and_round_double (code, uns, add_double (*lquo, *hquo, (HOST_WIDE_INT) -1, (HOST_WIDE_INT) -1, lquo, hquo); } - else return overflow; + else + return overflow; break; case CEIL_DIV_EXPR: @@ -688,28 +721,33 @@ div_and_round_double (code, uns, add_double (*lquo, *hquo, (HOST_WIDE_INT) 1, (HOST_WIDE_INT) 0, lquo, hquo); } - else return overflow; + else + return overflow; break; case ROUND_DIV_EXPR: case ROUND_MOD_EXPR: /* round to closest integer */ { - HOST_WIDE_INT labs_rem = *lrem, habs_rem = *hrem; - HOST_WIDE_INT labs_den = lden, habs_den = hden, ltwice, htwice; - - /* get absolute values */ - if (*hrem < 0) neg_double (*lrem, *hrem, &labs_rem, &habs_rem); - if (hden < 0) neg_double (lden, hden, &labs_den, &habs_den); - - /* if (2 * abs (lrem) >= abs (lden)) */ + unsigned HOST_WIDE_INT labs_rem = *lrem; + HOST_WIDE_INT habs_rem = *hrem; + unsigned HOST_WIDE_INT labs_den = lden, ltwice; + HOST_WIDE_INT habs_den = hden, htwice; + + /* Get absolute values */ + if (*hrem < 0) + neg_double (*lrem, *hrem, &labs_rem, &habs_rem); + if (hden < 0) + neg_double (lden, hden, &labs_den, &habs_den); + + /* If (2 * abs (lrem) >= abs (lden)) */ mul_double ((HOST_WIDE_INT) 2, (HOST_WIDE_INT) 0, labs_rem, habs_rem, <wice, &htwice); + if (((unsigned HOST_WIDE_INT) habs_den < (unsigned HOST_WIDE_INT) htwice) || (((unsigned HOST_WIDE_INT) habs_den == (unsigned HOST_WIDE_INT) htwice) - && ((HOST_WIDE_INT unsigned) labs_den - < (unsigned HOST_WIDE_INT) ltwice))) + && (labs_den < ltwice))) { if (*hquo < 0) /* quo = quo - 1; */ @@ -720,7 +758,8 @@ div_and_round_double (code, uns, add_double (*lquo, *hquo, (HOST_WIDE_INT) 1, (HOST_WIDE_INT) 0, lquo, hquo); } - else return overflow; + else + return overflow; } break; @@ -1412,9 +1451,12 @@ int_const_binop (code, arg1, arg2, notrunc, forsize) register tree arg1, arg2; int notrunc, forsize; { - HOST_WIDE_INT int1l, int1h, int2l, int2h; - HOST_WIDE_INT low, hi; - HOST_WIDE_INT garbagel, garbageh; + unsigned HOST_WIDE_INT int1l, int2l; + HOST_WIDE_INT int1h, int2h; + unsigned HOST_WIDE_INT low; + HOST_WIDE_INT hi; + unsigned HOST_WIDE_INT garbagel; + HOST_WIDE_INT garbageh; register tree t; int uns = TREE_UNSIGNED (TREE_TYPE (arg1)); int overflow = 0; @@ -1482,13 +1524,14 @@ int_const_binop (code, arg1, arg2, notrunc, forsize) case FLOOR_DIV_EXPR: case CEIL_DIV_EXPR: case EXACT_DIV_EXPR: /* This is a shortcut for a common special case. */ - if (int2h == 0 && int2l > 0 + if (int2h == 0 && (HOST_WIDE_INT) int2l > 0 && ! TREE_CONSTANT_OVERFLOW (arg1) && ! TREE_CONSTANT_OVERFLOW (arg2) - && int1h == 0 && int1l >= 0) + && int1h == 0 && (HOST_WIDE_INT) int1l >= 0) { if (code == CEIL_DIV_EXPR) int1l += int2l - 1; + low = int1l / int2l, hi = 0; break; } @@ -1515,10 +1558,10 @@ int_const_binop (code, arg1, arg2, notrunc, forsize) case TRUNC_MOD_EXPR: case FLOOR_MOD_EXPR: case CEIL_MOD_EXPR: /* This is a shortcut for a common special case. */ - if (int2h == 0 && int2l > 0 + if (int2h == 0 && (HOST_WIDE_INT) int2l > 0 && ! TREE_CONSTANT_OVERFLOW (arg1) && ! TREE_CONSTANT_OVERFLOW (arg2) - && int1h == 0 && int1l >= 0) + && int1h == 0 && (HOST_WIDE_INT) int1l >= 0) { if (code == CEIL_MOD_EXPR) int1l += int2l - 1; @@ -1541,13 +1584,10 @@ int_const_binop (code, arg1, arg2, notrunc, forsize) < (unsigned HOST_WIDE_INT) int2h) || (((unsigned HOST_WIDE_INT) int1h == (unsigned HOST_WIDE_INT) int2h) - && ((unsigned HOST_WIDE_INT) int1l - < (unsigned HOST_WIDE_INT) int2l))); + && int1l < int2l)); else - low = ((int1h < int2h) - || ((int1h == int2h) - && ((unsigned HOST_WIDE_INT) int1l - < (unsigned HOST_WIDE_INT) int2l))); + low = (int1h < int2h + || (int1h == int2h && int1l < int2l)); if (low == (code == MIN_EXPR)) low = int1l, hi = int1h; @@ -1559,7 +1599,7 @@ int_const_binop (code, arg1, arg2, notrunc, forsize) abort (); } - if (forsize && hi == 0 && low >= 0 && low < 1000) + if (forsize && hi == 0 && low < 1000) return size_int_type_wide (low, TREE_TYPE (arg1)); else { @@ -1981,9 +2021,7 @@ fold_convert (t, arg1) /* If we are trying to make a sizetype for a small integer, use size_int to pick up cached types to reduce duplicate nodes. */ if (TREE_CODE (type) == INTEGER_CST && TYPE_IS_SIZETYPE (type) - && TREE_INT_CST_HIGH (arg1) == 0 - && TREE_INT_CST_LOW (arg1) >= 0 - && TREE_INT_CST_LOW (arg1) < 1000) + && compare_tree_int (arg1, 1000) < 0) return size_int_type_wide (TREE_INT_CST_LOW (arg1), type); /* Given an integer constant, make new constant with new type, @@ -2280,8 +2318,7 @@ operand_equal_p (arg0, arg1, only_const) case INTEGER_CST: return (! TREE_CONSTANT_OVERFLOW (arg0) && ! TREE_CONSTANT_OVERFLOW (arg1) - && TREE_INT_CST_LOW (arg0) == TREE_INT_CST_LOW (arg1) - && TREE_INT_CST_HIGH (arg0) == TREE_INT_CST_HIGH (arg1)); + && tree_int_cst_equal (arg0, arg1)); case REAL_CST: return (! TREE_CONSTANT_OVERFLOW (arg0) @@ -2691,8 +2728,7 @@ invert_truthvalue (arg) switch (code) { case INTEGER_CST: - return convert (type, build_int_2 (TREE_INT_CST_LOW (arg) == 0 - && TREE_INT_CST_HIGH (arg) == 0, 0)); + return convert (type, build_int_2 (integer_zerop (arg), 0)); case TRUTH_AND_EXPR: return build (TRUTH_OR_EXPR, type, @@ -5100,10 +5136,9 @@ fold (expr) /* Fold an expression like: "foo"[2] */ if (TREE_CODE (arg0) == STRING_CST && TREE_CODE (arg1) == INTEGER_CST - && !TREE_INT_CST_HIGH (arg1) - && (i = TREE_INT_CST_LOW (arg1)) < TREE_STRING_LENGTH (arg0)) + && compare_tree_int (arg1, TREE_STRING_LENGTH (arg0)) < 0) { - t = build_int_2 (TREE_STRING_POINTER (arg0)[i], 0); + t = build_int_2 (TREE_STRING_POINTER (arg0)[TREE_INT_CST_LOW (arg))], 0); TREE_TYPE (t) = TREE_TYPE (TREE_TYPE (arg0)); force_fit_type (t, 0); } @@ -5391,9 +5426,10 @@ fold (expr) STRIP_NOPS (tree110); STRIP_NOPS (tree111); if (TREE_CODE (tree110) == INTEGER_CST - && TREE_INT_CST_HIGH (tree110) == 0 - && (TREE_INT_CST_LOW (tree110) - == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg0, 0)))) + && 0 == compare_tree_int (tree110, + TYPE_PRECISION + (TREE_TYPE (TREE_OPERAND + (arg0, 0)))) && operand_equal_p (tree01, tree111, 0)) return build ((code0 == LSHIFT_EXPR ? LROTATE_EXPR @@ -5408,9 +5444,10 @@ fold (expr) STRIP_NOPS (tree010); STRIP_NOPS (tree011); if (TREE_CODE (tree010) == INTEGER_CST - && TREE_INT_CST_HIGH (tree010) == 0 - && (TREE_INT_CST_LOW (tree010) - == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg0, 0)))) + && 0 == compare_tree_int (tree010, + TYPE_PRECISION + (TREE_TYPE (TREE_OPERAND + (arg0, 0)))) && operand_equal_p (tree11, tree011, 0)) return build ((code0 != LSHIFT_EXPR ? LROTATE_EXPR @@ -5831,7 +5868,7 @@ fold (expr) && TREE_INT_CST_HIGH (TREE_OPERAND (arg0, 1)) == 0 && ((TREE_INT_CST_LOW (arg1) + TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1))) - == GET_MODE_BITSIZE (TYPE_MODE (type)))) + == (unsigned int) GET_MODE_BITSIZE (TYPE_MODE (type)))) return TREE_OPERAND (arg0, 0); goto binary; @@ -6414,7 +6451,7 @@ fold (expr) { if (TREE_INT_CST_HIGH (arg1) == 0 && (TREE_INT_CST_LOW (arg1) - == ((HOST_WIDE_INT) 1 << (width - 1)) - 1) + == ((unsigned HOST_WIDE_INT) 1 << (width - 1)) - 1) && ! TREE_UNSIGNED (TREE_TYPE (arg1))) switch (TREE_CODE (t)) { @@ -6440,7 +6477,7 @@ fold (expr) else if (TREE_INT_CST_HIGH (arg1) == -1 && (- TREE_INT_CST_LOW (arg1) - == ((HOST_WIDE_INT) 1 << (width - 1))) + == ((unsigned HOST_WIDE_INT) 1 << (width - 1))) && ! TREE_UNSIGNED (TREE_TYPE (arg1))) switch (TREE_CODE (t)) { @@ -6466,7 +6503,7 @@ fold (expr) else if (TREE_INT_CST_HIGH (arg1) == 0 && (TREE_INT_CST_LOW (arg1) - == ((HOST_WIDE_INT) 1 << (width - 1)) - 1) + == ((unsigned HOST_WIDE_INT) 1 << (width - 1)) - 1) && TREE_UNSIGNED (TREE_TYPE (arg1))) switch (TREE_CODE (t)) @@ -6663,11 +6700,7 @@ fold (expr) if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST) { if (code == EQ_EXPR) - t1 = build_int_2 ((TREE_INT_CST_LOW (arg0) - == TREE_INT_CST_LOW (arg1)) - && (TREE_INT_CST_HIGH (arg0) - == TREE_INT_CST_HIGH (arg1)), - 0); + t1 = build_int_2 (tree_int_cst_equal (arg0, arg1), 0); else t1 = build_int_2 ((TREE_UNSIGNED (TREE_TYPE (arg0)) ? INT_CST_LT_UNSIGNED (arg0, arg1) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 9da0e2c..1620c53 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,11 @@ +Mon Mar 6 18:07:07 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * decl.c (emit_init_test_initialization): Mark KEY as unused. + * expr.c (build_newarray): Cast TREE_INT_CST_LOW to HOST_WIDE_INT. + (build_anewarray): Likewise. + * parse.y (patch_newarray): Likewise. + * parse.c: Regenerated. + 2000-03-06 Bryce McKinlay <bryce@albatross.co.nz> * decl.c (init_decl_processing): Added new class fields `depth', diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 17ec135..13d2dd7 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1,6 +1,5 @@ /* Process declarations and variables for the GNU compiler for the Java(TM) language. - Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of GNU CC. @@ -1634,7 +1633,7 @@ build_result_decl (fndecl) static boolean emit_init_test_initialization (entry, key) struct hash_entry *entry; - hash_table_key key; + hash_table_key key ATTRIBUTE_UNUSED; { struct init_test_hash_entry *ite = (struct init_test_hash_entry *) entry; expand_decl (ite->init_test_decl); diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 832e662..4db334d 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -786,10 +786,11 @@ build_newarray (atype_value, length) int atype_value; tree length; { - tree type = build_java_array_type (decode_newarray_type (atype_value), - TREE_CODE (length) == INTEGER_CST - ? TREE_INT_CST_LOW (length) - : -1); + tree type + = build_java_array_type (decode_newarray_type (atype_value), + TREE_CODE (length) == INTEGER_CST + ? (HOST_WIDE_INT) TREE_INT_CST_LOW (length) : -1); + return build (CALL_EXPR, promote_type (type), build_address_of (soft_newarray_node), tree_cons (NULL_TREE, @@ -806,10 +807,11 @@ build_anewarray (class_type, length) tree class_type; tree length; { - tree type = build_java_array_type (class_type, - TREE_CODE (length) == INTEGER_CST - ? TREE_INT_CST_LOW (length) - : -1); + tree type + = build_java_array_type (class_type, + TREE_CODE (length) == INTEGER_CST + ? (HOST_WIDE_INT) TREE_INT_CST_LOW (length) : -1); + return build (CALL_EXPR, promote_type (type), build_address_of (soft_anewarray_node), tree_cons (NULL_TREE, length, diff --git a/gcc/java/parse.c b/gcc/java/parse.c index f8b97b8..2361f3d 100644 --- a/gcc/java/parse.c +++ b/gcc/java/parse.c @@ -13431,9 +13431,11 @@ patch_newarray (node) for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim)) { type = array_type; - array_type = build_java_array_type (type, - TREE_CODE (cdim) == INTEGER_CST ? - TREE_INT_CST_LOW (cdim) : -1); + array_type + = build_java_array_type (type, + TREE_CODE (cdim) == INTEGER_CST + ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim) + : -1); array_type = promote_type (array_type); } dims = nreverse (dims); diff --git a/gcc/java/parse.y b/gcc/java/parse.y index d1aa061..1fb2175 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -10824,9 +10824,11 @@ patch_newarray (node) for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim)) { type = array_type; - array_type = build_java_array_type (type, - TREE_CODE (cdim) == INTEGER_CST ? - TREE_INT_CST_LOW (cdim) : -1); + array_type + = build_java_array_type (type, + TREE_CODE (cdim) == INTEGER_CST + ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim) + : -1); array_type = promote_type (array_type); } dims = nreverse (dims); diff --git a/gcc/mkdeps.c b/gcc/mkdeps.c index 7b0f271..b4b1257 100644 --- a/gcc/mkdeps.c +++ b/gcc/mkdeps.c @@ -102,10 +102,12 @@ munge (filename) /* Given a pathname, calculate the non-directory part. This always knows how to handle Unix-style pathnames, and understands VMS and DOS paths on those systems. */ + /* Find the base name of a (partial) pathname FNAME. Returns a pointer into the string passed in. Accepts Unix (/-separated) paths on all systems, DOS and VMS paths on those systems. */ + static const char * base_name (fname) const char *fname; @@ -149,8 +151,10 @@ deps_free (d) struct deps *d; { unsigned int i; + for (i = 0; i < d->ntargets; i++) free ((PTR) d->targetv[i]); + for (i = 0; i < d->ndeps; i++) free ((PTR) d->depv[i]); @@ -172,6 +176,7 @@ deps_add_target (d, t) d->targetv = xrealloc (d->targetv, d->targets_size * sizeof (const char *)); } + d->targetv[d->ntargets++] = t; } @@ -267,7 +272,7 @@ deps_dummy_targets (d, fp) const struct deps *d; FILE *fp; { - int i; + unsigned int i; for (i = 1; i < d->ndeps; i++) { diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 1001efb..4d1b455 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -112,7 +112,7 @@ print_node_brief (file, prefix, node, indent) { fprintf (file, "-"); fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, - -TREE_INT_CST_LOW (node)); + -TREE_INT_CST_LOW (node)); } else fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX, @@ -1620,26 +1620,34 @@ extern void reg_to_stack PARAMS ((rtx, FILE *)); #endif /* In fold-const.c */ -extern int add_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT *, HOST_WIDE_INT *)); -extern int neg_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT *, HOST_WIDE_INT *)); -extern int mul_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT *, HOST_WIDE_INT *)); -extern void lshift_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, HOST_WIDE_INT *, - HOST_WIDE_INT *, int)); -extern void rshift_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, - HOST_WIDE_INT *, HOST_WIDE_INT *, int)); -extern void lrotate_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, HOST_WIDE_INT *, - HOST_WIDE_INT *)); -extern void rrotate_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, HOST_WIDE_INT *, - HOST_WIDE_INT *)); +extern int add_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern int neg_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern int mul_double PARAMS ((unsigned HOST_WIDE_INT, + HOST_WIDE_INT, + unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern void lshift_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *, int)); +extern void rshift_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *, int)); +extern void lrotate_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern void rrotate_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); /* In calls.c */ extern void emit_library_call PARAMS ((rtx, int, enum machine_mode, @@ -3801,9 +3801,8 @@ expand_decl (decl) else if (TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST && ! (flag_stack_check && ! STACK_CHECK_BUILTIN - && (TREE_INT_CST_HIGH (DECL_SIZE_UNIT (decl)) != 0 - || (TREE_INT_CST_LOW (DECL_SIZE_UNIT (decl)) - > STACK_CHECK_MAX_VAR_SIZE)))) + && 0 < compare_tree_int (DECL_SIZE_UNIT (decl), + STACK_CHECK_MAX_VAR_SIZE))) { /* Variable of fixed size that goes on the stack. */ rtx oldaddr = 0; @@ -4212,8 +4211,7 @@ expand_anon_union_decl (decl, cleanup, decl_elts) change the element's mode to the appropriate one for its size. */ if (mode == BLKmode && DECL_MODE (decl) != BLKmode) DECL_MODE (decl_elt) = mode - = mode_for_size (TREE_INT_CST_LOW (DECL_SIZE (decl_elt)), - MODE_INT, 1); + = mode_for_size_tree (DECL_SIZE (decl_elt), MODE_INT, 1); /* (SUBREG (MEM ...)) at RTL generation time is invalid, so we instead create a new MEM rtx with the proper mode. */ @@ -4962,8 +4960,8 @@ all_cases_count (type, spareness) { if (TREE_CODE (TYPE_MIN_VALUE (type)) != INTEGER_CST || TREE_CODE (TREE_VALUE (t)) != INTEGER_CST - || TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) + count - != TREE_INT_CST_LOW (TREE_VALUE (t))) + || (TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) + count + != TREE_INT_CST_LOW (TREE_VALUE (t)))) *spareness = 1; count++; } @@ -5402,10 +5400,8 @@ expand_end_case (orig_index) #endif /* HAVE_casesi */ #endif /* CASE_VALUES_THRESHOLD */ - else if (TREE_INT_CST_HIGH (range) != 0 - || count < (unsigned int) CASE_VALUES_THRESHOLD - || ((unsigned HOST_WIDE_INT) (TREE_INT_CST_LOW (range)) - > 10 * count) + else if (count < CASE_VALUES_THRESHOLD + || compare_tree_int (range, 10 * count) > 0 #ifndef ASM_OUTPUT_ADDR_DIFF_ELT || flag_pic #endif @@ -5768,7 +5764,8 @@ estimate_case_costs (node) if ((INT_CST_LT (n->low, min_ascii)) || INT_CST_LT (max_ascii, n->high)) return 0; - for (i = TREE_INT_CST_LOW (n->low); i <= TREE_INT_CST_LOW (n->high); i++) + for (i = (HOST_WIDE_INT) TREE_INT_CST_LOW (n->low); + i <= (HOST_WIDE_INT) TREE_INT_CST_LOW (n->high); i++) if (cost_table[i] < 0) return 0; } diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 3aa186c..d4bd2e8 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -177,14 +177,10 @@ mode_for_size_tree (size, class, limit) int limit; { if (TREE_CODE (size) != INTEGER_CST - || TREE_INT_CST_HIGH (size) != 0 - /* If the low-order part is so high as to appear negative, we can't - find a mode for that many bits. */ - || TREE_INT_CST_LOW (size) < 0 /* What we really want to say here is that the size can fit in a host integer, but we know there's no way we'd find a mode for this many bits, so there's no point in doing the precise test. */ - || TREE_INT_CST_LOW (size) > 1000) + || compare_tree_int (size, 1000) > 0) return BLKmode; else return mode_for_size (TREE_INT_CST_LOW (size), class, limit); @@ -236,7 +232,7 @@ int_mode_for_mode (mode) case MODE_CC: default: - abort(); + abort (); } return mode; @@ -391,13 +387,11 @@ layout_decl (decl, known_align) tree size = DECL_SIZE_UNIT (decl); if (size != 0 && TREE_CODE (size) == INTEGER_CST - && (TREE_INT_CST_HIGH (size) != 0 - || TREE_INT_CST_LOW (size) > larger_than_size)) + && compare_tree_int (size, larger_than_size) > 0) { - int size_as_int = TREE_INT_CST_LOW (size); + unsigned int size_as_int = TREE_INT_CST_LOW (size); - if (size_as_int == TREE_INT_CST_LOW (size) - && TREE_INT_CST_HIGH (size) == 0) + if (compare_tree_int (size, size_as_int) == 0) warning_with_decl (decl, "size of `%s' is %d bytes", size_as_int); else warning_with_decl (decl, "size of `%s' is larger than %d bytes", @@ -432,7 +426,7 @@ layout_record (rec) and VAR_SIZE is a tree expression. If VAR_SIZE is null, the size is just CONST_SIZE. Naturally we try to avoid using VAR_SIZE. */ - HOST_WIDE_INT const_size = 0; + unsigned HOST_WIDE_INT const_size = 0; tree var_size = 0; /* Once we start using VAR_SIZE, this is the maximum alignment that we know VAR_SIZE has. */ @@ -581,7 +575,7 @@ layout_record (rec) { unsigned int type_align = TYPE_ALIGN (type); register tree dsize = DECL_SIZE (field); - int field_size = TREE_INT_CST_LOW (dsize); + unsigned int field_size = TREE_INT_CST_LOW (dsize); /* A bit field may not span more units of alignment of its type than its type itself. Advance to next boundary if necessary. */ @@ -778,7 +772,7 @@ layout_union (rec) /* The size of the union, based on the fields scanned so far, is max (CONST_SIZE, VAR_SIZE). VAR_SIZE may be null; then CONST_SIZE by itself is the size. */ - register HOST_WIDE_INT const_size = 0; + unsigned HOST_WIDE_INT const_size = 0; register tree var_size = 0; #ifdef STRUCTURE_SIZE_BOUNDARY @@ -946,7 +940,7 @@ layout_type (type) break; case VOID_TYPE: - TYPE_SIZE (type) = size_zero_node; + TYPE_SIZE (type) = bitsize_int (0); TYPE_SIZE_UNIT (type) = size_zero_node; TYPE_ALIGN (type) = 1; TYPE_MODE (type) = VOIDmode; @@ -1113,7 +1107,7 @@ layout_type (type) Unless the member is BLKmode only because it isn't aligned. */ for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) { - int bitpos; + unsigned HOST_WIDE_INT bitpos; if (TREE_CODE (field) != FIELD_DECL || TREE_CODE (TREE_TYPE (field)) == ERROR_MARK) @@ -1195,8 +1189,7 @@ layout_type (type) then stick with BLKmode. */ && (! STRICT_ALIGNMENT || TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT - || ((int) TYPE_ALIGN (type) - >= TREE_INT_CST_LOW (TYPE_SIZE (type))))) + || compare_tree_int (TYPE_SIZE (type), TYPE_ALIGN (type)) <= 0)) { tree field; @@ -258,7 +258,7 @@ int (*lang_get_alias_set) PARAMS ((tree)); struct type_hash { struct type_hash *next; /* Next structure in the bucket. */ - int hashcode; /* Hash code of this type. */ + unsigned int hashcode; /* Hash code of this type. */ tree type; /* The type recorded here. */ }; @@ -1446,7 +1446,7 @@ real_value_from_int_cst (type, i) e = ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2)) * (double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))); d *= e; - e = (double) (unsigned HOST_WIDE_INT) (~ TREE_INT_CST_LOW (i)); + e = (double) (~ TREE_INT_CST_LOW (i)); d += e; d = (- d - 1.0); } @@ -1458,7 +1458,7 @@ real_value_from_int_cst (type, i) e = ((double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2)) * (double) ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 2))); d *= e; - e = (double) (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (i); + e = (double) TREE_INT_CST_LOW (i); d += e; } #endif /* not REAL_ARITHMETIC */ @@ -1671,14 +1671,16 @@ integer_all_onesp (expr) uns = TREE_UNSIGNED (TREE_TYPE (expr)); if (!uns) - return TREE_INT_CST_LOW (expr) == -1 && TREE_INT_CST_HIGH (expr) == -1; + return (TREE_INT_CST_LOW (expr) == ~ (unsigned HOST_WIDE_INT) 0 + && TREE_INT_CST_HIGH (expr) == -1); /* Note that using TYPE_PRECISION here is wrong. We care about the actual bits, not the (arbitrary) range of the type. */ prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (expr))); if (prec >= HOST_BITS_PER_WIDE_INT) { - int high_value, shift_amount; + HOST_WIDE_INT high_value; + int shift_amount; shift_amount = prec - HOST_BITS_PER_WIDE_INT; @@ -1692,11 +1694,11 @@ integer_all_onesp (expr) else high_value = ((HOST_WIDE_INT) 1 << shift_amount) - 1; - return TREE_INT_CST_LOW (expr) == -1 - && TREE_INT_CST_HIGH (expr) == high_value; + return (TREE_INT_CST_LOW (expr) == ~ (unsigned HOST_WIDE_INT) 0 + && TREE_INT_CST_HIGH (expr) == high_value); } else - return TREE_INT_CST_LOW (expr) == ((HOST_WIDE_INT) 1 << prec) - 1; + return TREE_INT_CST_LOW (expr) == ((unsigned HOST_WIDE_INT) 1 << prec) - 1; } /* Return 1 if EXPR is an integer constant that is a power of 2 (i.e., has only @@ -1784,6 +1786,46 @@ tree_log2 (expr) : exact_log2 (low)); } +/* Similar, but return the largest integer Y such that 2 ** Y is less + than or equal to EXPR. */ + +int +tree_floor_log2 (expr) + tree expr; +{ + int prec; + HOST_WIDE_INT high, low; + + STRIP_NOPS (expr); + + if (TREE_CODE (expr) == COMPLEX_CST) + return tree_log2 (TREE_REALPART (expr)); + + prec = (POINTER_TYPE_P (TREE_TYPE (expr)) + ? POINTER_SIZE : TYPE_PRECISION (TREE_TYPE (expr))); + + high = TREE_INT_CST_HIGH (expr); + low = TREE_INT_CST_LOW (expr); + + /* First clear all bits that are beyond the type's precision in case + we've been sign extended. Ignore if type's precision hasn't been set + since what we are doing is setting it. */ + + if (prec == 2 * HOST_BITS_PER_WIDE_INT || prec == 0) + ; + else if (prec > HOST_BITS_PER_WIDE_INT) + high &= ~((HOST_WIDE_INT) (-1) << (prec - HOST_BITS_PER_WIDE_INT)); + else + { + high = 0; + if (prec < HOST_BITS_PER_WIDE_INT) + low &= ~((HOST_WIDE_INT) (-1) << prec); + } + + return (high != 0 ? HOST_BITS_PER_WIDE_INT + floor_log2 (high) + : floor_log2 (low)); +} + /* Return 1 if EXPR is the real constant zero. */ int @@ -3422,7 +3464,7 @@ build_type_attribute_variant (ttype, attribute) { if ( ! attribute_list_equal (TYPE_ATTRIBUTES (ttype), attribute)) { - register int hashcode; + unsigned int hashcode; tree ntype; push_obstacks (TYPE_OBSTACK (ttype), TYPE_OBSTACK (ttype)); @@ -3437,9 +3479,9 @@ build_type_attribute_variant (ttype, attribute) TYPE_NEXT_VARIANT (ntype) = 0; set_type_quals (ntype, TYPE_UNQUALIFIED); - hashcode = TYPE_HASH (TREE_CODE (ntype)) - + TYPE_HASH (TREE_TYPE (ntype)) - + attribute_hash_list (attribute); + hashcode = (TYPE_HASH (TREE_CODE (ntype)) + + TYPE_HASH (TREE_TYPE (ntype)) + + attribute_hash_list (attribute)); switch (TREE_CODE (ntype)) { @@ -3799,11 +3841,11 @@ build_type_copy (type) with types in the TREE_VALUE slots), by adding the hash codes of the individual types. */ -int +unsigned int type_hash_list (list) tree list; { - register int hashcode; + unsigned int hashcode; register tree tail; for (hashcode = 0, tail = list; tail; tail = TREE_CHAIN (tail)) @@ -3817,7 +3859,7 @@ type_hash_list (list) tree type_hash_lookup (hashcode, type) - int hashcode; + unsigned int hashcode; tree type; { register struct type_hash *h; @@ -3857,7 +3899,7 @@ type_hash_lookup (hashcode, type) void type_hash_add (hashcode, type) - int hashcode; + unsigned int hashcode; tree type; { register struct type_hash *h; @@ -3885,7 +3927,7 @@ int debug_no_type_hash = 0; tree type_hash_canon (hashcode, type) - int hashcode; + unsigned int hashcode; tree type; { tree t1; @@ -3932,11 +3974,11 @@ mark_type_hash (arg) with names in the TREE_PURPOSE slots and args in the TREE_VALUE slots), by adding the hash codes of the individual attributes. */ -int +unsigned int attribute_hash_list (list) tree list; { - register int hashcode; + unsigned int hashcode; register tree tail; for (hashcode = 0, tail = list; tail; tail = TREE_CHAIN (tail)) @@ -4255,6 +4297,27 @@ simple_cst_equal (t1, t2) return -1; } } + +/* Compare the value of T, an INTEGER_CST, with U, an unsigned integer value. + Return -1, 0, or 1 if the value of T is less than, equal to, or greater + than U, respectively. */ + +int +compare_tree_int (t, u) + tree t; + unsigned int u; +{ + if (tree_int_cst_sgn (t) < 0) + return -1; + else if (TREE_INT_CST_HIGH (t) != 0) + return 1; + else if (TREE_INT_CST_LOW (t) == u) + return 0; + else if (TREE_INT_CST_LOW (t) < u) + return -1; + else + return 1; +} /* Constructors for pointer, array and function types. (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are @@ -4348,14 +4411,16 @@ build_index_type (maxval) TYPE_ALIGN (itype) = TYPE_ALIGN (sizetype); if (TREE_CODE (maxval) == INTEGER_CST) { - int maxint = (int) TREE_INT_CST_LOW (maxval); + int maxint = TREE_INT_CST_LOW (maxval); + /* If the domain should be empty, make sure the maxval remains -1 and is not spoiled by truncation. */ - if (INT_CST_LT (maxval, integer_zero_node)) + if (tree_int_cst_sgn (maxval) < 0) { TYPE_MAX_VALUE (itype) = build_int_2 (-1, -1); TREE_TYPE (TYPE_MAX_VALUE (itype)) = sizetype; } + return type_hash_canon (maxint < 0 ? ~maxint : maxint, itype); } else @@ -4396,9 +4461,10 @@ build_range_type (type, lowval, highval) if (highval && TREE_CODE (highval) == INTEGER_CST) highint = TREE_INT_CST_LOW (highval); else - highint = (~(unsigned HOST_WIDE_INT)0) >> 1; + highint = (~(unsigned HOST_WIDE_INT) 0) >> 1; maxint = (int) (highint - lowint); + return type_hash_canon (maxint < 0 ? ~maxint : maxint, itype); } else @@ -4454,7 +4520,7 @@ build_array_type (elt_type, index_type) tree elt_type, index_type; { register tree t; - int hashcode; + unsigned int hashcode; if (TREE_CODE (elt_type) == FUNCTION_TYPE) { @@ -4511,7 +4577,7 @@ build_function_type (value_type, arg_types) tree value_type, arg_types; { register tree t; - int hashcode; + unsigned int hashcode; if (TREE_CODE (value_type) == FUNCTION_TYPE) { @@ -4543,7 +4609,7 @@ build_method_type (basetype, type) tree basetype, type; { register tree t; - int hashcode; + unsigned int hashcode; /* Make a node of the sort we want. */ t = make_node (METHOD_TYPE); @@ -4580,7 +4646,7 @@ build_offset_type (basetype, type) tree basetype, type; { register tree t; - int hashcode; + unsigned int hashcode; /* Make a node of the sort we want. */ t = make_node (OFFSET_TYPE); @@ -4605,7 +4671,7 @@ build_complex_type (component_type) tree component_type; { register tree t; - int hashcode; + unsigned int hashcode; /* Make a node of the sort we want. */ t = make_node (COMPLEX_TYPE); @@ -4740,7 +4806,9 @@ get_unwidened (op, for_type) /* Don't crash if field not laid out yet. */ && DECL_SIZE (TREE_OPERAND (op, 1)) != 0) { - unsigned innerprec = TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1))); + unsigned int innerprec + = TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1))); + type = type_for_size (innerprec, TREE_UNSIGNED (TREE_OPERAND (op, 1))); /* We can get this structure field in the narrowest type it fits in. @@ -4822,7 +4890,9 @@ get_narrower (op, unsignedp_ptr) /* Since type_for_size always gives an integer type. */ && TREE_CODE (TREE_TYPE (op)) != REAL_TYPE) { - unsigned innerprec = TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1))); + unsigned int innerprec + = TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (op, 1))); + tree type = type_for_size (innerprec, TREE_UNSIGNED (op)); /* We can get this structure field in a narrower type that fits it, @@ -5221,6 +5291,7 @@ get_set_constructor_bits (init, buffer, bit_size) = TREE_INT_CST_LOW (TREE_PURPOSE (vals)) - domain_min; HOST_WIDE_INT hi_index = TREE_INT_CST_LOW (TREE_VALUE (vals)) - domain_min; + if (lo_index < 0 || lo_index >= bit_size || hi_index < 0 || hi_index >= bit_size) abort (); @@ -5428,6 +5499,7 @@ void build_common_tree_nodes_2 (short_double) int short_double; { + /* Define these next since types below may used them. */ integer_zero_node = build_int_2 (0, 0); TREE_TYPE (integer_zero_node) = integer_type_node; integer_one_node = build_int_2 (1, 0); @@ -5439,7 +5511,7 @@ build_common_tree_nodes_2 (short_double) TREE_TYPE (size_one_node) = sizetype; void_type_node = make_node (VOID_TYPE); - layout_type (void_type_node); /* Uses size_zero_node */ + layout_type (void_type_node); /* We are not going to have real types in C with less than byte alignment, so we might as well not have any types that claim to have it. */ @@ -630,23 +630,21 @@ extern void tree_class_check_failed PARAMS ((const tree, char, #define INT_CST_LT(A, B) \ (TREE_INT_CST_HIGH (A) < TREE_INT_CST_HIGH (B) \ || (TREE_INT_CST_HIGH (A) == TREE_INT_CST_HIGH (B) \ - && ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (A) \ - < (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (B)))) + && TREE_INT_CST_LOW (A) < TREE_INT_CST_LOW (B))) #define INT_CST_LT_UNSIGNED(A, B) \ (((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (A) \ < (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (B)) \ || (((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (A) \ - == (unsigned HOST_WIDE_INT ) TREE_INT_CST_HIGH (B)) \ - && (((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (A) \ - < (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (B))))) + == (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (B)) \ + && TREE_INT_CST_LOW (A) < TREE_INT_CST_LOW (B))) struct tree_int_cst { char common[sizeof (struct tree_common)]; struct rtx_def *rtl; /* acts as link to register transfer language (rtl) info */ - HOST_WIDE_INT int_cst_low; + unsigned HOST_WIDE_INT int_cst_low; HOST_WIDE_INT int_cst_high; }; @@ -1698,7 +1696,7 @@ extern tree array_type_nelts PARAMS ((tree)); extern tree value_member PARAMS ((tree, tree)); extern tree purpose_member PARAMS ((tree, tree)); extern tree binfo_member PARAMS ((tree, tree)); -extern int attribute_hash_list PARAMS ((tree)); +extern unsigned int attribute_hash_list PARAMS ((tree)); extern int attribute_list_equal PARAMS ((tree, tree)); extern int attribute_list_contained PARAMS ((tree, tree)); extern int tree_int_cst_equal PARAMS ((tree, tree)); @@ -1787,7 +1785,7 @@ extern void layout_type PARAMS ((tree)); How the hash code is computed is up to the caller, as long as any two callers that could hash identical-looking type nodes agree. */ -extern tree type_hash_canon PARAMS ((int, tree)); +extern tree type_hash_canon PARAMS ((unsigned int, tree)); /* Given a VAR_DECL, PARM_DECL, RESULT_DECL or FIELD_DECL node, calculates the DECL_SIZE, DECL_SIZE_UNIT, DECL_ALIGN and DECL_MODE @@ -2218,26 +2216,34 @@ extern int stmt_loop_nest_empty PARAMS ((void)); extern tree fold PARAMS ((tree)); extern int force_fit_type PARAMS ((tree, int)); -extern int add_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT *, HOST_WIDE_INT *)); -extern int neg_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT *, HOST_WIDE_INT *)); -extern int mul_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT *, HOST_WIDE_INT *)); -extern void lshift_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, HOST_WIDE_INT *, - HOST_WIDE_INT *, int)); -extern void rshift_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, - HOST_WIDE_INT *, HOST_WIDE_INT *, int)); -extern void lrotate_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, HOST_WIDE_INT *, - HOST_WIDE_INT *)); -extern void rrotate_double PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, int, HOST_WIDE_INT *, - HOST_WIDE_INT *)); +extern int add_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern int neg_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern int mul_double PARAMS ((unsigned HOST_WIDE_INT, + HOST_WIDE_INT, + unsigned HOST_WIDE_INT, HOST_WIDE_INT, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern void lshift_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *, int)); +extern void rshift_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *, int)); +extern void lrotate_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); +extern void rrotate_double PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, unsigned int, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); extern int operand_equal_p PARAMS ((tree, tree, int)); extern tree invert_truthvalue PARAMS ((tree)); @@ -2394,19 +2400,21 @@ extern tree get_file_function_name PARAMS ((int)); extern void set_identifier_size PARAMS ((int)); extern int int_fits_type_p PARAMS ((tree, tree)); extern int tree_log2 PARAMS ((tree)); +extern int tree_floor_log2 PARAMS ((tree)); extern void preserve_initializer PARAMS ((void)); extern void preserve_data PARAMS ((void)); extern int object_permanent_p PARAMS ((tree)); extern int type_precision PARAMS ((tree)); extern int simple_cst_equal PARAMS ((tree, tree)); +extern int compare_tree_int PARAMS ((tree, unsigned int)); extern int type_list_equal PARAMS ((tree, tree)); extern int chain_member PARAMS ((tree, tree)); extern int chain_member_purpose PARAMS ((tree, tree)); extern int chain_member_value PARAMS ((tree, tree)); extern tree listify PARAMS ((tree)); -extern tree type_hash_lookup PARAMS ((int, tree)); -extern void type_hash_add PARAMS ((int, tree)); -extern int type_hash_list PARAMS ((tree)); +extern tree type_hash_lookup PARAMS ((unsigned int, tree)); +extern void type_hash_add PARAMS ((unsigned int, tree)); +extern unsigned int type_hash_list PARAMS ((tree)); extern int simple_cst_list_equal PARAMS ((tree, tree)); extern void debug_obstack PARAMS ((char *)); extern void rtl_in_current_obstack PARAMS ((void)); @@ -2449,6 +2457,7 @@ extern void free_temp_slots PARAMS ((void)); extern void pop_temp_slots PARAMS ((void)); extern void push_temp_slots PARAMS ((void)); extern void preserve_temp_slots PARAMS ((struct rtx_def *)); +extern void preserve_rtl_expr_temps PARAMS ((tree)); extern int aggregate_value_p PARAMS ((tree)); extern tree reorder_blocks PARAMS ((tree, struct rtx_def *)); @@ -2505,7 +2514,7 @@ extern void print_lang_statistics PARAMS ((void)); /* In c-common.c */ extern tree truthvalue_conversion PARAMS ((tree)); -extern int min_precision PARAMS ((tree, int)); +extern unsigned int min_precision PARAMS ((tree, int)); extern void split_specs_attrs PARAMS ((tree, tree *, tree *)); /* In c-decl.c */ @@ -2537,12 +2546,14 @@ extern void variable_section PARAMS ((tree, int)); /* In fold-const.c */ extern int div_and_round_double PARAMS ((enum tree_code, int, - HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT, HOST_WIDE_INT, - HOST_WIDE_INT *, - HOST_WIDE_INT *, - HOST_WIDE_INT *, - HOST_WIDE_INT *)); + unsigned HOST_WIDE_INT, + HOST_WIDE_INT, + unsigned HOST_WIDE_INT, + HOST_WIDE_INT, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *, + unsigned HOST_WIDE_INT *, + HOST_WIDE_INT *)); /* In stmt.c */ extern void emit_nop PARAMS ((void)); diff --git a/gcc/varasm.c b/gcc/varasm.c index a3d4317..b903220 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1424,7 +1424,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data) if (! dont_output_data) { - int size; + unsigned int size; if (TREE_CODE (DECL_SIZE_UNIT (decl)) != INTEGER_CST) goto finish; @@ -1432,8 +1432,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data) size_tree = DECL_SIZE_UNIT (decl); size = TREE_INT_CST_LOW (size_tree); - if (TREE_INT_CST_HIGH (size_tree) != 0 - || size != TREE_INT_CST_LOW (size_tree)) + if (compare_tree_int (size_tree, size) != 0) { error_with_decl (decl, "size of variable `%s' is too large"); goto finish; |