mirror of
https://gcc.gnu.org/git/gcc.git
synced 2025-01-24 13:24:33 +08:00
stor-layout.c (initialize_sizetypes): Initialize all sizetypes based on target definitions.
2011-06-07 Richard Guenther <rguenther@suse.de> * stor-layout.c (initialize_sizetypes): Initialize all sizetypes based on target definitions. (set_sizetype): Remove. * tree.c (build_common_tree_nodes): Do not call set_sizetype. * tree.h (set_sizetype): Remove. From-SVN: r174748
This commit is contained in:
parent
c3c79fc5a5
commit
67b884536d
@ -1,3 +1,11 @@
|
|||||||
|
2011-06-07 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
|
* stor-layout.c (initialize_sizetypes): Initialize all
|
||||||
|
sizetypes based on target definitions.
|
||||||
|
(set_sizetype): Remove.
|
||||||
|
* tree.c (build_common_tree_nodes): Do not call set_sizetype.
|
||||||
|
* tree.h (set_sizetype): Remove.
|
||||||
|
|
||||||
2011-06-07 Nick Clifton <nickc@redhat.com>
|
2011-06-07 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* config.gcc: Unify V850 architecture options and add support for
|
* config.gcc: Unify V850 architecture options and add support for
|
||||||
|
@ -2189,93 +2189,69 @@ make_accum_type (int precision, int unsignedp, int satp)
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize sizetype and bitsizetype to a reasonable and temporary
|
/* Initialize sizetypes so layout_type can use them. */
|
||||||
value to enable integer types to be created. */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
initialize_sizetypes (void)
|
initialize_sizetypes (void)
|
||||||
{
|
{
|
||||||
tree t = make_node (INTEGER_TYPE);
|
int precision, bprecision;
|
||||||
int precision = GET_MODE_BITSIZE (SImode);
|
|
||||||
|
|
||||||
SET_TYPE_MODE (t, SImode);
|
/* Get sizetypes precision from the SIZE_TYPE target macro. */
|
||||||
TYPE_ALIGN (t) = GET_MODE_ALIGNMENT (SImode);
|
if (strcmp (SIZE_TYPE, "unsigned int") == 0)
|
||||||
TYPE_IS_SIZETYPE (t) = 1;
|
precision = INT_TYPE_SIZE;
|
||||||
TYPE_UNSIGNED (t) = 1;
|
else if (strcmp (SIZE_TYPE, "long unsigned int") == 0)
|
||||||
TYPE_SIZE (t) = build_int_cst (t, precision);
|
precision = LONG_TYPE_SIZE;
|
||||||
TYPE_SIZE_UNIT (t) = build_int_cst (t, GET_MODE_SIZE (SImode));
|
else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0)
|
||||||
TYPE_PRECISION (t) = precision;
|
precision = LONG_LONG_TYPE_SIZE;
|
||||||
|
else
|
||||||
|
gcc_unreachable ();
|
||||||
|
|
||||||
set_min_and_max_values_for_integral_type (t, precision,
|
bprecision
|
||||||
|
= MIN (precision + BITS_PER_UNIT_LOG + 1, MAX_FIXED_MODE_SIZE);
|
||||||
|
bprecision
|
||||||
|
= GET_MODE_PRECISION (smallest_mode_for_size (bprecision, MODE_INT));
|
||||||
|
if (bprecision > HOST_BITS_PER_WIDE_INT * 2)
|
||||||
|
bprecision = HOST_BITS_PER_WIDE_INT * 2;
|
||||||
|
|
||||||
|
/* Create stubs for sizetype and bitsizetype so we can create constants. */
|
||||||
|
sizetype = make_node (INTEGER_TYPE);
|
||||||
|
/* ??? We can't set a name for sizetype because it appears in C diagnostics
|
||||||
|
and pp_c_type_specifier doesn't deal with IDENTIFIER_NODE TYPE_NAMEs. */
|
||||||
|
TYPE_PRECISION (sizetype) = precision;
|
||||||
|
TYPE_UNSIGNED (sizetype) = 1;
|
||||||
|
TYPE_IS_SIZETYPE (sizetype) = 1;
|
||||||
|
bitsizetype = make_node (INTEGER_TYPE);
|
||||||
|
TYPE_NAME (bitsizetype) = get_identifier ("bitsizetype");
|
||||||
|
TYPE_PRECISION (bitsizetype) = bprecision;
|
||||||
|
TYPE_UNSIGNED (bitsizetype) = 1;
|
||||||
|
TYPE_IS_SIZETYPE (bitsizetype) = 1;
|
||||||
|
|
||||||
|
/* Now layout both types manually. */
|
||||||
|
SET_TYPE_MODE (sizetype, smallest_mode_for_size (precision, MODE_INT));
|
||||||
|
TYPE_ALIGN (sizetype) = GET_MODE_ALIGNMENT (TYPE_MODE (sizetype));
|
||||||
|
TYPE_SIZE (sizetype) = bitsize_int (precision);
|
||||||
|
TYPE_SIZE_UNIT (sizetype) = size_int (GET_MODE_SIZE (TYPE_MODE (sizetype)));
|
||||||
|
set_min_and_max_values_for_integral_type (sizetype, precision,
|
||||||
/*is_unsigned=*/true);
|
/*is_unsigned=*/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 and (b) any INTEGER_CSTs created with such a type,
|
|
||||||
remain valid. */
|
|
||||||
|
|
||||||
void
|
|
||||||
set_sizetype (tree type)
|
|
||||||
{
|
|
||||||
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
|
|
||||||
cross-compiling from a 32 bit to a 64 bit host, we are limited to 64 bit
|
|
||||||
precision. */
|
|
||||||
int precision
|
|
||||||
= MIN (oprecision + BITS_PER_UNIT_LOG + 1, MAX_FIXED_MODE_SIZE);
|
|
||||||
precision
|
|
||||||
= GET_MODE_PRECISION (smallest_mode_for_size (precision, MODE_INT));
|
|
||||||
if (precision > HOST_BITS_PER_WIDE_INT * 2)
|
|
||||||
precision = HOST_BITS_PER_WIDE_INT * 2;
|
|
||||||
|
|
||||||
/* sizetype must be an unsigned type. */
|
|
||||||
gcc_assert (TYPE_UNSIGNED (type));
|
|
||||||
|
|
||||||
t = build_distinct_type_copy (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);
|
|
||||||
TYPE_UID (t) = TYPE_UID (sizetype);
|
|
||||||
TYPE_IS_SIZETYPE (t) = 1;
|
|
||||||
|
|
||||||
/* Replace our original stub sizetype. */
|
|
||||||
memcpy (sizetype, t, tree_size (sizetype));
|
|
||||||
TYPE_MAIN_VARIANT (sizetype) = sizetype;
|
|
||||||
TYPE_CANONICAL (sizetype) = sizetype;
|
|
||||||
|
|
||||||
/* sizetype is unsigned but we need to fix TYPE_MAX_VALUE so that it is
|
/* 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. */
|
sign-extended in a way consistent with force_fit_type. */
|
||||||
max = TYPE_MAX_VALUE (sizetype);
|
|
||||||
TYPE_MAX_VALUE (sizetype)
|
TYPE_MAX_VALUE (sizetype)
|
||||||
= double_int_to_tree (sizetype, tree_to_double_int (max));
|
= double_int_to_tree (sizetype,
|
||||||
|
tree_to_double_int (TYPE_MAX_VALUE (sizetype)));
|
||||||
|
|
||||||
t = make_node (INTEGER_TYPE);
|
SET_TYPE_MODE (bitsizetype, smallest_mode_for_size (bprecision, MODE_INT));
|
||||||
TYPE_NAME (t) = get_identifier ("bit_size_type");
|
TYPE_ALIGN (bitsizetype) = GET_MODE_ALIGNMENT (TYPE_MODE (bitsizetype));
|
||||||
/* We want to use bitsizetype's cache, as we will be replacing that type. */
|
TYPE_SIZE (bitsizetype) = bitsize_int (bprecision);
|
||||||
TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (bitsizetype);
|
TYPE_SIZE_UNIT (bitsizetype)
|
||||||
TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (bitsizetype);
|
= size_int (GET_MODE_SIZE (TYPE_MODE (bitsizetype)));
|
||||||
TYPE_PRECISION (t) = precision;
|
set_min_and_max_values_for_integral_type (bitsizetype, bprecision,
|
||||||
TYPE_UID (t) = TYPE_UID (bitsizetype);
|
/*is_unsigned=*/true);
|
||||||
TYPE_IS_SIZETYPE (t) = 1;
|
/* ??? TYPE_MAX_VALUE is not properly sign-extended. */
|
||||||
|
|
||||||
/* Replace our original stub bitsizetype. */
|
|
||||||
memcpy (bitsizetype, t, tree_size (bitsizetype));
|
|
||||||
TYPE_MAIN_VARIANT (bitsizetype) = bitsizetype;
|
|
||||||
TYPE_CANONICAL (bitsizetype) = bitsizetype;
|
|
||||||
|
|
||||||
fixup_unsigned_type (bitsizetype);
|
|
||||||
|
|
||||||
/* Create the signed variants of *sizetype. */
|
/* Create the signed variants of *sizetype. */
|
||||||
ssizetype = make_signed_type (oprecision);
|
ssizetype = make_signed_type (TYPE_PRECISION (sizetype));
|
||||||
TYPE_IS_SIZETYPE (ssizetype) = 1;
|
TYPE_IS_SIZETYPE (ssizetype) = 1;
|
||||||
sbitsizetype = make_signed_type (precision);
|
sbitsizetype = make_signed_type (TYPE_PRECISION (bitsizetype));
|
||||||
TYPE_IS_SIZETYPE (sbitsizetype) = 1;
|
TYPE_IS_SIZETYPE (sbitsizetype) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9098,8 +9098,7 @@ make_or_reuse_accum_type (unsigned size, int unsignedp, int satp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create nodes for all integer types (and error_mark_node) using the sizes
|
/* Create nodes for all integer types (and error_mark_node) using the sizes
|
||||||
of C datatypes. The caller should call set_sizetype soon after calling
|
of C datatypes. */
|
||||||
this function to select one of the types as sizetype. */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
build_common_tree_nodes (bool signed_char)
|
build_common_tree_nodes (bool signed_char)
|
||||||
@ -9161,7 +9160,6 @@ build_common_tree_nodes (bool signed_char)
|
|||||||
size_type_node = long_long_unsigned_type_node;
|
size_type_node = long_long_unsigned_type_node;
|
||||||
else
|
else
|
||||||
gcc_unreachable ();
|
gcc_unreachable ();
|
||||||
set_sizetype (size_type_node);
|
|
||||||
|
|
||||||
/* Fill in the rest of the sized types. Reuse existing type nodes
|
/* Fill in the rest of the sized types. Reuse existing type nodes
|
||||||
when possible. */
|
when possible. */
|
||||||
@ -9182,7 +9180,7 @@ build_common_tree_nodes (bool signed_char)
|
|||||||
access_private_node = get_identifier ("private");
|
access_private_node = get_identifier ("private");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call this function after calling build_common_tree_nodes and set_sizetype.
|
/* Call this function after calling build_common_tree_nodes.
|
||||||
It will create several other common tree nodes. */
|
It will create several other common tree nodes. */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -4291,7 +4291,6 @@ extern tree signed_or_unsigned_type_for (int, tree);
|
|||||||
extern tree signed_type_for (tree);
|
extern tree signed_type_for (tree);
|
||||||
extern tree unsigned_type_for (tree);
|
extern tree unsigned_type_for (tree);
|
||||||
extern void initialize_sizetypes (void);
|
extern void initialize_sizetypes (void);
|
||||||
extern void set_sizetype (tree);
|
|
||||||
extern void fixup_unsigned_type (tree);
|
extern void fixup_unsigned_type (tree);
|
||||||
extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool);
|
extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool);
|
||||||
extern tree build_pointer_type (tree);
|
extern tree build_pointer_type (tree);
|
||||||
|
Loading…
Reference in New Issue
Block a user