Commit 3f13dd77 by Eric Botcazou Committed by Eric Botcazou

ada.h: Fix outdated comment.

	* gcc-interface/ada.h: Fix outdated comment.
	* gcc-interface/ada-tree.h (SET_TYPE_RM_VALUE): Use MARK_VISITED in
	lieu of mark_visited.
	* gcc-interface/gigi.h (mark_visited): Change type of parameter.
	(MARK_VISITED): New macro.
	(gnat_truthvalue_conversion): Delete.
	* gcc-interface/decl.c (gnat_to_gnu_entity): Use MARK_VISITED in lieu
	of mark_visited.
	(annotate_rep): Fix formatting and tidy.
	(compute_field_positions): Get rid of useless variable.
	* gcc-interface/trans.c (gnat_to_gnu): Retrieve the Nkind of the GNAT
	node only once.  Use IN operator for the Nkind in more cases.
	Remove calls to gnat_truthvalue_conversion.
	(mark_visited): Change type of parameter and adjust.
	(mark_visited_r): Dereference TP only once.
	(add_decl_expr): Use MARK_VISITED in lieu of mark_visited.
	* gcc-interface/utils2.c (gnat_truthvalue_conversion): Delete.
	(build_binary_op): Remove calls to gnat_truthvalue_conversion.
	(build_unary_op): Likewise.

From-SVN: r152121
parent 6356f38f
2009-09-24 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada.h: Fix outdated comment.
* gcc-interface/ada-tree.h (SET_TYPE_RM_VALUE): Use MARK_VISITED in
lieu of mark_visited.
* gcc-interface/gigi.h (mark_visited): Change type of parameter.
(MARK_VISITED): New macro.
(gnat_truthvalue_conversion): Delete.
* gcc-interface/decl.c (gnat_to_gnu_entity): Use MARK_VISITED in lieu
of mark_visited.
(annotate_rep): Fix formatting and tidy.
(compute_field_positions): Get rid of useless variable.
* gcc-interface/trans.c (gnat_to_gnu): Retrieve the Nkind of the GNAT
node only once. Use IN operator for the Nkind in more cases.
Remove calls to gnat_truthvalue_conversion.
(mark_visited): Change type of parameter and adjust.
(mark_visited_r): Dereference TP only once.
(add_decl_expr): Use MARK_VISITED in lieu of mark_visited.
* gcc-interface/utils2.c (gnat_truthvalue_conversion): Delete.
(build_binary_op): Remove calls to gnat_truthvalue_conversion.
(build_unary_op): Likewise.
2009-09-24 Dave Korn <dave.korn.cygwin@gmail.com>
* gcc-interface/Makefile.in (LIBGNAT_TARGET_PAIRS): Simplify test for
......
......@@ -210,8 +210,7 @@ do { \
TYPE_RM_VALUES (NODE) = make_tree_vec (3); \
/* ??? The field is not visited by the generic \
code so we need to mark it manually. */ \
if (!TREE_CONSTANT (tmp)) \
mark_visited (&tmp); \
MARK_VISITED (tmp); \
TREE_VEC_ELT (TYPE_RM_VALUES (NODE), (N)) = tmp; \
} while (0)
......
......@@ -62,9 +62,9 @@
enum { CAT (SUBTYPE,__First) = FIRST, \
CAT (SUBTYPE,__Last) = LAST };
/* The following definitions provide the equivalent of the Ada IN and NOT IN
operators, assuming that the subtype involved has been defined using the
SUBTYPE macro defined above. */
/* The following definition provides the equivalent of the Ada IN operator,
assuming that the subtype involved has been defined using the SUBTYPE
macro defined above. */
#define IN(VALUE,SUBTYPE) \
(((VALUE) >= (SUBTYPE) CAT (SUBTYPE,__First)) \
......
......@@ -898,11 +898,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
if (stable)
{
gnu_decl = maybe_stable_expr;
/* ??? No DECL_EXPR is created so we need to mark
the expression manually lest it is shared. */
if (global_bindings_p ())
mark_visited (&gnu_decl);
MARK_VISITED (maybe_stable_expr);
gnu_decl = maybe_stable_expr;
save_gnu_tree (gnat_entity, gnu_decl, true);
saved = true;
annotate_object (gnat_entity, gnu_type, NULL_TREE,
......@@ -2465,7 +2465,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* ??? create_type_decl is not invoked on the inner types so
the MULT_EXPR node built above will never be marked. */
mark_visited (&TYPE_SIZE_UNIT (gnu_arr_type));
MARK_VISITED (TYPE_SIZE_UNIT (gnu_arr_type));
}
}
......@@ -4631,7 +4631,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
the MULT_EXPR node built above may not be marked by the call
to create_type_decl below. */
if (global_bindings_p ())
mark_visited (&DECL_FIELD_OFFSET (gnu_field));
MARK_VISITED (DECL_FIELD_OFFSET (gnu_field));
}
}
......@@ -7271,78 +7271,76 @@ annotate_object (Entity_Id gnat_entity, tree gnu_type, tree size, bool by_ref)
UI_From_Int (TYPE_ALIGN (gnu_type) / BITS_PER_UNIT));
}
/* Given GNAT_ENTITY, a record type, and GNU_TYPE, its corresponding
GCC type, set Component_Bit_Offset and Esize to the position and size
used by Gigi. */
/* Given GNAT_ENTITY, a record type, and GNU_TYPE, its corresponding GCC type,
set Component_Bit_Offset and Esize of the components to the position and
size used by Gigi. */
static void
annotate_rep (Entity_Id gnat_entity, tree gnu_type)
{
tree gnu_list;
tree gnu_entry;
Entity_Id gnat_field;
tree gnu_list;
/* We operate by first making a list of all fields and their positions
(we can get the sizes easily at any time) by a recursive call
and then update all the sizes into the tree. */
gnu_list = compute_field_positions (gnu_type, NULL_TREE,
size_zero_node, bitsize_zero_node,
BIGGEST_ALIGNMENT);
/* We operate by first making a list of all fields and their position (we
can get the size easily) and then update all the sizes in the tree. */
gnu_list = compute_field_positions (gnu_type, NULL_TREE, size_zero_node,
bitsize_zero_node, BIGGEST_ALIGNMENT);
for (gnat_field = First_Entity (gnat_entity); Present (gnat_field);
for (gnat_field = First_Entity (gnat_entity);
Present (gnat_field);
gnat_field = Next_Entity (gnat_field))
if ((Ekind (gnat_field) == E_Component
|| (Ekind (gnat_field) == E_Discriminant
&& !Is_Unchecked_Union (Scope (gnat_field)))))
if (Ekind (gnat_field) == E_Component
|| (Ekind (gnat_field) == E_Discriminant
&& !Is_Unchecked_Union (Scope (gnat_field))))
{
tree parent_offset = bitsize_zero_node;
tree parent_offset, t;
gnu_entry = purpose_member (gnat_to_gnu_field_decl (gnat_field),
gnu_list);
if (gnu_entry)
t = purpose_member (gnat_to_gnu_field_decl (gnat_field), gnu_list);
if (t)
{
if (type_annotate_only && Is_Tagged_Type (gnat_entity))
{
/* In this mode the tag and parent components have not been
/* In this mode the tag and parent components are not
generated, so we add the appropriate offset to each
component. For a component appearing in the current
extension, the offset is the size of the parent. */
if (Is_Derived_Type (gnat_entity)
&& Original_Record_Component (gnat_field) == gnat_field)
parent_offset
= UI_To_gnu (Esize (Etype (Base_Type (gnat_entity))),
bitsizetype);
else
parent_offset = bitsize_int (POINTER_SIZE);
if (Is_Derived_Type (gnat_entity)
&& Original_Record_Component (gnat_field) == gnat_field)
parent_offset
= UI_To_gnu (Esize (Etype (Base_Type (gnat_entity))),
bitsizetype);
else
parent_offset = bitsize_int (POINTER_SIZE);
}
else
parent_offset = bitsize_zero_node;
Set_Component_Bit_Offset
(gnat_field,
annotate_value
(size_binop (PLUS_EXPR,
bit_from_pos (TREE_PURPOSE (TREE_VALUE (gnu_entry)),
TREE_VALUE (TREE_VALUE
(TREE_VALUE (gnu_entry)))),
parent_offset)));
Set_Component_Bit_Offset
(gnat_field,
annotate_value
(size_binop (PLUS_EXPR,
bit_from_pos (TREE_PURPOSE (TREE_VALUE (t)),
TREE_VALUE (TREE_VALUE
(TREE_VALUE (t)))),
parent_offset)));
Set_Esize (gnat_field,
annotate_value (DECL_SIZE (TREE_PURPOSE (gnu_entry))));
annotate_value (DECL_SIZE (TREE_PURPOSE (t))));
}
else if (Is_Tagged_Type (gnat_entity)
&& Is_Derived_Type (gnat_entity))
else if (Is_Tagged_Type (gnat_entity) && Is_Derived_Type (gnat_entity))
{
/* If there is no gnu_entry, this is an inherited component whose
/* If there is no entry, this is an inherited component whose
position is the same as in the parent type. */
Set_Component_Bit_Offset
(gnat_field,
Component_Bit_Offset (Original_Record_Component (gnat_field)));
Set_Esize (gnat_field,
Esize (Original_Record_Component (gnat_field)));
}
}
}
/* Scan all fields in GNU_TYPE and build entries where TREE_PURPOSE is the
FIELD_DECL and TREE_VALUE a TREE_LIST with TREE_PURPOSE being the byte
position and TREE_VALUE being a TREE_LIST with TREE_PURPOSE the value to be
......@@ -7356,9 +7354,9 @@ compute_field_positions (tree gnu_type, tree gnu_list, tree gnu_pos,
tree gnu_bitpos, unsigned int offset_align)
{
tree gnu_field;
tree gnu_result = gnu_list;
for (gnu_field = TYPE_FIELDS (gnu_type); gnu_field;
for (gnu_field = TYPE_FIELDS (gnu_type);
gnu_field;
gnu_field = TREE_CHAIN (gnu_field))
{
tree gnu_our_bitpos = size_binop (PLUS_EXPR, gnu_bitpos,
......@@ -7368,22 +7366,22 @@ compute_field_positions (tree gnu_type, tree gnu_list, tree gnu_pos,
unsigned int our_offset_align
= MIN (offset_align, DECL_OFFSET_ALIGN (gnu_field));
gnu_result
gnu_list
= tree_cons (gnu_field,
tree_cons (gnu_our_offset,
tree_cons (size_int (our_offset_align),
gnu_our_bitpos, NULL_TREE),
NULL_TREE),
gnu_result);
gnu_list);
if (DECL_INTERNAL_P (gnu_field))
gnu_result
= compute_field_positions (TREE_TYPE (gnu_field), gnu_result,
gnu_list
= compute_field_positions (TREE_TYPE (gnu_field), gnu_list,
gnu_our_offset, gnu_our_bitpos,
our_offset_align);
}
return gnu_result;
return gnu_list;
}
/* UINT_SIZE is a Uint giving the specified size for an object of GNU_TYPE
......
......@@ -75,10 +75,19 @@ extern void set_block_for_group (tree);
Get SLOC from GNAT_ENTITY. */
extern void add_decl_expr (tree gnu_decl, Entity_Id gnat_entity);
/* Mark nodes rooted at *TP with TREE_VISITED and types as having their
/* Mark nodes rooted at T with TREE_VISITED and types as having their
sized gimplified. We use this to indicate all variable sizes and
positions in global types may not be shared by any subprogram. */
extern void mark_visited (tree *tp);
extern void mark_visited (tree t);
/* This macro calls the above function but short-circuits the common
case of a constant to save time and also checks for NULL. */
#define MARK_VISITED(EXP) \
do { \
if((EXP) && !TREE_CONSTANT (EXP)) \
mark_visited (EXP); \
} while (0)
/* Finalize any From_With_Type incomplete types. We do this after processing
our compilation unit and after processing its spec, if this is a body. */
......@@ -767,20 +776,6 @@ extern bool is_double_scalar_or_array (Entity_Id gnat_type,
component of an aggregate type. */
extern bool type_for_nonaliased_component_p (tree gnu_type);
/* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
operation.
This preparation consists of taking the ordinary
representation of an expression EXPR and producing a valid tree
boolean expression describing whether EXPR is nonzero. We could
simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
but we optimize comparisons, &&, ||, and !.
The resulting type should always be the same as the input type.
This function is simpler than the corresponding C version since
the only possible operands will be things of Boolean type. */
extern tree gnat_truthvalue_conversion (tree expr);
/* Return the base type of TYPE. */
extern tree get_base_type (tree type);
......
......@@ -55,63 +55,6 @@ static tree compare_arrays (tree, tree, tree);
static tree nonbinary_modular_operation (enum tree_code, tree, tree, tree);
static tree build_simple_component_ref (tree, tree, tree, bool);
/* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
operation.
This preparation consists of taking the ordinary representation of
an expression expr and producing a valid tree boolean expression
describing whether expr is nonzero. We could simply always do
build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
but we optimize comparisons, &&, ||, and !.
The resulting type should always be the same as the input type.
This function is simpler than the corresponding C version since
the only possible operands will be things of Boolean type. */
tree
gnat_truthvalue_conversion (tree expr)
{
tree type = TREE_TYPE (expr);
switch (TREE_CODE (expr))
{
case EQ_EXPR: case NE_EXPR: case LE_EXPR: case GE_EXPR:
case LT_EXPR: case GT_EXPR:
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
case ERROR_MARK:
return expr;
case INTEGER_CST:
return (integer_zerop (expr)
? build_int_cst (type, 0)
: build_int_cst (type, 1));
case REAL_CST:
return (real_zerop (expr)
? fold_convert (type, integer_zero_node)
: fold_convert (type, integer_one_node));
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
{
tree arg1 = gnat_truthvalue_conversion (TREE_OPERAND (expr, 1));
tree arg2 = gnat_truthvalue_conversion (TREE_OPERAND (expr, 2));
return fold_build3 (COND_EXPR, type, TREE_OPERAND (expr, 0),
arg1, arg2);
}
default:
return build_binary_op (NE_EXPR, type, expr,
fold_convert (type, integer_zero_node));
}
}
/* Return the base type of TYPE. */
tree
......@@ -970,15 +913,6 @@ build_binary_op (enum tree_code op_code, tree result_type,
left_operand = convert (operation_type, left_operand);
break;
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
left_operand = gnat_truthvalue_conversion (left_operand);
right_operand = gnat_truthvalue_conversion (right_operand);
goto common;
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
......@@ -1120,7 +1054,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
case TRUTH_NOT_EXPR:
gcc_assert (result_type == base_type);
result = invert_truthvalue (gnat_truthvalue_conversion (operand));
result = invert_truthvalue (operand);
break;
case ATTR_ADDR_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