aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-01-08 22:53:20 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-01-08 22:53:20 +0000
commit2ac7cbb53296e6006d7c113d81175dd455fd570b (patch)
treec7ad9e6d3d7b86c201aaecf9a0017fb8badea1c3
parent1c61ff294690d6ce7c9e958f62ab48a441943844 (diff)
downloadgcc-2ac7cbb53296e6006d7c113d81175dd455fd570b.zip
gcc-2ac7cbb53296e6006d7c113d81175dd455fd570b.tar.gz
gcc-2ac7cbb53296e6006d7c113d81175dd455fd570b.tar.bz2
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
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/cuintp.c2
-rw-r--r--gcc/ada/trans.c6
-rw-r--r--gcc/builtins.c13
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/cvt.c4
-rw-r--r--gcc/fold-const.c31
-rw-r--r--gcc/java/ChangeLog5
-rw-r--r--gcc/java/jcf-parse.c3
-rw-r--r--gcc/java/lex.c5
-rw-r--r--gcc/stor-layout.c13
-rw-r--r--gcc/tree.c18
-rw-r--r--gcc/tree.h2
14 files changed, 75 insertions, 53 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 44039cc..db828ec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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).
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e8361c2..af2d893 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/cuintp.c b/gcc/ada/cuintp.c
index 7adc057..fbf800f 100644
--- a/gcc/ada/cuintp.c
+++ b/gcc/ada/cuintp.c
@@ -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,
diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c
index b19f2f5..14c059d 100644
--- a/gcc/ada/trans.c
+++ b/gcc/ada/trans.c
@@ -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:
diff --git a/gcc/builtins.c b/gcc/builtins.c
index a39a4c1..ad85034 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -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;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a8d9f78..d41988f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index f09f708..d01dc1d 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -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);
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d082ed3..d88c01b 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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);
}
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index edd58d4..a8aea42 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -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.
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index b9d52b6..9f0ccaa 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -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;
}
diff --git a/gcc/java/lex.c b/gcc/java/lex.c
index 661f141..730c144 100644
--- a/gcc/java/lex.c
+++ b/gcc/java/lex.c
@@ -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)
{
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 61879a0..c1c81c3 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -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;
}
}
diff --git a/gcc/tree.c b/gcc/tree.c
index 348d288..a3577c4 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -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)
diff --git a/gcc/tree.h b/gcc/tree.h
index fd9e14a..37a8546 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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) *);