Commit 1139f2e8 by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Use boolean_type_node in lieu of integer_type_node…

decl.c (gnat_to_gnu_entity): Use boolean_type_node in lieu of integer_type_node for boolean operations.

	* gcc-interface/decl.c (gnat_to_gnu_entity): Use boolean_type_node in
	lieu of integer_type_node for boolean operations.
	(choices_to_gnu): Likewise.
	* gcc-interface/trans.c (Attribute_to_gnu): Likewise.
	(Loop_Statement_to_gnu): Likewise.
	(establish_gnat_vms_condition_handler): Likewise.
	(Exception_Handler_to_gnu_sjlj): Likewise.
	(gnat_to_gnu): Likewise.
	(build_unary_op_trapv): Likewise.
	(build_binary_op_trapv): Likewise.
	(emit_range_check): Likewise.
	(emit_index_check): Likewise.
	(convert_with_check): Likewise.
	* gcc-interface/utils.c (convert_vms_descriptor64): Likewise.
	(convert_vms_descriptor32): Likewise.
	(convert_vms_descriptor): Likewise.
	* gcc-interface/utils2.c (nonbinary_modular_operation): Likewise.
	(compare_arrays): Use boolean instead of integer constants.
	(build_binary_op) <TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, TRUTH_AND_EXPR,
	TRUTH_OR_EXPR, TRUTH_XOR_EXPR>: New case.  Check that the result type
	is a boolean type.
	<GE_EXPR, LE_EXPR, GT_EXPR, LT_EXPR>: Remove obsolete assertion.
	<EQ_EXPR, NE_EXPR>: Check that the result type is a boolean type.
	<PREINC/PREDECREMENT_EXPR, POSTINC/POSTDECREMENT_EXPR>: Delete.
	<TRUTH_NOT_EXPR>: Check that the result type is a boolean type.
	(build_unary_op): Use boolean_type_node in lieu of integer_type_node
	for boolean operations.
	(fill_vms_descriptor): Likewise.  Fix formatting nits.

From-SVN: r158411
parent d88bbbb9
2010-04-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity): Use boolean_type_node in
lieu of integer_type_node for boolean operations.
(choices_to_gnu): Likewise.
* gcc-interface/trans.c (Attribute_to_gnu): Likewise.
(Loop_Statement_to_gnu): Likewise.
(establish_gnat_vms_condition_handler): Likewise.
(Exception_Handler_to_gnu_sjlj): Likewise.
(gnat_to_gnu): Likewise.
(build_unary_op_trapv): Likewise.
(build_binary_op_trapv): Likewise.
(emit_range_check): Likewise.
(emit_index_check): Likewise.
(convert_with_check): Likewise.
* gcc-interface/utils.c (convert_vms_descriptor64): Likewise.
(convert_vms_descriptor32): Likewise.
(convert_vms_descriptor): Likewise.
* gcc-interface/utils2.c (nonbinary_modular_operation): Likewise.
(compare_arrays): Use boolean instead of integer constants.
(build_binary_op) <TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR, TRUTH_AND_EXPR,
TRUTH_OR_EXPR, TRUTH_XOR_EXPR>: New case. Check that the result type
is a boolean type.
<GE_EXPR, LE_EXPR, GT_EXPR, LT_EXPR>: Remove obsolete assertion.
<EQ_EXPR, NE_EXPR>: Check that the result type is a boolean type.
<PREINC/PREDECREMENT_EXPR, POSTINC/POSTDECREMENT_EXPR>: Delete.
<TRUTH_NOT_EXPR>: Check that the result type is a boolean type.
(build_unary_op): Use boolean_type_node in lieu of integer_type_node
for boolean operations.
(fill_vms_descriptor): Likewise. Fix formatting nits.
2010-04-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada-tree.def (LOOP_STMT): Change to 4-operand nodes.
* gcc-interface/ada-tree.h (LOOP_STMT_TOP_COND, LOOP_STMT_BOT_COND):
Merge into...
......
......@@ -1916,7 +1916,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* Compute the size of this dimension. */
gnu_max
= build3 (COND_EXPR, gnu_index_base_type,
build2 (GE_EXPR, integer_type_node, gnu_high, gnu_low),
build2 (GE_EXPR, boolean_type_node, gnu_high, gnu_low),
gnu_high,
build2 (MINUS_EXPR, gnu_index_base_type,
gnu_low, fold_convert (gnu_index_base_type,
......@@ -2214,7 +2214,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnu_high
= build_cond_expr (sizetype,
build_binary_op (GE_EXPR,
integer_type_node,
boolean_type_node,
gnu_orig_max,
gnu_orig_min),
gnu_max, gnu_high);
......@@ -6335,13 +6335,11 @@ choices_to_gnu (tree operand, Node_Id choices)
low = gnat_to_gnu (Low_Bound (choice));
high = gnat_to_gnu (High_Bound (choice));
/* There's no good type to use here, so we might as well use
integer_type_node. */
this_test
= build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
build_binary_op (GE_EXPR, integer_type_node,
= build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
build_binary_op (GE_EXPR, boolean_type_node,
operand, low),
build_binary_op (LE_EXPR, integer_type_node,
build_binary_op (LE_EXPR, boolean_type_node,
operand, high));
break;
......@@ -6352,10 +6350,10 @@ choices_to_gnu (tree operand, Node_Id choices)
high = gnat_to_gnu (High_Bound (gnat_temp));
this_test
= build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
build_binary_op (GE_EXPR, integer_type_node,
= build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
build_binary_op (GE_EXPR, boolean_type_node,
operand, low),
build_binary_op (LE_EXPR, integer_type_node,
build_binary_op (LE_EXPR, boolean_type_node,
operand, high));
break;
......@@ -6373,10 +6371,10 @@ choices_to_gnu (tree operand, Node_Id choices)
high = TYPE_MAX_VALUE (type);
this_test
= build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
build_binary_op (GE_EXPR, integer_type_node,
= build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
build_binary_op (GE_EXPR, boolean_type_node,
operand, low),
build_binary_op (LE_EXPR, integer_type_node,
build_binary_op (LE_EXPR, boolean_type_node,
operand, high));
break;
}
......@@ -6386,7 +6384,7 @@ choices_to_gnu (tree operand, Node_Id choices)
case N_Character_Literal:
case N_Integer_Literal:
single = gnat_to_gnu (choice);
this_test = build_binary_op (EQ_EXPR, integer_type_node, operand,
this_test = build_binary_op (EQ_EXPR, boolean_type_node, operand,
single);
break;
......@@ -6398,8 +6396,8 @@ choices_to_gnu (tree operand, Node_Id choices)
gcc_unreachable ();
}
result = build_binary_op (TRUTH_ORIF_EXPR, integer_type_node,
result, this_test);
result = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node, result,
this_test);
}
return result;
......
......@@ -3025,7 +3025,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
/* Test that we really have a SB descriptor, like DEC Ada. */
t = build3 (COMPONENT_REF, TREE_TYPE (klass), desc, klass, NULL);
u = convert (TREE_TYPE (klass), DECL_INITIAL (klass));
u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
u = build_binary_op (EQ_EXPR, boolean_type_node, t, u);
/* If so, there is already a template in the descriptor and
it is located right after the POINTER field. The fields are
64bits so they must be repacked. */
......@@ -3063,12 +3063,12 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
/* Raise CONSTRAINT_ERROR if either more than 1 dimension
or FL_COEFF or FL_BOUNDS not set. */
u = build_int_cst (TREE_TYPE (aflags), 192);
u = build_binary_op (TRUTH_OR_EXPR, integer_type_node,
build_binary_op (NE_EXPR, integer_type_node,
u = build_binary_op (TRUTH_OR_EXPR, boolean_type_node,
build_binary_op (NE_EXPR, boolean_type_node,
dimct,
convert (TREE_TYPE (dimct),
size_one_node)),
build_binary_op (NE_EXPR, integer_type_node,
build_binary_op (NE_EXPR, boolean_type_node,
build2 (BIT_AND_EXPR,
TREE_TYPE (aflags),
aflags, u),
......@@ -3173,7 +3173,7 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
/* Test that we really have a SB descriptor, like DEC Ada. */
t = build3 (COMPONENT_REF, TREE_TYPE (klass), desc, klass, NULL);
u = convert (TREE_TYPE (klass), DECL_INITIAL (klass));
u = build_binary_op (EQ_EXPR, integer_type_node, t, u);
u = build_binary_op (EQ_EXPR, boolean_type_node, t, u);
/* If so, there is already a template in the descriptor and
it is located right after the POINTER field. */
t = TREE_CHAIN (pointer);
......@@ -3196,12 +3196,12 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog)
/* Raise CONSTRAINT_ERROR if either more than 1 dimension
or FL_COEFF or FL_BOUNDS not set. */
u = build_int_cst (TREE_TYPE (aflags), 192);
u = build_binary_op (TRUTH_OR_EXPR, integer_type_node,
build_binary_op (NE_EXPR, integer_type_node,
u = build_binary_op (TRUTH_OR_EXPR, boolean_type_node,
build_binary_op (NE_EXPR, boolean_type_node,
dimct,
convert (TREE_TYPE (dimct),
size_one_node)),
build_binary_op (NE_EXPR, integer_type_node,
build_binary_op (NE_EXPR, boolean_type_node,
build2 (BIT_AND_EXPR,
TREE_TYPE (aflags),
aflags, u),
......@@ -3263,11 +3263,11 @@ convert_vms_descriptor (tree gnu_type, tree gnu_expr, tree gnu_expr_alt_type,
mbo = build3 (COMPONENT_REF, TREE_TYPE (mbo), desc, mbo, NULL_TREE);
mbmo = build3 (COMPONENT_REF, TREE_TYPE (mbmo), desc, mbmo, NULL_TREE);
is64bit
= build_binary_op (TRUTH_ANDIF_EXPR, integer_type_node,
build_binary_op (EQ_EXPR, integer_type_node,
= build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node,
build_binary_op (EQ_EXPR, boolean_type_node,
convert (integer_type_node, mbo),
integer_one_node),
build_binary_op (EQ_EXPR, integer_type_node,
build_binary_op (EQ_EXPR, boolean_type_node,
convert (integer_type_node, mbmo),
integer_minus_one_node));
......
......@@ -242,11 +242,11 @@ find_common_type (tree t1, tree t2)
static tree
compare_arrays (tree result_type, tree a1, tree a2)
{
tree result = convert (result_type, boolean_true_node);
tree a1_is_null = convert (result_type, boolean_false_node);
tree a2_is_null = convert (result_type, boolean_false_node);
tree t1 = TREE_TYPE (a1);
tree t2 = TREE_TYPE (a2);
tree result = convert (result_type, integer_one_node);
tree a1_is_null = convert (result_type, integer_zero_node);
tree a2_is_null = convert (result_type, integer_zero_node);
bool a1_side_effects_p = TREE_SIDE_EFFECTS (a1);
bool a2_side_effects_p = TREE_SIDE_EFFECTS (a2);
bool length_zero_p = false;
......@@ -310,7 +310,7 @@ compare_arrays (tree result_type, tree a1, tree a2)
length_zero_p = true;
this_a1_is_null = comparison;
this_a2_is_null = convert (result_type, integer_one_node);
this_a2_is_null = convert (result_type, boolean_true_node);
}
/* If the length is some other constant value, we know that the
......@@ -339,7 +339,7 @@ compare_arrays (tree result_type, tree a1, tree a2)
this_a1_is_null = build_binary_op (LT_EXPR, result_type, ub1, lb1);
if (EXPR_P (this_a1_is_null))
SET_EXPR_LOCATION (this_a1_is_null, input_location);
this_a2_is_null = convert (result_type, integer_zero_node);
this_a2_is_null = convert (result_type, boolean_false_node);
}
/* Otherwise compare the computed lengths. */
......@@ -491,7 +491,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs,
{
result = gnat_protect_expr (result);
result = fold_build3 (COND_EXPR, op_type,
fold_build2 (LT_EXPR, integer_type_node, result,
fold_build2 (LT_EXPR, boolean_type_node, result,
convert (op_type, integer_zero_node)),
fold_build2 (PLUS_EXPR, op_type, result, modulus),
result);
......@@ -502,7 +502,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs,
{
result = gnat_protect_expr (result);
result = fold_build3 (COND_EXPR, op_type,
fold_build2 (GE_EXPR, integer_type_node,
fold_build2 (GE_EXPR, boolean_type_node,
result, modulus),
fold_build2 (MINUS_EXPR, op_type,
result, modulus),
......@@ -716,16 +716,28 @@ build_binary_op (enum tree_code op_code, tree result_type,
modulus = NULL_TREE;
break;
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
#ifdef ENABLE_CHECKING
gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
#endif
operation_type = left_base_type;
left_operand = convert (operation_type, left_operand);
right_operand = convert (operation_type, right_operand);
break;
case GE_EXPR:
case LE_EXPR:
case GT_EXPR:
case LT_EXPR:
gcc_assert (!POINTER_TYPE_P (left_type));
/* ... fall through ... */
case EQ_EXPR:
case NE_EXPR:
#ifdef ENABLE_CHECKING
gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
#endif
/* If either operand is a NULL_EXPR, just return a new one. */
if (TREE_CODE (left_operand) == NULL_EXPR)
return build2 (op_code, result_type,
......@@ -842,13 +854,6 @@ build_binary_op (enum tree_code op_code, tree result_type,
modulus = NULL_TREE;
break;
case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
/* These operations are not used anymore. */
gcc_unreachable ();
case LSHIFT_EXPR:
case RSHIFT_EXPR:
case LROTATE_EXPR:
......@@ -1001,7 +1006,9 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
break;
case TRUTH_NOT_EXPR:
gcc_assert (result_type == base_type);
#ifdef ENABLE_CHECKING
gcc_assert (TREE_CODE (get_base_type (result_type)) == BOOLEAN_TYPE);
#endif
result = invert_truthvalue (operand);
break;
......@@ -1259,7 +1266,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
result = fold_build3 (COND_EXPR, operation_type,
fold_build2 (NE_EXPR,
integer_type_node,
boolean_type_node,
operand,
convert
(operation_type,
......@@ -2088,12 +2095,11 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
tree
fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual)
{
tree field;
tree parm_decl = get_gnu_tree (gnat_formal);
tree const_list = NULL_TREE;
tree record_type = TREE_TYPE (TREE_TYPE (parm_decl));
int do_range_check =
strcmp ("MBO",
tree const_list = NULL_TREE, field;
const bool do_range_check
= strcmp ("MBO",
IDENTIFIER_POINTER (DECL_NAME (TYPE_FIELDS (record_type))));
expr = maybe_unconstrained_array (expr);
......@@ -2105,19 +2111,19 @@ fill_vms_descriptor (tree expr, Entity_Id gnat_formal, Node_Id gnat_actual)
SUBSTITUTE_PLACEHOLDER_IN_EXPR
(DECL_INITIAL (field), expr));
/* Check to ensure that only 32bit pointers are passed in
32bit descriptors */
if (do_range_check &&
strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), "POINTER") == 0)
/* Check to ensure that only 32-bit pointers are passed in
32-bit descriptors */
if (do_range_check
&& strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), "POINTER") == 0)
{
tree pointer64type =
build_pointer_type_for_mode (void_type_node, DImode, false);
tree pointer64type
= build_pointer_type_for_mode (void_type_node, DImode, false);
tree addr64expr = build_unary_op (ADDR_EXPR, pointer64type, expr);
tree malloc64low =
build_int_cstu (long_integer_type_node, 0x80000000);
tree malloc64low
= build_int_cstu (long_integer_type_node, 0x80000000);
add_stmt (build3 (COND_EXPR, void_type_node,
build_binary_op (GE_EXPR, long_integer_type_node,
build_binary_op (GE_EXPR, boolean_type_node,
convert (long_integer_type_node,
addr64expr),
malloc64low),
......
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