diff options
author | Kenneth Zadeck <zadeck@naturalbridge.com> | 2014-05-06 16:25:05 +0000 |
---|---|---|
committer | Mike Stump <mrs@gcc.gnu.org> | 2014-05-06 16:25:05 +0000 |
commit | 807e902eea17f3132488c256c963823976b2348c (patch) | |
tree | e5e1af94eb1502ba893bd6ce4a11f68877ff62a9 /gcc/cp | |
parent | 6122336c832dc4dfedc49279549caddce86306ff (diff) | |
download | gcc-807e902eea17f3132488c256c963823976b2348c.zip gcc-807e902eea17f3132488c256c963823976b2348c.tar.gz gcc-807e902eea17f3132488c256c963823976b2348c.tar.bz2 |
Merge in wide-int.
From-SVN: r210113
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/call.c | 7 | ||||
-rw-r--r-- | gcc/cp/class.c | 27 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 34 | ||||
-rw-r--r-- | gcc/cp/init.c | 46 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 25 | ||||
-rw-r--r-- | gcc/cp/tree.c | 4 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 11 |
8 files changed, 75 insertions, 84 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 8c55c32..857df57 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-objc.h" #include "timevar.h" #include "cgraph.h" +#include "wide-int.h" /* The various kinds of conversion. */ @@ -6576,8 +6577,7 @@ type_passed_as (tree type) else if (targetm.calls.promote_prototypes (type) && INTEGRAL_TYPE_P (type) && COMPLETE_TYPE_P (type) - && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), - TYPE_SIZE (integer_type_node))) + && tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) type = integer_type_node; return type; @@ -6617,8 +6617,7 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain) else if (targetm.calls.promote_prototypes (type) && INTEGRAL_TYPE_P (type) && COMPLETE_TYPE_P (type) - && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), - TYPE_SIZE (integer_type_node))) + && tree_int_cst_lt (TYPE_SIZE (type), TYPE_SIZE (integer_type_node))) val = cp_perform_integral_promotions (val, complain); if ((complain & tf_warning) && warn_suggest_attribute_format) diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 5cac488..c96d79d 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "dumpfile.h" #include "splay-tree.h" #include "gimplify.h" +#include "wide-int.h" /* The number of nested classes being processed. If we are not in the scope of any class, this is zero. */ @@ -3811,7 +3812,7 @@ walk_subobject_offsets (tree type, /* If this OFFSET is bigger than the MAX_OFFSET, then we should stop. */ - if (max_offset && INT_CST_LT (max_offset, offset)) + if (max_offset && tree_int_cst_lt (max_offset, offset)) return 0; if (type == error_mark_node) @@ -3968,8 +3969,8 @@ walk_subobject_offsets (tree type, for (index = size_zero_node; /* G++ 3.2 had an off-by-one error here. */ (abi_version_at_least (2) - ? !INT_CST_LT (TYPE_MAX_VALUE (domain), index) - : INT_CST_LT (index, TYPE_MAX_VALUE (domain))); + ? !tree_int_cst_lt (TYPE_MAX_VALUE (domain), index) + : tree_int_cst_lt (index, TYPE_MAX_VALUE (domain))); index = size_binop (PLUS_EXPR, index, size_one_node)) { r = walk_subobject_offsets (TREE_TYPE (type), @@ -3985,7 +3986,7 @@ walk_subobject_offsets (tree type, /* If this new OFFSET is bigger than the MAX_OFFSET, then there's no point in iterating through the remaining elements of the array. */ - if (max_offset && INT_CST_LT (max_offset, offset)) + if (max_offset && tree_int_cst_lt (max_offset, offset)) break; } } @@ -5922,7 +5923,7 @@ end_of_class (tree t, int include_virtuals_p) continue; offset = end_of_base (base_binfo); - if (INT_CST_LT_UNSIGNED (result, offset)) + if (tree_int_cst_lt (result, offset)) result = offset; } @@ -5932,7 +5933,7 @@ end_of_class (tree t, int include_virtuals_p) vec_safe_iterate (vbases, i, &base_binfo); i++) { offset = end_of_base (base_binfo); - if (INT_CST_LT_UNSIGNED (result, offset)) + if (tree_int_cst_lt (result, offset)) result = offset; } @@ -6012,7 +6013,7 @@ include_empty_classes (record_layout_info rli) CLASSTYPE_AS_BASE (rli->t) != NULL_TREE); rli_size = rli_size_unit_so_far (rli); if (TREE_CODE (rli_size) == INTEGER_CST - && INT_CST_LT_UNSIGNED (rli_size, eoc)) + && tree_int_cst_lt (rli_size, eoc)) { if (!abi_version_at_least (2)) /* In version 1 of the ABI, the size of a class that ends with @@ -6128,7 +6129,7 @@ layout_class_type (tree t, tree *virtuals_p) type, then there are some special rules for allocating it. */ if (DECL_C_BIT_FIELD (field) - && INT_CST_LT (TYPE_SIZE (type), DECL_SIZE (field))) + && tree_int_cst_lt (TYPE_SIZE (type), DECL_SIZE (field))) { unsigned int itk; tree integer_type; @@ -6139,10 +6140,10 @@ layout_class_type (tree t, tree *virtuals_p) bits as additional padding. */ for (itk = itk_char; itk != itk_none; ++itk) if (integer_types[itk] != NULL_TREE - && (INT_CST_LT (size_int (MAX_FIXED_MODE_SIZE), - TYPE_SIZE (integer_types[itk])) - || INT_CST_LT (DECL_SIZE (field), - TYPE_SIZE (integer_types[itk])))) + && (tree_int_cst_lt (size_int (MAX_FIXED_MODE_SIZE), + TYPE_SIZE (integer_types[itk])) + || tree_int_cst_lt (DECL_SIZE (field), + TYPE_SIZE (integer_types[itk])))) break; /* ITK now indicates a type that is too large for the @@ -6158,7 +6159,7 @@ layout_class_type (tree t, tree *virtuals_p) 3.2 always created a padding field, even if it had zero width. */ if (!abi_version_at_least (2) - || INT_CST_LT (TYPE_SIZE (integer_type), DECL_SIZE (field))) + || tree_int_cst_lt (TYPE_SIZE (integer_type), DECL_SIZE (field))) { if (abi_version_at_least (2) && TREE_CODE (t) == UNION_TYPE) /* In a union, the padding field must have the full width diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index e8ece0e..c833722 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "convert.h" #include "decl.h" #include "target.h" +#include "wide-int.h" static tree cp_convert_to_pointer (tree, tree, tsubst_flags_t); static tree convert_to_pointer_force (tree, tree, tsubst_flags_t); @@ -582,9 +583,7 @@ ignore_overflows (tree expr, tree orig) { gcc_assert (!TREE_OVERFLOW (orig)); /* Ensure constant sharing. */ - expr = build_int_cst_wide (TREE_TYPE (expr), - TREE_INT_CST_LOW (expr), - TREE_INT_CST_HIGH (expr)); + expr = wide_int_to_tree (TREE_TYPE (expr), expr); } return expr; } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ffaff5c..01a3625 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see #include "plugin.h" #include "cgraph.h" #include "cilk.h" +#include "wide-int.h" /* Possible cases of bad specifiers type used by bad_specifiers. */ enum bad_spec_place { @@ -4844,7 +4845,7 @@ check_array_designated_initializer (constructor_elt *ce, if (TREE_CODE (ce->index) == INTEGER_CST) { /* A C99 designator is OK if it matches the current index. */ - if (TREE_INT_CST_LOW (ce->index) == index) + if (wi::eq_p (ce->index, index)) return true; else sorry ("non-trivial designated initializers not supported"); @@ -8316,7 +8317,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) constant_expression_error (size); /* An array must have a positive number of elements. */ - if (INT_CST_LT (size, integer_zero_node)) + if (tree_int_cst_lt (size, integer_zero_node)) { if (!(complain & tf_error)) return error_mark_node; @@ -12677,9 +12678,9 @@ finish_enum_value_list (tree enumtype) enumeration. We must do this before the type of MINNODE and MAXNODE are transformed, since tree_int_cst_min_precision relies on the TREE_TYPE of the value it is passed. */ - bool unsignedp = tree_int_cst_sgn (minnode) >= 0; - int lowprec = tree_int_cst_min_precision (minnode, unsignedp); - int highprec = tree_int_cst_min_precision (maxnode, unsignedp); + signop sgn = tree_int_cst_sgn (minnode) >= 0 ? UNSIGNED : SIGNED; + int lowprec = tree_int_cst_min_precision (minnode, sgn); + int highprec = tree_int_cst_min_precision (maxnode, sgn); int precision = MAX (lowprec, highprec); unsigned int itk; bool use_short_enum; @@ -12711,7 +12712,7 @@ finish_enum_value_list (tree enumtype) underlying_type = integer_types[itk]; if (underlying_type != NULL_TREE && TYPE_PRECISION (underlying_type) >= precision - && TYPE_UNSIGNED (underlying_type) == unsignedp) + && TYPE_SIGN (underlying_type) == sgn) break; } if (itk == itk_none) @@ -12758,12 +12759,11 @@ finish_enum_value_list (tree enumtype) = build_distinct_type_copy (underlying_type); TYPE_PRECISION (ENUM_UNDERLYING_TYPE (enumtype)) = precision; set_min_and_max_values_for_integral_type - (ENUM_UNDERLYING_TYPE (enumtype), precision, unsignedp); + (ENUM_UNDERLYING_TYPE (enumtype), precision, sgn); /* If -fstrict-enums, still constrain TYPE_MIN/MAX_VALUE. */ if (flag_strict_enums) - set_min_and_max_values_for_integral_type (enumtype, precision, - unsignedp); + set_min_and_max_values_for_integral_type (enumtype, precision, sgn); } else underlying_type = ENUM_UNDERLYING_TYPE (enumtype); @@ -12887,14 +12887,14 @@ build_enumerator (tree name, tree value, tree enumtype, location_t loc) value = error_mark_node; else { - double_int di = TREE_INT_CST (prev_value) - .add_with_sign (double_int_one, - false, &overflowed); + tree type = TREE_TYPE (prev_value); + signop sgn = TYPE_SIGN (type); + widest_int wi = wi::add (wi::to_widest (prev_value), 1, sgn, + &overflowed); if (!overflowed) { - tree type = TREE_TYPE (prev_value); - bool pos = TYPE_UNSIGNED (type) || !di.is_negative (); - if (!double_int_fits_to_tree_p (type, di)) + bool pos = !wi::neg_p (wi, sgn); + if (!wi::fits_to_tree_p (wi, type)) { unsigned int itk; for (itk = itk_int; itk != itk_none; itk++) @@ -12902,7 +12902,7 @@ build_enumerator (tree name, tree value, tree enumtype, location_t loc) type = integer_types[itk]; if (type != NULL_TREE && (pos || !TYPE_UNSIGNED (type)) - && double_int_fits_to_tree_p (type, di)) + && wi::fits_to_tree_p (wi, type)) break; } if (type && cxx_dialect < cxx11 @@ -12914,7 +12914,7 @@ incremented enumerator value is too large for %<long%>"); if (type == NULL_TREE) overflowed = true; else - value = double_int_to_tree (type, di); + value = wide_int_to_tree (type, wi); } if (overflowed) diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 46422a5..6838d2a 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "target.h" #include "gimplify.h" +#include "wide-int.h" static bool begin_init_stmts (tree *, tree *); static tree finish_init_stmts (bool, tree, tree); @@ -2284,10 +2285,10 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, /* For arrays, a bounds checks on the NELTS parameter. */ tree outer_nelts_check = NULL_TREE; bool outer_nelts_from_type = false; - double_int inner_nelts_count = double_int_one; + offset_int inner_nelts_count = 1; tree alloc_call, alloc_expr; /* Size of the inner array elements. */ - double_int inner_size; + offset_int inner_size; /* The address returned by the call to "operator new". This node is a VAR_DECL and is therefore reusable. */ tree alloc_node; @@ -2343,9 +2344,8 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, if (TREE_CODE (inner_nelts_cst) == INTEGER_CST) { bool overflow; - double_int result = TREE_INT_CST (inner_nelts_cst) - .mul_with_sign (inner_nelts_count, - false, &overflow); + offset_int result = wi::mul (wi::to_offset (inner_nelts_cst), + inner_nelts_count, SIGNED, &overflow); if (overflow) { if (complain & tf_error) @@ -2456,42 +2456,40 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, { /* Maximum available size in bytes. Half of the address space minus the cookie size. */ - double_int max_size - = double_int_one.llshift (TYPE_PRECISION (sizetype) - 1, - HOST_BITS_PER_DOUBLE_INT); + offset_int max_size + = wi::set_bit_in_zero <offset_int> (TYPE_PRECISION (sizetype) - 1); /* Maximum number of outer elements which can be allocated. */ - double_int max_outer_nelts; + offset_int max_outer_nelts; tree max_outer_nelts_tree; gcc_assert (TREE_CODE (size) == INTEGER_CST); cookie_size = targetm.cxx.get_cookie_size (elt_type); gcc_assert (TREE_CODE (cookie_size) == INTEGER_CST); - gcc_checking_assert (TREE_INT_CST (cookie_size).ult (max_size)); + gcc_checking_assert (wi::ltu_p (wi::to_offset (cookie_size), max_size)); /* Unconditionally subtract the cookie size. This decreases the maximum object size and is safe even if we choose not to use a cookie after all. */ - max_size -= TREE_INT_CST (cookie_size); + max_size -= wi::to_offset (cookie_size); bool overflow; - inner_size = TREE_INT_CST (size) - .mul_with_sign (inner_nelts_count, false, &overflow); - if (overflow || inner_size.ugt (max_size)) + inner_size = wi::mul (wi::to_offset (size), inner_nelts_count, SIGNED, + &overflow); + if (overflow || wi::gtu_p (inner_size, max_size)) { if (complain & tf_error) error ("size of array is too large"); return error_mark_node; } - max_outer_nelts = max_size.udiv (inner_size, TRUNC_DIV_EXPR); + + max_outer_nelts = wi::udiv_trunc (max_size, inner_size); /* Only keep the top-most seven bits, to simplify encoding the constant in the instruction stream. */ { - unsigned shift = HOST_BITS_PER_DOUBLE_INT - 7 - - (max_outer_nelts.high ? clz_hwi (max_outer_nelts.high) - : (HOST_BITS_PER_WIDE_INT + clz_hwi (max_outer_nelts.low))); - max_outer_nelts - = max_outer_nelts.lrshift (shift, HOST_BITS_PER_DOUBLE_INT) - .llshift (shift, HOST_BITS_PER_DOUBLE_INT); + unsigned shift = (max_outer_nelts.get_precision ()) - 7 + - wi::clz (max_outer_nelts); + max_outer_nelts = wi::lshift (wi::lrshift (max_outer_nelts, shift), + shift); } - max_outer_nelts_tree = double_int_to_tree (sizetype, max_outer_nelts); + max_outer_nelts_tree = wide_int_to_tree (sizetype, max_outer_nelts); size = size_binop (MULT_EXPR, size, convert (sizetype, nelts)); outer_nelts_check = fold_build2 (LE_EXPR, boolean_type_node, @@ -2572,7 +2570,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, cookie_size = NULL_TREE; /* No size arithmetic necessary, so the size check is not needed. */ - if (outer_nelts_check != NULL && inner_size.is_one ()) + if (outer_nelts_check != NULL && inner_size == 1) outer_nelts_check = NULL_TREE; } /* Perform the overflow check. */ @@ -2617,7 +2615,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, cookie_size = NULL_TREE; /* No size arithmetic necessary, so the size check is not needed. */ - if (outer_nelts_check != NULL && inner_size.is_one ()) + if (outer_nelts_check != NULL && inner_size == 1) outer_nelts_check = NULL_TREE; } diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 84d10a0..97fb4c6 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "target.h" #include "cgraph.h" +#include "wide-int.h" /* Debugging support. */ @@ -1513,8 +1514,8 @@ static inline void write_integer_cst (const tree cst) { int sign = tree_int_cst_sgn (cst); - - if (TREE_INT_CST_HIGH (cst) + (sign < 0)) + widest_int abs_value = wi::abs (wi::to_widest (cst)); + if (!wi::fits_uhwi_p (abs_value)) { /* A bignum. We do this in chunks, each of which fits in a HOST_WIDE_INT. */ @@ -1540,8 +1541,7 @@ write_integer_cst (const tree cst) type = c_common_signed_or_unsigned_type (1, TREE_TYPE (cst)); base = build_int_cstu (type, chunk); - n = build_int_cst_wide (type, - TREE_INT_CST_LOW (cst), TREE_INT_CST_HIGH (cst)); + n = wide_int_to_tree (type, cst); if (sign < 0) { @@ -1568,14 +1568,9 @@ write_integer_cst (const tree cst) else { /* A small num. */ - unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (cst); - if (sign < 0) - { - write_char ('n'); - low = -low; - } - write_unsigned_number (low); + write_char ('n'); + write_unsigned_number (abs_value.to_uhwi ()); } } @@ -3226,12 +3221,12 @@ write_array_type (const tree type) { /* The ABI specifies that we should mangle the number of elements in the array, not the largest allowed index. */ - double_int dmax = tree_to_double_int (max) + double_int_one; + offset_int wmax = wi::to_offset (max) + 1; /* Truncate the result - this will mangle [0, SIZE_INT_MAX] number of elements as zero. */ - dmax = dmax.zext (TYPE_PRECISION (TREE_TYPE (max))); - gcc_assert (dmax.fits_uhwi ()); - write_unsigned_number (dmax.low); + wmax = wi::zext (wmax, TYPE_PRECISION (TREE_TYPE (max))); + gcc_assert (wi::fits_uhwi_p (wmax)); + write_unsigned_number (wmax.to_uhwi ()); } else { diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 4b39b90..e140024 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "hash-table.h" #include "gimple-expr.h" #include "gimplify.h" +#include "wide-int.h" static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); @@ -2620,8 +2621,7 @@ cp_tree_equal (tree t1, tree t2) switch (code1) { case INTEGER_CST: - return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2) - && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2); + return tree_int_cst_equal (t1, t2); case REAL_CST: return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2)); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 044d971..1d8b782 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see #include "cp-tree.h" #include "flags.h" #include "diagnostic-core.h" +#include "wide-int.h" static tree process_init_constructor (tree type, tree init, tsubst_flags_t complain); @@ -1165,12 +1166,10 @@ process_init_constructor_array (tree type, tree init, { tree domain = TYPE_DOMAIN (type); if (domain && TREE_CONSTANT (TYPE_MAX_VALUE (domain))) - len = (tree_to_double_int (TYPE_MAX_VALUE (domain)) - - tree_to_double_int (TYPE_MIN_VALUE (domain)) - + double_int_one) - .ext (TYPE_PRECISION (TREE_TYPE (domain)), - TYPE_UNSIGNED (TREE_TYPE (domain))) - .low; + len = wi::ext (wi::to_offset (TYPE_MAX_VALUE (domain)) + - wi::to_offset (TYPE_MIN_VALUE (domain)) + 1, + TYPE_PRECISION (TREE_TYPE (domain)), + TYPE_SIGN (TREE_TYPE (domain))).to_uhwi (); else unbounded = true; /* Take as many as there are. */ } |