tree.h (build_int_cst_wide_type): Export.

2007-01-08  Richard Guenther  <rguenther@suse.de>

	* tree.h (build_int_cst_wide_type): Export.
	* tree.c (build_int_cst_wide_type): New function.
	(build_int_cst_wide): Fix comment.
	* builtins.c (fold_builtin_object_size): Use build_int_cst
	to build -1 or 0 of the correct type.  Use fit_double_type
	to check for overflow.
	* fold-const.c (optimize_bit_field_compare): Use build_int_cst_type
	to build the mask.
	(decode_field_reference): Likewise.
	(all_ones_mask_p): Likewise.
	(native_interpret_int): Use build_int_cst_wide_type.
	(fold_binary): Use build_int_cst_type to build an all-ones
	value.
	* stor-layout.c (set_sizetype): Use build_int_cst_wide_type.

	java/
	* lex.c (do_java_lex): Use build_int_cst_wide_type.
	* jcf-parse.c (get_constant): Likewise.

	cp/
	* cvt.c (cp_convert_to_pointer): Use build_int_cst_type.

	ada/
	* cuintp.c (build_cst_from_int): Use built_int_cst_type.
	* trans.c (gnat_to_gnu): Likewise.

From-SVN: r120596
This commit is contained in:
Richard Guenther 2007-01-08 22:53:20 +00:00 committed by Richard Biener
parent 1c61ff2946
commit 2ac7cbb532
14 changed files with 75 additions and 53 deletions

View File

@ -1,3 +1,20 @@
2007-01-08 Richard Guenther <rguenther@suse.de>
* tree.h (build_int_cst_wide_type): Export.
* tree.c (build_int_cst_wide_type): New function.
(build_int_cst_wide): Fix comment.
* builtins.c (fold_builtin_object_size): Use build_int_cst
to build -1 or 0 of the correct type. Use fit_double_type
to check for overflow.
* fold-const.c (optimize_bit_field_compare): Use build_int_cst_type
to build the mask.
(decode_field_reference): Likewise.
(all_ones_mask_p): Likewise.
(native_interpret_int): Use build_int_cst_wide_type.
(fold_binary): Use build_int_cst_type to build an all-ones
value.
* stor-layout.c (set_sizetype): Use build_int_cst_wide_type.
2007-01-08 Daniel Jacobowitz <dan@codesourcery.com>
* config/pa/t-pa64 (libgcc_stub.a): Use $(T).

View File

@ -1,3 +1,8 @@
2007-01-08 Richard Guenther <rguenther@suse.de>
* cuintp.c (build_cst_from_int): Use built_int_cst_type.
* trans.c (gnat_to_gnu): Likewise.
2006-12-07 Geoffrey Keating <geoffk@apple.com>
* Makefile.in: Replace CROSS_COMPILE with CROSS_DIRECTORY_STRUCTURE.

View File

@ -62,7 +62,7 @@ build_cst_from_int (tree type, HOST_WIDE_INT low)
if (TREE_CODE (type) == REAL_TYPE)
return convert (type, build_int_cst (NULL_TREE, low));
else
return force_fit_type (build_int_cst (type, low), false, false, false);
return build_int_cst_type (type, low);
}
/* Similar to UI_To_Int, but return a GCC INTEGER_CST or REAL_CST node,

View File

@ -2729,10 +2729,8 @@ gnat_to_gnu (Node_Id gnat_node)
gnu_result = DECL_INITIAL (get_gnu_tree (Entity (gnat_node)));
else
gnu_result
= force_fit_type
(build_int_cst
(gnu_result_type, UI_To_CC (Char_Literal_Value (gnat_node))),
false, false, false);
= build_int_cst_type
(gnu_result_type, UI_To_CC (Char_Literal_Value (gnat_node)));
break;
case N_Real_Literal:

View File

@ -10808,13 +10808,11 @@ fold_builtin_object_size (tree arglist)
if there are any side-effects, it returns (size_t) -1 for types 0 and 1
and (size_t) 0 for types 2 and 3. */
if (TREE_SIDE_EFFECTS (ptr))
return fold_convert (size_type_node,
object_size_type < 2
? integer_minus_one_node : integer_zero_node);
return build_int_cst_type (size_type_node, object_size_type < 2 ? -1 : 0);
if (TREE_CODE (ptr) == ADDR_EXPR)
ret = build_int_cstu (size_type_node,
compute_builtin_object_size (ptr, object_size_type));
compute_builtin_object_size (ptr, object_size_type));
else if (TREE_CODE (ptr) == SSA_NAME)
{
@ -10831,9 +10829,10 @@ fold_builtin_object_size (tree arglist)
if (ret)
{
ret = force_fit_type (ret, -1, false, false);
if (TREE_CONSTANT_OVERFLOW (ret))
ret = 0;
unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (ret);
HOST_WIDE_INT high = TREE_INT_CST_HIGH (ret);
if (fit_double_type (low, high, &low, &high, TREE_TYPE (ret)))
ret = NULL_TREE;
}
return ret;

View File

@ -1,3 +1,7 @@
2007-01-08 Richard Guenther <rguenther@suse.de>
* cvt.c (cp_convert_to_pointer): Use build_int_cst_type.
2007-01-08 Mark Shinwell <shinwell@codesourcery.com>
* call.c (standard_conversion): Pass flag to

View File

@ -251,9 +251,7 @@ cp_convert_to_pointer (tree type, tree expr, bool force)
{
/* A NULL pointer-to-member is represented by -1, not by
zero. */
expr = build_int_cst (type, -1);
/* Fix up the representation of -1 if appropriate. */
expr = force_fit_type (expr, 0, false, false);
expr = build_int_cst_type (type, -1);
}
else
expr = build_int_cst (type, 0);

View File

@ -3478,9 +3478,7 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type,
lbitpos = nbitsize - lbitsize - lbitpos;
/* Make the mask to be used against the extracted field. */
mask = build_int_cst (unsigned_type, -1);
mask = force_fit_type (mask, 0, false, false);
mask = fold_convert (unsigned_type, mask);
mask = build_int_cst_type (unsigned_type, -1);
mask = const_binop (LSHIFT_EXPR, mask, size_int (nbitsize - lbitsize), 0);
mask = const_binop (RSHIFT_EXPR, mask,
size_int (nbitsize - lbitsize - lbitpos), 0);
@ -3638,8 +3636,7 @@ decode_field_reference (tree exp, HOST_WIDE_INT *pbitsize,
unsigned_type = lang_hooks.types.type_for_size (*pbitsize, 1);
precision = TYPE_PRECISION (unsigned_type);
mask = build_int_cst (unsigned_type, -1);
mask = force_fit_type (mask, 0, false, false);
mask = build_int_cst_type (unsigned_type, -1);
mask = const_binop (LSHIFT_EXPR, mask, size_int (precision - *pbitsize), 0);
mask = const_binop (RSHIFT_EXPR, mask, size_int (precision - *pbitsize), 0);
@ -3664,8 +3661,7 @@ all_ones_mask_p (tree mask, int size)
unsigned int precision = TYPE_PRECISION (type);
tree tmask;
tmask = build_int_cst (lang_hooks.types.signed_type (type), -1);
tmask = force_fit_type (tmask, 0, false, false);
tmask = build_int_cst_type (lang_hooks.types.signed_type (type), -1);
return
tree_int_cst_equal (mask,
@ -7113,8 +7109,7 @@ native_interpret_int (tree type, unsigned char *ptr, int len)
<< (bitpos - HOST_BITS_PER_WIDE_INT);
}
return force_fit_type (build_int_cst_wide (type, lo, hi),
0, false, false);
return build_int_cst_wide_type (type, lo, hi);
}
@ -8802,8 +8797,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)
&& !TYPE_TRAP_SIGNED (type))
{
t1 = build_int_cst (type, -1);
t1 = force_fit_type (t1, 0, false, false);
t1 = build_int_cst_type (type, -1);
return omit_one_operand (type, t1, arg1);
}
@ -8812,8 +8806,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
&& operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)
&& !TYPE_TRAP_SIGNED (type))
{
t1 = build_int_cst (type, -1);
t1 = force_fit_type (t1, 0, false, false);
t1 = build_int_cst_type (type, -1);
return omit_one_operand (type, t1, arg0);
}
@ -9601,8 +9594,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
{
t1 = build_int_cst (type, -1);
t1 = force_fit_type (t1, 0, false, false);
t1 = build_int_cst_type (type, -1);
return omit_one_operand (type, t1, arg1);
}
@ -9610,8 +9602,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
if (TREE_CODE (arg1) == BIT_NOT_EXPR
&& operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
{
t1 = build_int_cst (type, -1);
t1 = force_fit_type (t1, 0, false, false);
t1 = build_int_cst_type (type, -1);
return omit_one_operand (type, t1, arg0);
}
@ -9717,8 +9708,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
{
t1 = build_int_cst (type, -1);
t1 = force_fit_type (t1, 0, false, false);
t1 = build_int_cst_type (type, -1);
return omit_one_operand (type, t1, arg1);
}
@ -9726,8 +9716,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
if (TREE_CODE (arg1) == BIT_NOT_EXPR
&& operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
{
t1 = build_int_cst (type, -1);
t1 = force_fit_type (t1, 0, false, false);
t1 = build_int_cst_type (type, -1);
return omit_one_operand (type, t1, arg0);
}

View File

@ -1,3 +1,8 @@
2007-01-08 Richard Guenther <rguenther@suse.de>
* lex.c (do_java_lex): Use build_int_cst_wide_type.
* jcf-parse.c (get_constant): Likewise.
2006-11-12 Jan Hubicka <jh@suse.cz>
* resource.c (compile_resource_data): Update for new varpool names.

View File

@ -320,8 +320,7 @@ get_constant (JCF *jcf, int index)
lshift_double (num, 0, 32, 64, &lo, &hi, 0);
num = JPOOL_UINT (jcf, index+1);
add_double (lo, hi, num, 0, &lo, &hi);
value = build_int_cst_wide (long_type_node, lo, hi);
value = force_fit_type (value, 0, false, false);
value = build_int_cst_wide_type (long_type_node, lo, hi);
break;
}

View File

@ -1234,9 +1234,8 @@ do_java_lex (YYSTYPE *java_lval)
}
/* Sign extend the value. */
value = build_int_cst_wide (long_suffix ? long_type_node : int_type_node,
low, high);
value = force_fit_type (value, 0, false, false);
value = build_int_cst_wide_type (long_suffix ? long_type_node
: int_type_node, low, high);
if (radix != 10)
{

View File

@ -2003,14 +2003,11 @@ set_sizetype (tree type)
orig_max = TYPE_MAX_VALUE (sizetype);
/* Build a new node with the same values, but a different type. */
new_max = build_int_cst_wide (sizetype,
TREE_INT_CST_LOW (orig_max),
TREE_INT_CST_HIGH (orig_max));
/* Now sign extend it using force_fit_type to ensure
consistency. */
new_max = force_fit_type (new_max, 0, 0, 0);
/* 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;
}
}

View File

@ -789,6 +789,17 @@ build_int_cst_type (tree type, HOST_WIDE_INT low)
return build_int_cst_wide (type, low1, hi);
}
/* Create an INT_CST node of TYPE and value HI:LOW. The value is truncated
and sign extended according to the value range of TYPE. */
tree
build_int_cst_wide_type (tree type,
unsigned HOST_WIDE_INT low, HOST_WIDE_INT high)
{
fit_double_type (low, high, &low, &high, type);
return build_int_cst_wide (type, low, high);
}
/* These are the hash table functions for the hash table of INTEGER_CST
nodes of a sizetype. */
@ -817,10 +828,9 @@ int_cst_hash_eq (const void *x, const void *y)
&& TREE_INT_CST_LOW (xt) == TREE_INT_CST_LOW (yt));
}
/* Create an INT_CST node of TYPE and value HI:LOW. If TYPE is NULL,
integer_type_node is used. The returned node is always shared.
For small integers we use a per-type vector cache, for larger ones
we use a single hash table. */
/* Create an INT_CST node of TYPE and value HI:LOW.
The returned node is always shared. For small integers we use a
per-type vector cache, for larger ones we use a single hash table. */
tree
build_int_cst_wide (tree type, unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi)

View File

@ -3654,6 +3654,8 @@ extern tree build_int_cst (tree, HOST_WIDE_INT);
extern tree build_int_cst_type (tree, HOST_WIDE_INT);
extern tree build_int_cstu (tree, unsigned HOST_WIDE_INT);
extern tree build_int_cst_wide (tree, unsigned HOST_WIDE_INT, HOST_WIDE_INT);
extern tree build_int_cst_wide_type (tree,
unsigned HOST_WIDE_INT, HOST_WIDE_INT);
extern tree build_vector (tree, tree);
extern tree build_vector_from_ctor (tree, VEC(constructor_elt,gc) *);
extern tree build_constructor (tree, VEC(constructor_elt,gc) *);