aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2010-04-18 21:49:29 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2010-04-18 21:49:29 +0000
commit3b9e5d953c6c8f977035b600242efb26084d25be (patch)
treeabb5e5a28274a29b2192f0299a551011760fbf42 /gcc/stor-layout.c
parentb3c359652e9323f202e530d5948185504b2b4882 (diff)
downloadgcc-3b9e5d953c6c8f977035b600242efb26084d25be.zip
gcc-3b9e5d953c6c8f977035b600242efb26084d25be.tar.gz
gcc-3b9e5d953c6c8f977035b600242efb26084d25be.tar.bz2
fold-const.c (fold_comparison): Use ssizetype.
2010-04-18  Eric Botcazou  <ebotcazou@adacore.com> * fold-const.c (fold_comparison): Use ssizetype. * gimple-fold.c (maybe_fold_offset_to_array_ref): Likewise. * ipa-prop.c (ipa_modify_call_arguments): Use sizetype. * tree-loop-distribution.c (build_size_arg_loc): Likewise. * tree-object-size.c (compute_object_sizes): Use size_type_node. * tree.h (initialize_sizetypes): Remove parameter. (build_common_tree_nodes): Remove second parameter. * stor-layout.c (initialize_sizetypes): Remove parameter. Always create an unsigned type. (set_sizetype): Assert that the passed type is unsigned and simplify. * tree.c (build_common_tree_nodes): Remove second parameter. Adjust call to initialize_sizetypes. * c-decl.c (c_init_decl_processing): Remove second argument in call to build_common_tree_nodes. cp/ * decl.c (cxx_init_decl_processing): Remove second argument in call to build_common_tree_nodes. java/ * decl.c (java_init_decl_processing): Remove argument in call to initialize_sizetypes fortran/ * f95-lang.c (gfc_init_decl_processing): Remove second argument in call to build_common_tree_nodes. ada/ * gcc-interface/misc.c (gnat_init): Remove second argument in call to build_common_tree_nodes. lto/ * lto-lang.c (lto_init): Remove second argument in call to build_common_tree_nodes. From-SVN: r158496
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c72
1 files changed, 27 insertions, 45 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 46ac333..151092c 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -2214,37 +2214,35 @@ make_accum_type (int precision, int unsignedp, int satp)
value to enable integer types to be created. */
void
-initialize_sizetypes (bool signed_p)
+initialize_sizetypes (void)
{
tree t = make_node (INTEGER_TYPE);
int precision = GET_MODE_BITSIZE (SImode);
SET_TYPE_MODE (t, SImode);
TYPE_ALIGN (t) = GET_MODE_ALIGNMENT (SImode);
- TYPE_USER_ALIGN (t) = 0;
TYPE_IS_SIZETYPE (t) = 1;
- TYPE_UNSIGNED (t) = !signed_p;
+ TYPE_UNSIGNED (t) = 1;
TYPE_SIZE (t) = build_int_cst (t, precision);
TYPE_SIZE_UNIT (t) = build_int_cst (t, GET_MODE_SIZE (SImode));
TYPE_PRECISION (t) = precision;
- /* Set TYPE_MIN_VALUE and TYPE_MAX_VALUE. */
- set_min_and_max_values_for_integral_type (t, precision, !signed_p);
+ set_min_and_max_values_for_integral_type (t, precision, true);
sizetype = t;
bitsizetype = build_distinct_type_copy (t);
}
-/* Make sizetype a version of TYPE, and initialize *sizetype
- accordingly. We do this by overwriting the stub sizetype and
- bitsizetype nodes created by initialize_sizetypes. This makes sure
- that (a) anything stubby about them no longer exists, (b) any
- INTEGER_CSTs created with such a type, remain valid. */
+/* Make sizetype a version of TYPE, and initialize *sizetype accordingly.
+ We do this by overwriting the stub sizetype and bitsizetype nodes created
+ by initialize_sizetypes. This makes sure that (a) anything stubby about
+ them no longer exists and (b) any INTEGER_CSTs created with such a type,
+ remain valid. */
void
set_sizetype (tree type)
{
- tree t;
+ tree t, max;
int oprecision = TYPE_PRECISION (type);
/* The *bitsizetype types use a precision that avoids overflows when
calculating signed sizes / offsets in bits. However, when
@@ -2257,11 +2255,11 @@ set_sizetype (tree type)
if (precision > HOST_BITS_PER_WIDE_INT * 2)
precision = HOST_BITS_PER_WIDE_INT * 2;
- gcc_assert (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));
+ /* sizetype must be an unsigned type. */
+ gcc_assert (TYPE_UNSIGNED (type));
t = build_distinct_type_copy (type);
- /* We do want to use sizetype's cache, as we will be replacing that
- type. */
+ /* We want to use sizetype's cache, as we will be replacing that type. */
TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (sizetype);
TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (sizetype);
TREE_TYPE (TYPE_CACHED_VALUES (t)) = type;
@@ -2273,10 +2271,17 @@ set_sizetype (tree type)
TYPE_MAIN_VARIANT (sizetype) = sizetype;
TYPE_CANONICAL (sizetype) = sizetype;
+ /* sizetype is unsigned but we need to fix TYPE_MAX_VALUE so that it is
+ sign-extended in a way consistent with force_fit_type. */
+ max = TYPE_MAX_VALUE (sizetype);
+ TYPE_MAX_VALUE (sizetype)
+ = build_int_cst_wide_type (sizetype,
+ TREE_INT_CST_LOW (max),
+ TREE_INT_CST_HIGH (max));
+
t = make_node (INTEGER_TYPE);
TYPE_NAME (t) = get_identifier ("bit_size_type");
- /* We do want to use bitsizetype's cache, as we will be replacing that
- type. */
+ /* We want to use bitsizetype's cache, as we will be replacing that type. */
TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (bitsizetype);
TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (bitsizetype);
TYPE_PRECISION (t) = precision;
@@ -2288,36 +2293,13 @@ set_sizetype (tree type)
TYPE_MAIN_VARIANT (bitsizetype) = bitsizetype;
TYPE_CANONICAL (bitsizetype) = bitsizetype;
- if (TYPE_UNSIGNED (type))
- {
- fixup_unsigned_type (bitsizetype);
- ssizetype = make_signed_type (oprecision);
- TYPE_IS_SIZETYPE (ssizetype) = 1;
- sbitsizetype = make_signed_type (precision);
- TYPE_IS_SIZETYPE (sbitsizetype) = 1;
- }
- else
- {
- fixup_signed_type (bitsizetype);
- ssizetype = sizetype;
- sbitsizetype = bitsizetype;
- }
-
- /* If SIZETYPE is unsigned, we need to fix TYPE_MAX_VALUE so that
- it is sign extended in a way consistent with force_fit_type. */
- if (TYPE_UNSIGNED (type))
- {
- tree orig_max, new_max;
+ fixup_unsigned_type (bitsizetype);
- orig_max = TYPE_MAX_VALUE (sizetype);
-
- /* Build a new node with the same values, but a different type.
- Sign extend it to ensure consistency. */
- new_max = build_int_cst_wide_type (sizetype,
- TREE_INT_CST_LOW (orig_max),
- TREE_INT_CST_HIGH (orig_max));
- TYPE_MAX_VALUE (sizetype) = new_max;
- }
+ /* Create the signed variants of *sizetype. */
+ ssizetype = make_signed_type (oprecision);
+ TYPE_IS_SIZETYPE (ssizetype) = 1;
+ sbitsizetype = make_signed_type (precision);
+ TYPE_IS_SIZETYPE (sbitsizetype) = 1;
}
/* TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE