Commit 9645c3c5 by Roger Sayle Committed by Roger Sayle

cuintp.c (UI_To_gnu): Use fold_buildN calls instead of calling fold with the result of buildN.


	* cuintp.c (UI_To_gnu): Use fold_buildN calls instead of calling
	fold with the result of buildN.
	* decl.c (gnat_to_gnu_entity): Likewise.
	* trans.c (Attribute_to_gnu, gnat_to_gnu, emit_check): Likewise.
	* utils.c (finish_record_type, merge_sizes, max_size, convert):
	Likewise.
	* utils2.c (gnat_truthvalue_conversion, compare_arrays,
	nonbinary_modular_operation, build_binary_op, build_unary_op,
	build_cond_expr): Likewise.

	* utils.c (convert): Use fold_build1 when casting values to void.
	* utils2.c (gnat_truthvalue_conversion): Use build_int_cst and
	fold_convert instead of convert when appropriate.

From-SVN: r122752
parent 63a08740
2007-03-09 Roger Sayle <roger@eyesopen.com>
* cuintp.c (UI_To_gnu): Use fold_buildN calls instead of calling
fold with the result of buildN.
* decl.c (gnat_to_gnu_entity): Likewise.
* trans.c (Attribute_to_gnu, gnat_to_gnu, emit_check): Likewise.
* utils.c (finish_record_type, merge_sizes, max_size, convert):
Likewise.
* utils2.c (gnat_truthvalue_conversion, compare_arrays,
nonbinary_modular_operation, build_binary_op, build_unary_op,
build_cond_expr): Likewise.
* utils.c (convert): Use fold_build1 when casting values to void.
* utils2.c (gnat_truthvalue_conversion): Use build_int_cst and
fold_convert instead of convert when appropriate.
2007-03-01 Brooks Moses <brooks.moses@codesourcery.com> 2007-03-01 Brooks Moses <brooks.moses@codesourcery.com>
* Make-lang.in: Add install-pdf target as copied from * Make-lang.in: Add install-pdf target as copied from
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* * * *
* C Implementation File * * C Implementation File *
* * * *
* Copyright (C) 1992-2005 Free Software Foundation, Inc. * * Copyright (C) 1992-2007 Free Software Foundation, Inc. *
* * * *
* GNAT is free software; you can redistribute it and/or modify it under * * GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- * * terms of the GNU General Public License as published by the Free Soft- *
...@@ -113,18 +113,18 @@ UI_To_gnu (Uint Input, tree type) ...@@ -113,18 +113,18 @@ UI_To_gnu (Uint Input, tree type)
gnu_ret = build_cst_from_int (comp_type, First); gnu_ret = build_cst_from_int (comp_type, First);
if (First < 0) if (First < 0)
for (Idx++, Length--; Length; Idx++, Length--) for (Idx++, Length--; Length; Idx++, Length--)
gnu_ret = fold (build2 (MINUS_EXPR, comp_type, gnu_ret = fold_build2 (MINUS_EXPR, comp_type,
fold (build2 (MULT_EXPR, comp_type, fold_build2 (MULT_EXPR, comp_type,
gnu_ret, gnu_base)), gnu_ret, gnu_base),
build_cst_from_int (comp_type, build_cst_from_int (comp_type,
Udigits_Ptr[Idx]))); Udigits_Ptr[Idx]));
else else
for (Idx++, Length--; Length; Idx++, Length--) for (Idx++, Length--; Length; Idx++, Length--)
gnu_ret = fold (build2 (PLUS_EXPR, comp_type, gnu_ret = fold_build2 (PLUS_EXPR, comp_type,
fold (build2 (MULT_EXPR, comp_type, fold_build2 (MULT_EXPR, comp_type,
gnu_ret, gnu_base)), gnu_ret, gnu_base),
build_cst_from_int (comp_type, build_cst_from_int (comp_type,
Udigits_Ptr[Idx]))); Udigits_Ptr[Idx]));
} }
gnu_ret = convert (type, gnu_ret); gnu_ret = convert (type, gnu_ret);
......
...@@ -1332,8 +1332,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1332,8 +1332,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
{ {
TYPE_MODULAR_P (gnu_type) = 1; TYPE_MODULAR_P (gnu_type) = 1;
SET_TYPE_MODULUS (gnu_type, gnu_modulus); SET_TYPE_MODULUS (gnu_type, gnu_modulus);
gnu_high = fold (build2 (MINUS_EXPR, gnu_type, gnu_modulus, gnu_high = fold_build2 (MINUS_EXPR, gnu_type, gnu_modulus,
convert (gnu_type, integer_one_node))); convert (gnu_type, integer_one_node));
} }
/* If we have to set TYPE_PRECISION different from its natural value, /* If we have to set TYPE_PRECISION different from its natural value,
...@@ -1909,10 +1909,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -1909,10 +1909,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& TREE_CODE (gnu_max) == INTEGER_CST && TREE_CODE (gnu_max) == INTEGER_CST
&& TREE_OVERFLOW (gnu_min) && TREE_OVERFLOW (gnu_max) && TREE_OVERFLOW (gnu_min) && TREE_OVERFLOW (gnu_max)
&& (!TREE_OVERFLOW && (!TREE_OVERFLOW
(fold (build2 (MINUS_EXPR, gnu_index_subtype, (fold_build2 (MINUS_EXPR, gnu_index_subtype,
TYPE_MAX_VALUE (gnu_index_subtype), TYPE_MAX_VALUE (gnu_index_subtype),
TYPE_MIN_VALUE (gnu_index_subtype)))))) TYPE_MIN_VALUE (gnu_index_subtype)))))
TREE_OVERFLOW (gnu_min) = TREE_OVERFLOW (gnu_max) = 0; {
TREE_OVERFLOW (gnu_min) = 0;
TREE_OVERFLOW (gnu_max) = 0;
}
/* Similarly, if the range is null, use bounds of 1..0 for /* Similarly, if the range is null, use bounds of 1..0 for
the sizetype bounds. */ the sizetype bounds. */
......
...@@ -782,8 +782,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) ...@@ -782,8 +782,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
if (attribute == Attr_Max_Size_In_Storage_Elements) if (attribute == Attr_Max_Size_In_Storage_Elements)
gnu_result = convert (sizetype, gnu_result = convert (sizetype,
fold (build2 (CEIL_DIV_EXPR, bitsizetype, fold_build2 (CEIL_DIV_EXPR, bitsizetype,
gnu_result, bitsize_unit_node))); gnu_result, bitsize_unit_node));
break; break;
case Attr_Alignment: case Attr_Alignment:
...@@ -1100,8 +1100,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) ...@@ -1100,8 +1100,8 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
example in AARM 11.6(5.e). */ example in AARM 11.6(5.e). */
if (prefix_unused && TREE_SIDE_EFFECTS (gnu_prefix) if (prefix_unused && TREE_SIDE_EFFECTS (gnu_prefix)
&& !Is_Entity_Name (Prefix (gnat_node))) && !Is_Entity_Name (Prefix (gnat_node)))
gnu_result = fold (build2 (COMPOUND_EXPR, TREE_TYPE (gnu_result), gnu_result = fold_build2 (COMPOUND_EXPR, TREE_TYPE (gnu_result),
gnu_prefix, gnu_result)); gnu_prefix, gnu_result);
*gnu_result_type_p = gnu_result_type; *gnu_result_type_p = gnu_result_type;
return gnu_result; return gnu_result;
...@@ -3079,13 +3079,13 @@ gnat_to_gnu (Node_Id gnat_node) ...@@ -3079,13 +3079,13 @@ gnat_to_gnu (Node_Id gnat_node)
expression if the slice range is not null (max >= min) or expression if the slice range is not null (max >= min) or
returns the min if the slice range is null */ returns the min if the slice range is null */
gnu_expr gnu_expr
= fold (build3 (COND_EXPR, gnu_expr_type, = fold_build3 (COND_EXPR, gnu_expr_type,
build_binary_op (GE_EXPR, gnu_expr_type, build_binary_op (GE_EXPR, gnu_expr_type,
convert (gnu_expr_type, convert (gnu_expr_type,
gnu_max_expr), gnu_max_expr),
convert (gnu_expr_type, convert (gnu_expr_type,
gnu_min_expr)), gnu_min_expr)),
gnu_expr, gnu_min_expr)); gnu_expr, gnu_min_expr);
} }
else else
gnu_expr = TYPE_MIN_VALUE (TYPE_DOMAIN (gnu_result_type)); gnu_expr = TYPE_MIN_VALUE (TYPE_DOMAIN (gnu_result_type));
...@@ -5403,10 +5403,10 @@ emit_check (tree gnu_cond, tree gnu_expr, int reason) ...@@ -5403,10 +5403,10 @@ emit_check (tree gnu_cond, tree gnu_expr, int reason)
in front of the comparison in case it ends up being a SAVE_EXPR. Put the in front of the comparison in case it ends up being a SAVE_EXPR. Put the
whole thing inside its own SAVE_EXPR so the inner SAVE_EXPR doesn't leak whole thing inside its own SAVE_EXPR so the inner SAVE_EXPR doesn't leak
out. */ out. */
gnu_result = fold (build3 (COND_EXPR, TREE_TYPE (gnu_expr), gnu_cond, gnu_result = fold_build3 (COND_EXPR, TREE_TYPE (gnu_expr), gnu_cond,
build2 (COMPOUND_EXPR, TREE_TYPE (gnu_expr), build2 (COMPOUND_EXPR, TREE_TYPE (gnu_expr),
gnu_call, gnu_expr), gnu_call, gnu_expr),
gnu_expr)); gnu_expr);
/* If GNU_EXPR has side effects, make the outer COMPOUND_EXPR and /* If GNU_EXPR has side effects, make the outer COMPOUND_EXPR and
protect it. Otherwise, show GNU_RESULT has no side effects: we protect it. Otherwise, show GNU_RESULT has no side effects: we
......
...@@ -868,10 +868,10 @@ finish_record_type (tree record_type, tree fieldlist, bool has_rep, ...@@ -868,10 +868,10 @@ finish_record_type (tree record_type, tree fieldlist, bool has_rep,
case QUAL_UNION_TYPE: case QUAL_UNION_TYPE:
ada_size ada_size
= fold (build3 (COND_EXPR, bitsizetype, DECL_QUALIFIER (field), = fold_build3 (COND_EXPR, bitsizetype, DECL_QUALIFIER (field),
this_ada_size, ada_size)); this_ada_size, ada_size);
size = fold (build3 (COND_EXPR, bitsizetype, DECL_QUALIFIER (field), size = fold_build3 (COND_EXPR, bitsizetype, DECL_QUALIFIER (field),
this_size, size)); this_size, size);
break; break;
case RECORD_TYPE: case RECORD_TYPE:
...@@ -1133,15 +1133,15 @@ merge_sizes (tree last_size, tree first_bit, tree size, bool special, ...@@ -1133,15 +1133,15 @@ merge_sizes (tree last_size, tree first_bit, tree size, bool special,
} }
else else
new = fold (build3 (COND_EXPR, type, TREE_OPERAND (size, 0), new = fold_build3 (COND_EXPR, type, TREE_OPERAND (size, 0),
integer_zerop (TREE_OPERAND (size, 1)) integer_zerop (TREE_OPERAND (size, 1))
? last_size : merge_sizes (last_size, first_bit, ? last_size : merge_sizes (last_size, first_bit,
TREE_OPERAND (size, 1), TREE_OPERAND (size, 1),
1, has_rep), 1, has_rep),
integer_zerop (TREE_OPERAND (size, 2)) integer_zerop (TREE_OPERAND (size, 2))
? last_size : merge_sizes (last_size, first_bit, ? last_size : merge_sizes (last_size, first_bit,
TREE_OPERAND (size, 2), TREE_OPERAND (size, 2),
1, has_rep))); 1, has_rep));
/* We don't need any NON_VALUE_EXPRs and they can confuse us (especially /* We don't need any NON_VALUE_EXPRs and they can confuse us (especially
when fed through substitute_in_expr) into thinking that a constant when fed through substitute_in_expr) into thinking that a constant
...@@ -2372,9 +2372,9 @@ max_size (tree exp, bool max_p) ...@@ -2372,9 +2372,9 @@ max_size (tree exp, bool max_p)
return max_size (TREE_OPERAND (exp, 0), max_p); return max_size (TREE_OPERAND (exp, 0), max_p);
else else
return return
fold (build1 (code, type, fold_build1 (code, type,
max_size (TREE_OPERAND (exp, 0), max_size (TREE_OPERAND (exp, 0),
code == NEGATE_EXPR ? !max_p : max_p))); code == NEGATE_EXPR ? !max_p : max_p));
case 2: case 2:
if (code == COMPOUND_EXPR) if (code == COMPOUND_EXPR)
...@@ -2424,16 +2424,16 @@ max_size (tree exp, bool max_p) ...@@ -2424,16 +2424,16 @@ max_size (tree exp, bool max_p)
&& !TREE_CONSTANT (rhs)) && !TREE_CONSTANT (rhs))
return lhs; return lhs;
else else
return fold (build2 (code, type, lhs, rhs)); return fold_build2 (code, type, lhs, rhs);
} }
case 3: case 3:
if (code == SAVE_EXPR) if (code == SAVE_EXPR)
return exp; return exp;
else if (code == COND_EXPR) else if (code == COND_EXPR)
return fold (build2 (max_p ? MAX_EXPR : MIN_EXPR, type, return fold_build2 (max_p ? MAX_EXPR : MIN_EXPR, type,
max_size (TREE_OPERAND (exp, 1), max_p), max_size (TREE_OPERAND (exp, 1), max_p),
max_size (TREE_OPERAND (exp, 2), max_p))); max_size (TREE_OPERAND (exp, 2), max_p));
} }
/* Other tree classes cannot happen. */ /* Other tree classes cannot happen. */
...@@ -3167,10 +3167,10 @@ convert (tree type, tree expr) ...@@ -3167,10 +3167,10 @@ convert (tree type, tree expr)
/* If the input is a biased type, adjust first. */ /* If the input is a biased type, adjust first. */
if (ecode == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (etype)) if (ecode == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (etype))
return convert (type, fold (build2 (PLUS_EXPR, TREE_TYPE (etype), return convert (type, fold_build2 (PLUS_EXPR, TREE_TYPE (etype),
fold_convert (TREE_TYPE (etype), fold_convert (TREE_TYPE (etype),
expr), expr),
TYPE_MIN_VALUE (etype)))); TYPE_MIN_VALUE (etype)));
/* If the input is a justified modular type, we need to extract the actual /* If the input is a justified modular type, we need to extract the actual
object before converting it to any other type with the exceptions of an object before converting it to any other type with the exceptions of an
...@@ -3321,7 +3321,7 @@ convert (tree type, tree expr) ...@@ -3321,7 +3321,7 @@ convert (tree type, tree expr)
switch (code) switch (code)
{ {
case VOID_TYPE: case VOID_TYPE:
return build1 (CONVERT_EXPR, type, expr); return fold_build1 (CONVERT_EXPR, type, expr);
case BOOLEAN_TYPE: case BOOLEAN_TYPE:
return fold_convert (type, gnat_truthvalue_conversion (expr)); return fold_convert (type, gnat_truthvalue_conversion (expr));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment