Commit 7d7a1fe8 by Eric Botcazou Committed by Eric Botcazou

gigi.h (maybe_variable): Delete.

	* gcc-interface/gigi.h (maybe_variable): Delete.
	(protect_multiple_eval): Likewise.
	(maybe_stabilize_reference): Likewise.
	(gnat_save_expr): Declare.
	(gnat_protect_expr): Likewise.
	(gnat_stabilize_reference): Likewise.
	* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Use
	gnat_stabilize_reference.
	(maybe_variable): Delete.
	(elaborate_expression_1): Use gnat_save_expr.
	* gcc-interface/trans.c (Attribute_to_gnu): Use gnat_protect_expr.
	(call_to_gnu): Pass NULL to gnat_stabilize_reference.
	(gnat_to_gnu) <N_Object_Declaration>: Use gnat_save_expr.
	<N_Slice>: Use gnat_protect_exp.
	<N_Selected_Component>: Pass NULL to gnat_stabilize_reference.
	<N_In>: Use gnat_protect_expr.
	Pass NULL to gnat_stabilize_reference.
	(build_unary_op_trapv): Use gnat_protect_expr.
	(build_binary_op_trapv): Likewise.
	(emit_range_check): Likewise.
	(emit_index_check): Likewise.
	(convert_with_check): Likewise.
	(protect_multiple_eval): Move to utils2.c file.
	(maybe_stabilize_reference): Merge into...
	(gnat_stabilize_reference): ...this.  Move to utils2.c file.
	(gnat_stabilize_reference_1): Likewise.
	* gcc-interface/utils.c (convert_to_fat_pointer): Use gnat_protect_expr
	instead of protect_multiple_eval.
	* gcc-interface/utils2.c (compare_arrays): Likewise.
	(nonbinary_modular_operation): Likewise.
	(maybe_wrap_malloc): Likewise.
	(build_allocator): Likewise.
	(gnat_save_expr): New function.
	(gnat_protect_expr): Rename from protect_multiple_eval.  Early return
	in common cases.  Propagate TREE_READONLY onto dereferences.
	(gnat_stabilize_reference_1): Move from trans.c file.
	(gnat_stabilize_reference): Likewise.

From-SVN: r158159
parent 3f2060fd
2010-04-09 Eric Botcazou <ebotcazou@adacore.com> 2010-04-09 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (maybe_variable): Delete.
(protect_multiple_eval): Likewise.
(maybe_stabilize_reference): Likewise.
(gnat_save_expr): Declare.
(gnat_protect_expr): Likewise.
(gnat_stabilize_reference): Likewise.
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Use
gnat_stabilize_reference.
(maybe_variable): Delete.
(elaborate_expression_1): Use gnat_save_expr.
* gcc-interface/trans.c (Attribute_to_gnu): Use gnat_protect_expr.
(call_to_gnu): Pass NULL to gnat_stabilize_reference.
(gnat_to_gnu) <N_Object_Declaration>: Use gnat_save_expr.
<N_Slice>: Use gnat_protect_exp.
<N_Selected_Component>: Pass NULL to gnat_stabilize_reference.
<N_In>: Use gnat_protect_expr.
Pass NULL to gnat_stabilize_reference.
(build_unary_op_trapv): Use gnat_protect_expr.
(build_binary_op_trapv): Likewise.
(emit_range_check): Likewise.
(emit_index_check): Likewise.
(convert_with_check): Likewise.
(protect_multiple_eval): Move to utils2.c file.
(maybe_stabilize_reference): Merge into...
(gnat_stabilize_reference): ...this. Move to utils2.c file.
(gnat_stabilize_reference_1): Likewise.
* gcc-interface/utils.c (convert_to_fat_pointer): Use gnat_protect_expr
instead of protect_multiple_eval.
* gcc-interface/utils2.c (compare_arrays): Likewise.
(nonbinary_modular_operation): Likewise.
(maybe_wrap_malloc): Likewise.
(build_allocator): Likewise.
(gnat_save_expr): New function.
(gnat_protect_expr): Rename from protect_multiple_eval. Early return
in common cases. Propagate TREE_READONLY onto dereferences.
(gnat_stabilize_reference_1): Move from trans.c file.
(gnat_stabilize_reference): Likewise.
2010-04-09 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (gnat_mark_addressable): Rename parameter. * gcc-interface/gigi.h (gnat_mark_addressable): Rename parameter.
* gcc-interface/decl.c (maybe_variable): Do not set TREE_STATIC on _REF * gcc-interface/decl.c (maybe_variable): Do not set TREE_STATIC on _REF
node. Use the type of the operand to set TREE_READONLY. node. Use the type of the operand to set TREE_READONLY.
......
...@@ -897,7 +897,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -897,7 +897,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& !TREE_SIDE_EFFECTS (gnu_expr)))) && !TREE_SIDE_EFFECTS (gnu_expr))))
{ {
maybe_stable_expr maybe_stable_expr
= maybe_stabilize_reference (gnu_expr, true, &stable); = gnat_stabilize_reference (gnu_expr, true, &stable);
if (stable) if (stable)
{ {
...@@ -973,7 +973,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -973,7 +973,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
else else
{ {
maybe_stable_expr maybe_stable_expr
= maybe_stabilize_reference (gnu_expr, true, &stable); = gnat_stabilize_reference (gnu_expr, true, &stable);
if (stable) if (stable)
renamed_obj = maybe_stable_expr; renamed_obj = maybe_stable_expr;
...@@ -5727,29 +5727,6 @@ prepend_attributes (Entity_Id gnat_entity, struct attrib ** attr_list) ...@@ -5727,29 +5727,6 @@ prepend_attributes (Entity_Id gnat_entity, struct attrib ** attr_list)
} }
} }
/* Called when we need to protect a variable object using a SAVE_EXPR. */
tree
maybe_variable (tree gnu_operand)
{
if (TREE_CONSTANT (gnu_operand)
|| TREE_READONLY (gnu_operand)
|| TREE_CODE (gnu_operand) == SAVE_EXPR
|| TREE_CODE (gnu_operand) == NULL_EXPR)
return gnu_operand;
if (TREE_CODE (gnu_operand) == UNCONSTRAINED_ARRAY_REF)
{
tree gnu_result
= build1 (UNCONSTRAINED_ARRAY_REF, TREE_TYPE (gnu_operand),
variable_size (TREE_OPERAND (gnu_operand, 0)));
TREE_READONLY (gnu_result) = TYPE_READONLY (TREE_TYPE (gnu_operand));
return gnu_result;
}
return variable_size (gnu_operand);
}
/* Given a GNAT tree GNAT_EXPR, for an expression which is a value within a /* Given a GNAT tree GNAT_EXPR, for an expression which is a value within a
type definition (either a bound or a discriminant value) for GNAT_ENTITY, type definition (either a bound or a discriminant value) for GNAT_ENTITY,
return the GCC tree to use for that expression. GNU_NAME is the suffix return the GCC tree to use for that expression. GNU_NAME is the suffix
...@@ -5852,7 +5829,7 @@ elaborate_expression_1 (tree gnu_expr, Entity_Id gnat_entity, tree gnu_name, ...@@ -5852,7 +5829,7 @@ elaborate_expression_1 (tree gnu_expr, Entity_Id gnat_entity, tree gnu_name,
if (expr_global && expr_variable) if (expr_global && expr_variable)
return gnu_decl; return gnu_decl;
return expr_variable ? maybe_variable (gnu_expr) : gnu_expr; return expr_variable ? gnat_save_expr (gnu_expr) : gnu_expr;
} }
/* Create a record type that contains a SIZE bytes long field of TYPE with a /* Create a record type that contains a SIZE bytes long field of TYPE with a
......
...@@ -112,9 +112,6 @@ extern void mark_out_of_scope (Entity_Id gnat_entity); ...@@ -112,9 +112,6 @@ extern void mark_out_of_scope (Entity_Id gnat_entity);
/* Get the unpadded version of a GNAT type. */ /* Get the unpadded version of a GNAT type. */
extern tree get_unpadded_type (Entity_Id gnat_entity); extern tree get_unpadded_type (Entity_Id gnat_entity);
/* Called when we need to protect a variable object using a save_expr. */
extern tree maybe_variable (tree gnu_operand);
/* Create a record type that contains a SIZE bytes long field of TYPE with a /* Create a record type that contains a SIZE bytes long field of TYPE with a
starting bit position so that it is aligned to ALIGN bits, and leaving at starting bit position so that it is aligned to ALIGN bits, and leaving at
least ROOM bytes free before the field. BASE_ALIGN is the alignment the least ROOM bytes free before the field. BASE_ALIGN is the alignment the
...@@ -256,9 +253,6 @@ extern void post_error_ne_tree (const char *msg, Node_Id node, Entity_Id ent, ...@@ -256,9 +253,6 @@ extern void post_error_ne_tree (const char *msg, Node_Id node, Entity_Id ent,
extern void post_error_ne_tree_2 (const char *msg, Node_Id node, Entity_Id ent, extern void post_error_ne_tree_2 (const char *msg, Node_Id node, Entity_Id ent,
tree t, int num); tree t, int num);
/* Protect EXP from multiple evaluation. This may make a SAVE_EXPR. */
extern tree protect_multiple_eval (tree exp);
/* Return a label to branch to for the exception type in KIND or NULL_TREE /* Return a label to branch to for the exception type in KIND or NULL_TREE
if none. */ if none. */
extern tree get_exception_label (char kind); extern tree get_exception_label (char kind);
...@@ -267,12 +261,6 @@ extern tree get_exception_label (char kind); ...@@ -267,12 +261,6 @@ extern tree get_exception_label (char kind);
called. */ called. */
extern Node_Id error_gnat_node; extern Node_Id error_gnat_node;
/* This is equivalent to stabilize_reference in tree.c, but we know how to
handle our own nodes and we take extra arguments. FORCE says whether to
force evaluation of everything. We set SUCCESS to true unless we walk
through something we don't know how to stabilize. */
extern tree maybe_stabilize_reference (tree ref, bool force, bool *success);
/* Highest number in the front-end node table. */ /* Highest number in the front-end node table. */
extern int max_gnat_nodes; extern int max_gnat_nodes;
...@@ -875,6 +863,21 @@ extern tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal, ...@@ -875,6 +863,21 @@ extern tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal,
should not be allocated in a register. Returns true if successful. */ should not be allocated in a register. Returns true if successful. */
extern bool gnat_mark_addressable (tree t); extern bool gnat_mark_addressable (tree t);
/* Save EXP for later use or reuse. This is equivalent to save_expr in tree.c
but we know how to handle our own nodes. */
extern tree gnat_save_expr (tree exp);
/* Protect EXP for immediate reuse. This is a variant of gnat_save_expr that
is optimized under the assumption that EXP's value doesn't change before
its subsequent reuse(s) except through its potential reevaluation. */
extern tree gnat_protect_expr (tree exp);
/* This is equivalent to stabilize_reference in tree.c but we know how to
handle our own nodes and we take extra arguments. FORCE says whether to
force evaluation of everything. We set SUCCESS to true unless we walk
through something we don't know how to stabilize. */
extern tree gnat_stabilize_reference (tree ref, bool force, bool *success);
/* Implementation of the builtin_function langhook. */ /* Implementation of the builtin_function langhook. */
extern tree gnat_builtin_function (tree decl); extern tree gnat_builtin_function (tree decl);
......
...@@ -3587,7 +3587,7 @@ convert_to_fat_pointer (tree type, tree expr) ...@@ -3587,7 +3587,7 @@ convert_to_fat_pointer (tree type, tree expr)
{ {
tree fields = TYPE_FIELDS (TREE_TYPE (etype)); tree fields = TYPE_FIELDS (TREE_TYPE (etype));
expr = protect_multiple_eval (expr); expr = gnat_protect_expr (expr);
if (TREE_CODE (expr) == ADDR_EXPR) if (TREE_CODE (expr) == ADDR_EXPR)
expr = TREE_OPERAND (expr, 0); expr = TREE_OPERAND (expr, 0);
else else
......
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