Commit c8945d56 by Eric Botcazou Committed by Arnaud Charlet

gigi.h: (tree_code_for_record_type): Declare.

2006-10-31  Eric Botcazou  <ebotcazou@adacore.com>
	    Nicolas Setton  <setton@adacore.com>
	    Olivier Hainque  <hainque@adacore.com>
	    Gary Dismukes  <dismukes@adacore.com>

	* gigi.h: (tree_code_for_record_type): Declare.
	(add_global_renaming_pointer): Rename to record_global_renaming_pointer.
	(get_global_renaming_pointers): Rename to
	invalidate_global_renaming_pointers.
	(static_ctors): Delete.
	(static_dtors): Likewise.
	(gnat_write_global_declarations): Declare.
	(create_var_decl): Adjust descriptive comment to indicate that the
	subprogram may return a CONST_DECL node.
	(create_true_var_decl): Declare new function, similar to
	create_var_decl but forcing the creation of a VAR_DECL node.
	(get_global_renaming_pointers): Declare.
	(add_global_renaming_pointer): Likewise.

	* ada-tree.h (DECL_READONLY_ONCE_ELAB): New macro.

	* decl.c (gnat_to_gnu_entity) <case E_Function>: Don't copy the type
	tree before setting TREE_ADDRESSABLE for by-reference return mechanism
	processing.
	(gnat_to_gnu_entity): Remove From_With_Type from computation for
	imported_p.
	<E_Access_Type>: Use the Non_Limited_View as the full view of the
	designated type if the pointer comes from a limited_with clause.  Make
	incomplete designated type if it is in the main unit and has a freeze
	node.
	<E_Incomplete_Type>: Rework to treat Non_Limited_View, Full_View, and
	Underlying_Full_View similarly.  Return earlier if the full view already
	has an associated tree.
	(gnat_to_gnu_entity) <E_Record_Type>: Restore comment.
	(gnat_to_gnu_entity) <E_Record_Type>: Do not use a dummy type.
	(gnat_to_gnu_entity) <E_Variable>: Set TYPE_REF_CAN_ALIAS_ALL on the
	reference type built for objects with an address clause.
	Use create_true_var_decl with const_flag set for
	DECL_CONST_CORRESPONDING_VARs, ensuring a VAR_DECL is created with
	TREE_READONLY set.
	(gnat_to_gnu_entity, case E_Enumeration_Type): Set TYPE_NAME
	for Character and Wide_Character types. This info is read by the
	dwarf-2 writer, and is needed to be able to use the command "ptype
	character" in the debugger.
	(gnat_to_gnu_entity): When generating a type representing
	a Character or Wide_Character type, set the flag TYPE_STRING_FLAG,
	so that debug writers can distinguish it from ordinary integers.
	(elaborate_expression_1): Test the DECL_READONLY_ONCE_ELAB flag in
	addition to TREE_READONLY to assert the constantness of variables for
	elaboration purposes.
	(gnat_to_gnu_entity, subprogram cases): Change loops on formal
	parameters to call new Einfo function First_Formal_With_Extras.
	(gnat_to_gnu_entity): In type_annotate mode, replace a discriminant of a
	protected type with its corresponding discriminant, to obtain a usable
	declaration
	(gnat_to_gnu_entity) <E_Access_Protected_Subprogram_Type>: Be prepared
	for a multiple elaboration of the "equivalent" type.
	(gnat_to_gnu_entity): Adjust for renaming of add_global_renaming_pointer
	into record_global_renaming_pointer.
	(gnat_to_gnu_entity) <E_Array_Type>: Do not force
	TYPE_NONALIASED_COMPONENT to 0 if the element type is an aggregate.
	<E_Array_Subtype>: Likewise.
	(gnat_to_gnu_entity) <E_Incomplete_Subtype>: Add support for regular
	incomplete subtypes and incomplete subtypes of incomplete types visible
	through a limited with clause.
	(gnat_to_gnu_entity) <E_Array_Subtype>: Take into account the bounds of
	the base index type for the maximum size of the array only if they are
	constant.
	(gnat_to_gnu_entity, renaming object case): Do not wrap up the
	expression into a SAVE_EXPR if stabilization failed.

	* utils.c (create_subprog_decl): Turn TREE_ADDRESSABLE on the type of
	a result decl into DECL_BY_REFERENCE on this decl, now what is expected
	by lower level compilation passes.
	(gnat_genericize): New function, lowering a function body to GENERIC.
	Turn the type of RESULT_DECL into a real reference type if the decl
	has been marked DECL_BY_REFERENCE, and adjust references to the latter
	accordingly.
	(gnat_genericize_r): New function. Tree walking callback for
	gnat_genericize.
	(convert_from_reference, is_byref_result): New functions. Helpers for
	gnat_genericize_r.
	(create_type_decl): Call gnat_pushdecl before calling
	rest_of_decl_compilation, to make sure that field TYPE_NAME of
	type_decl is properly set before calling the debug information writers.
	(write_record_type_debug_info): The heuristics which compute the
	alignment of a field in a variant record might not be accurate. Add a
	safety test to make sure no alignment is set to a smaller value than
	the alignment of the field type.
	(make_dummy_type): Use the Non_Limited_View as the underlying type if
	the type comes from a limited_with clause. Do not loop on the full view.
	(GET_GNU_TREE, SET_GNU_TREE, PRESENT_GNU_TREE): New macros.
	(dummy_node_table): New global variable, moved from decl.c.
	(GET_DUMMY_NODE, SET_DUMMY_NODE, PRESENT_DUMMY_NODE): New macros.
	(save_gnu_tree): Use above macros.
	(get_gnu_tree): Likewise.
	(present_gnu_tree): Likewise.
	(init_dummy_type): New function, moved from decl.c. Use above macros.
	(make_dummy_type): Likewise.
	(tree_code_for_record_type): New function extracted from make_dummy_type
	(init_gigi_decls): Set DECL_IS_MALLOC on gnat_malloc.
	(static_ctors): Change it to a vector, make static.
	(static_dtors): Likewise.
	(end_subprog_body): Adjust for above change.
	(build_global_cdtor): Moved from trans.c.
	(gnat_write_global_declarations): Emit global constructor and
	destructor, and call cgraph_optimize before emitting debug info for
	global declarations.
	(global_decls): New global variable.
	(gnat_pushdecl): Store the global declarations in global_decls, for
	later use.
	(gnat_write_global_declarations): Emit debug information for global
	 declarations.
	(create_var_decl_1): Former create_var_decl, with an extra argument to
	 state whether the creation of a CONST_DECL is allowed.
	(create_var_decl): Behavior unchanged. Now a wrapper around
	create_var_decl_1 allowing CONST_DECL creation.
	(create_true_var_decl): New function, similar to create_var_decl but
	forcing the creation of a VAR_DECL node (CONST_DECL not allowed).
	(create_field_decl): Do not always mark the field as addressable
	if its type is an aggregate.
	(global_renaming_pointers): New static variable.
	(add_global_renaming_pointer): New function.
	(get_global_renaming_pointers): Likewise.

	* misc.c (gnat_dwarf_name): New function.
	(LANG_HOOKS_DWARF_NAME): Define to gnat_dwarf_name.
	(gnat_post_options): Add comment about structural alias analysis.
	(gnat_parse_file): Do not call cgraph_optimize here.
	(LANG_HOOKS_WRITE_GLOBALS): Define to gnat_write_global_declarations.

	* trans.c (process_freeze_entity): Don't abort if we already have a
	non dummy GCC tree for a Concurrent_Record_Type, as it might
	legitimately have been elaborated while processing the associated
	Concurrent_Type prior to this explicit freeze node.
	(Identifier_to_gnu): Do not make a variable referenced in a SJLJ
	exception handler volatile if it is of variable size.
	(process_type): Remove bypass for types coming from a limited_with
	clause.
	(call_to_gnu): When processing the copy-out of a N_Type_Conversion GNAT
	actual, convert the corresponding gnu_actual to the real destination
	type when necessary.
	(add_decl_expr): Set the DECL_READONLY_ONCE_ELAB flag on variables
	originally TREE_READONLY but whose elaboration cannot be performed
	statically.
	Part of fix for F504-021.
	(tree_transform, subprogram cases): Change loops on formal parameters to
	call new Einfo function First_Formal_With_Extras.
	(gnat_to_gnu) <N_Op_Shift_Right_Arithmetic>: Ignore constant overflow
	stemming from type conversion for the lhs.
	(Attribute_to_gnu) <Attr_Alignment>: Also divide the alignment by the
	number of bits per unit for components of records.
	(gnat_to_gnu) <N_Code_Statement>: Mark operands addressable if needed.
	(Handled_Sequence_Of_Statements_to_gnu): Register the cleanup associated
	with At_End_Proc after the SJLJ EH cleanup.
	(Compilation_Unit_to_gnu): Call elaborate_all_entities only on the main
	compilation unit.
	(elaborate_all_entities): Do not retest type_annotate_only.
	(tree_transform) <N_Abstract_Subprogram_Declaration>: Process the
	result type of an abstract subprogram, which may be an itype associated
	with an anonymous access result (related to AI-318-02).
	(build_global_cdtor): Move to utils.c.
	(Case_Statement_to_gnu): Avoid adding the choice of a when statement if
	this choice is not a null tree nor an integer constant.
	(gigi): Run unshare_save_expr via walk_tree_without_duplicates
	on the body of elaboration routines instead of mark_unvisited.
	(add_stmt): Do not mark the tree.
	(add_decl_expr): Tweak comment.
	(mark_unvisited): Delete.
	(unshare_save_expr): New static function.
	(call_to_gnu): Issue an error when making a temporary around a
	procedure call because of non-addressable actual parameter if the
	type of the formal is by_reference.
	(Compilation_Unit_to_gnu): Invalidate the global renaming pointers
	after building the elaboration routine.

From-SVN: r118331
parent bfc8aa81
...@@ -232,6 +232,10 @@ struct lang_type GTY(()) {tree t; }; ...@@ -232,6 +232,10 @@ struct lang_type GTY(()) {tree t; };
discriminant. */ discriminant. */
#define DECL_STUBBED_P(NODE) DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE)) #define DECL_STUBBED_P(NODE) DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE))
/* Nonzero in a VAR_DECL if it is guaranteed to be constant after having
been elaborated and TREE_READONLY is not set on it. */
#define DECL_READONLY_ONCE_ELAB(NODE) DECL_LANG_FLAG_0 (VAR_DECL_CHECK (NODE))
/* Nonzero if this decl is always used by reference; i.e., an INDIRECT_REF /* Nonzero if this decl is always used by reference; i.e., an INDIRECT_REF
is needed to access the object. */ is needed to access the object. */
#define DECL_BY_REF_P(NODE) DECL_LANG_FLAG_1 (NODE) #define DECL_BY_REF_P(NODE) DECL_LANG_FLAG_1 (NODE)
......
...@@ -380,9 +380,6 @@ enum standard_datatypes ...@@ -380,9 +380,6 @@ enum standard_datatypes
extern GTY(()) tree gnat_std_decls[(int) ADT_LAST]; extern GTY(()) tree gnat_std_decls[(int) ADT_LAST];
extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1]; extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1];
extern GTY(()) tree static_ctors;
extern GTY(()) tree static_dtors;
#define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type] #define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type]
#define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl] #define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl]
#define except_type_node gnat_std_decls[(int) ADT_except_type] #define except_type_node gnat_std_decls[(int) ADT_except_type]
...@@ -448,6 +445,9 @@ extern tree gnat_type_for_size (unsigned precision, int unsignedp); ...@@ -448,6 +445,9 @@ extern tree gnat_type_for_size (unsigned precision, int unsignedp);
an unsigned type; otherwise a signed type is returned. */ an unsigned type; otherwise a signed type is returned. */
extern tree gnat_type_for_mode (enum machine_mode mode, int unsignedp); extern tree gnat_type_for_mode (enum machine_mode mode, int unsignedp);
/* Emit debug info for all global variable declarations. */
extern void gnat_write_global_declarations (void);
/* Return the unsigned version of a TYPE_NODE, a scalar type. */ /* Return the unsigned version of a TYPE_NODE, a scalar type. */
extern tree gnat_unsigned_type (tree type_node); extern tree gnat_unsigned_type (tree type_node);
...@@ -533,10 +533,11 @@ extern tree create_type_decl (tree type_name, tree type, ...@@ -533,10 +533,11 @@ extern tree create_type_decl (tree type_name, tree type,
bool artificial_p, bool debug_info_p, bool artificial_p, bool debug_info_p,
Node_Id gnat_node); Node_Id gnat_node);
/* Returns a GCC VAR_DECL node. VAR_NAME gives the name of the variable. /* Returns a GCC VAR_DECL or CONST_DECL node.
ASM_NAME is its assembler name (if provided). TYPE is
its data type (a GCC ..._TYPE node). VAR_INIT is the GCC tree for an VAR_NAME gives the name of the variable. ASM_NAME is its assembler name
optional initial expression; NULL_TREE if none. (if provided). TYPE is its data type (a GCC ..._TYPE node). VAR_INIT is
the GCC tree for an optional initial expression; NULL_TREE if none.
CONST_FLAG is true if this variable is constant. CONST_FLAG is true if this variable is constant.
...@@ -556,9 +557,22 @@ extern tree create_var_decl (tree var_name, tree asm_name, tree type, ...@@ -556,9 +557,22 @@ extern tree create_var_decl (tree var_name, tree asm_name, tree type,
bool static_flag, bool static_flag,
struct attrib *attr_list, Node_Id gnat_node); struct attrib *attr_list, Node_Id gnat_node);
/* Similar to create_var_decl, forcing the creation of a VAR_DECL node. */
extern tree create_true_var_decl (tree var_name, tree asm_name, tree type,
tree var_init, bool const_flag,
bool public_flag, bool extern_flag,
bool static_flag,
struct attrib *attr_list, Node_Id gnat_node);
/* Given a DECL and ATTR_LIST, apply the listed attributes. */ /* Given a DECL and ATTR_LIST, apply the listed attributes. */
extern void process_attributes (tree decl, struct attrib *attr_list); extern void process_attributes (tree decl, struct attrib *attr_list);
/* Record a global renaming pointer. */
void record_global_renaming_pointer (tree);
/* Invalidate the global renaming pointers. */
void invalidate_global_renaming_pointers (void);
/* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its /* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its
type, and RECORD_TYPE is the type of the parent. PACKED is nonzero if type, and RECORD_TYPE is the type of the parent. PACKED is nonzero if
this field is in a record type with a "pragma pack". If SIZE is nonzero this field is in a record type with a "pragma pack". If SIZE is nonzero
...@@ -656,6 +670,10 @@ extern tree maybe_unconstrained_array (tree exp); ...@@ -656,6 +670,10 @@ extern tree maybe_unconstrained_array (tree exp);
If NOTRUNC_P is true, truncation operations should be suppressed. */ If NOTRUNC_P is true, truncation operations should be suppressed. */
extern tree unchecked_convert (tree type, tree expr, bool notrunc_p); extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
/* Return the appropriate GCC tree code for the specified GNAT type,
the latter being a record type as predicated by Is_Record_Type. */
extern enum tree_code tree_code_for_record_type (Entity_Id);
/* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
operation. operation.
......
...@@ -127,6 +127,8 @@ static tree gnat_type_max_size (tree); ...@@ -127,6 +127,8 @@ static tree gnat_type_max_size (tree);
#define LANG_HOOKS_GETDECLS lhd_return_null_tree_v #define LANG_HOOKS_GETDECLS lhd_return_null_tree_v
#undef LANG_HOOKS_PUSHDECL #undef LANG_HOOKS_PUSHDECL
#define LANG_HOOKS_PUSHDECL lhd_return_tree #define LANG_HOOKS_PUSHDECL lhd_return_tree
#undef LANG_HOOKS_WRITE_GLOBALS
#define LANG_HOOKS_WRITE_GLOBALS gnat_write_global_declarations
#undef LANG_HOOKS_FINISH_INCOMPLETE_DECL #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
#define LANG_HOOKS_FINISH_INCOMPLETE_DECL gnat_finish_incomplete_decl #define LANG_HOOKS_FINISH_INCOMPLETE_DECL gnat_finish_incomplete_decl
#undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
...@@ -233,23 +235,22 @@ gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -233,23 +235,22 @@ gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
{ {
int seh[2]; int seh[2];
/* call the target specific initializations */ /* Call the target specific initializations. */
__gnat_initialize (NULL); __gnat_initialize (NULL);
/* ??? call the SEH initialization routine, this is to workaround a /* ??? Call the SEH initialization routine. This is to workaround
bootstrap path problem. The call below should be removed at some point and a bootstrap path problem. The call below should be removed at some
the seh pointer passed to __gnat_initialize() above. */ point and the SEH pointer passed to __gnat_initialize() above. */
__gnat_install_SEH_handler((void *)seh); __gnat_install_SEH_handler((void *)seh);
/* Call the front-end elaboration procedures */ /* Call the front-end elaboration procedures. */
adainit (); adainit ();
/* Call the front end */ /* Call the front end. */
_ada_gnat1drv (); _ada_gnat1drv ();
/* We always have a single compilation unit in Ada. */
cgraph_finalize_compilation_unit (); cgraph_finalize_compilation_unit ();
cgraph_optimize ();
} }
/* Decode all the language specific options that cannot be decoded by GCC. /* Decode all the language specific options that cannot be decoded by GCC.
...@@ -365,6 +366,9 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED) ...@@ -365,6 +366,9 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
if (flag_inline_functions) if (flag_inline_functions)
flag_inline_trees = 2; flag_inline_trees = 2;
/* The structural alias analysis machinery essentially assumes that
everything is addressable (modulo bit-fields) by disregarding
the TYPE_NONALIASED_COMPONENT and DECL_NONADDRESSABLE_P macros. */
flag_tree_salias = 0; flag_tree_salias = 0;
return false; return false;
...@@ -771,7 +775,7 @@ gnat_type_max_size (tree gnu_type) ...@@ -771,7 +775,7 @@ gnat_type_max_size (tree gnu_type)
&& TYPE_ADA_SIZE (gnu_type)) && TYPE_ADA_SIZE (gnu_type))
{ {
tree max_adasize = max_size (TYPE_ADA_SIZE (gnu_type), true); tree max_adasize = max_size (TYPE_ADA_SIZE (gnu_type), true);
/* If we have succeded in finding a constant, round it up to the /* If we have succeded in finding a constant, round it up to the
type's alignment and return the result in byte units. */ type's alignment and return the result in byte units. */
......
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