Commit a8f73d4b by Mark Mitchell Committed by Mark Mitchell

Reorganize per-function data.

	* cp-tree.h (saved_scope): Add function_decl, bindings.
	(language_function): Rename binding_level to bindings.
	(cp_function_chain): Use the current_function, not the
	outer_function_chain.
	(current_class_ptr): Make it work, even when there's no
	current function.
	(current_class_ref): Likewise.
	(SF_DEFAULT, SF_PRE_PARSED, SF_INCLASS_INLINE, SF_EXPAND): New
	macros.
	(clear_temp_name): Remove.
	* decl.c (check_function_type): New function, broken out from
	start_function.
	(current_binding_level): Adjust definition.
	(pushlevel): Simplify.
	(poplevel): Don't use named_label_uses when we're outside
	a function scope.
	(mark_saved_scope): Mark function_decl and bindings.
	(maybe_push_to_top_level): Don't unconditionally push a new
	function context.  Save bindings and the current_function_decl.
	Don't clear named_labels.
	(pop_from_top_level): Pop function context if appropriate.
	(init_decl_processing): Set init_lang_status and free_lang_status,
	rather than save_lang_status and restore_lang_status.
	(start_function): Take SF_* flags.  Don't clear per-function data.
	Reorder and simplify to use new per-function data code.  Add
	asserts.
	(store_parm_decls): Don't call init_function_start here.
	(finish_function): Adjust for new handling of per-function data.
	(push_cp_function_context): Simplify.
	(mark_cp_function_context): Change binding_level to bindings.
	* decl2.c (clear_temp_name): Remove.
	(start_objects): Use SF flags to start_function.
	(start_static_storage_duration_function): Likewise.
	* except.c (start_anon_func): Remove redundant calls to
	push_function_context_to.  Use SF flags to start function.
	(end_anon_func): Remove redundant call to pop_function_context
	from.
	* lex.c (reinit_parse_for_function): Don't initialize per-function
	data.
	* method.c (emit_thunk): Clear current_function after calling
	assemble_end_function.  Use SF flags for start_function.
	(synthesize_method): Use SF flags for start_function.
	* parse.c: Regenerated.
	* parse.y (fn.defpen): Likewise.
	(pending_inline): Clear current_function, even if something goes
	wrong.
	* pt.c (instantiate_decl): Use SF flags to start_function.
	Don't save and restore expanding_p.
	(add_tree): Handle the case where we are outside any function.
	(end_tree): Likewise.
	* rtti.c (sythesize_tinfo_fn): Use SF flags to start_function.
	* semantics.c (begin_function_definition): Likewise.
	(expand_body): Likewise.

From-SVN: r29240
parent 0a8a198c
1999-09-09 Mark Mitchell <mark@codesourcery.com>
Reorganize per-function data.
* cp-tree.h (saved_scope): Add function_decl, bindings.
(language_function): Rename binding_level to bindings.
(cp_function_chain): Use the current_function, not the
outer_function_chain.
(current_class_ptr): Make it work, even when there's no
current function.
(current_class_ref): Likewise.
(SF_DEFAULT, SF_PRE_PARSED, SF_INCLASS_INLINE, SF_EXPAND): New
macros.
(clear_temp_name): Remove.
* decl.c (check_function_type): New function, broken out from
start_function.
(current_binding_level): Adjust definition.
(pushlevel): Simplify.
(poplevel): Don't use named_label_uses when we're outside
a function scope.
(mark_saved_scope): Mark function_decl and bindings.
(maybe_push_to_top_level): Don't unconditionally push a new
function context. Save bindings and the current_function_decl.
Don't clear named_labels.
(pop_from_top_level): Pop function context if appropriate.
(init_decl_processing): Set init_lang_status and free_lang_status,
rather than save_lang_status and restore_lang_status.
(start_function): Take SF_* flags. Don't clear per-function data.
Reorder and simplify to use new per-function data code. Add
asserts.
(store_parm_decls): Don't call init_function_start here.
(finish_function): Adjust for new handling of per-function data.
(push_cp_function_context): Simplify.
(mark_cp_function_context): Change binding_level to bindings.
* decl2.c (clear_temp_name): Remove.
(start_objects): Use SF flags to start_function.
(start_static_storage_duration_function): Likewise.
* except.c (start_anon_func): Remove redundant calls to
push_function_context_to. Use SF flags to start function.
(end_anon_func): Remove redundant call to pop_function_context
from.
* lex.c (reinit_parse_for_function): Don't initialize per-function
data.
* method.c (emit_thunk): Clear current_function after calling
assemble_end_function. Use SF flags for start_function.
(synthesize_method): Use SF flags for start_function.
* parse.c: Regenerated.
* parse.y (fn.defpen): Likewise.
(pending_inline): Clear current_function, even if something goes
wrong.
* pt.c (instantiate_decl): Use SF flags to start_function.
Don't save and restore expanding_p.
(add_tree): Handle the case where we are outside any function.
(end_tree): Likewise.
* rtti.c (sythesize_tinfo_fn): Use SF flags to start_function.
* semantics.c (begin_function_definition): Likewise.
(expand_body): Likewise.
1999-09-09 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (convert_to_void): Prototype new function.
......
......@@ -525,6 +525,7 @@ struct saved_scope {
tree class_name;
tree class_type;
tree access_specifier;
tree function_decl;
varray_type lang_base;
tree *lang_stack;
tree lang_name;
......@@ -536,10 +537,12 @@ struct saved_scope {
HOST_WIDE_INT x_processing_template_decl;
int x_processing_specialization;
int x_processing_explicit_instantiation;
int need_pop_function_context;
char *firstobj;
struct binding_level *class_bindings;
struct binding_level *bindings;
struct saved_scope *prev;
};
......@@ -627,12 +630,12 @@ struct language_function
int stmts_are_full_exprs_p;
struct named_label_list *named_label_uses;
struct binding_level *binding_level;
struct binding_level *bindings;
};
/* The current C++-specific per-function global variables. */
#define cp_function_chain (outer_function_chain->language)
#define cp_function_chain (current_function->language)
/* In a destructor, the point at which all derived class destroying
has been done, just before any base class destroying will be done. */
......@@ -665,8 +668,10 @@ struct language_function
PARM_DECL for the `this' pointer. The current_class_ref is an
expression for `*this'. */
#define current_class_ptr cp_function_chain->x_current_class_ptr
#define current_class_ref cp_function_chain->x_current_class_ref
#define current_class_ptr \
(current_function ? cp_function_chain->x_current_class_ptr : NULL_TREE)
#define current_class_ref \
(current_function ? cp_function_chain->x_current_class_ref : NULL_TREE)
/* When building a statement-tree, this is the last node added to the
tree. */
......@@ -2942,6 +2947,18 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
#define PUSH_USING 2 /* We are pushing this DECL as the
result of a using declaration. */
/* Used with start function. */
#define SF_DEFAULT SF_EXPAND
/* No flags. Temporarily, this is
SF_EXPAND. Once we are fully
function-at-a-time, this will be
0. */
#define SF_PRE_PARSED 1 /* The function declaration has
already been parsed. */
#define SF_INCLASS_INLINE 2 /* The function is an inline, defined
in the class body. */
#define SF_EXPAND 4 /* Generate RTL for this function. */
/* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
sense of `same'. */
#define same_type_p(type1, type2) \
......@@ -3226,7 +3243,6 @@ extern tree constructor_name_full PROTO((tree));
extern tree constructor_name PROTO((tree));
extern void setup_vtbl_ptr PROTO((void));
extern void mark_inline_for_output PROTO((tree));
extern void clear_temp_name PROTO((void));
extern tree get_temp_name PROTO((tree, int));
extern void finish_anon_union PROTO((tree));
extern tree finish_table PROTO((tree, tree, tree, int));
......
......@@ -2018,12 +2018,6 @@ mark_inline_for_output (decl)
++saved_inlines_used;
}
void
clear_temp_name ()
{
temp_name_counter = 0;
}
/* Hand off a unique name which can be used for variable we don't really
want to know about anyway, for example, the anonymous variables which
are needed to make references work. Declare this thing so we can use it.
......@@ -2825,7 +2819,7 @@ start_objects (method_type, initp)
start_function (void_list_node,
make_call_declarator (fnname, void_list_node, NULL_TREE,
NULL_TREE),
NULL_TREE, 0);
NULL_TREE, SF_DEFAULT);
#if defined(ASM_OUTPUT_CONSTRUCTOR) && defined(ASM_OUTPUT_DESTRUCTOR)
/* It can be a static function as long as collect2 does not have
......@@ -3014,7 +3008,7 @@ start_static_storage_duration_function ()
start_function (/*specs=*/NULL_TREE,
ssdf_decl,
/*attrs=*/NULL_TREE,
/*pre_parsed_p=*/1);
SF_DEFAULT | SF_PRE_PARSED);
/* Set up the scope of the outermost block in the function. */
store_parm_decls ();
......
......@@ -801,7 +801,6 @@ start_anon_func ()
tree params;
tree t;
push_function_context_to (NULL_TREE);
push_to_top_level ();
/* No need to mangle this. */
......@@ -816,7 +815,7 @@ start_anon_func ()
NULL_TREE);
start_function (decl_tree_cons (NULL_TREE, get_identifier ("static"),
void_list_node),
t, NULL_TREE, 0);
t, NULL_TREE, SF_DEFAULT);
store_parm_decls ();
pushlevel (0);
clear_last_expr ();
......@@ -841,7 +840,6 @@ end_anon_func ()
finish_function (lineno, 0);
pop_from_top_level ();
pop_function_context_from (NULL_TREE);
}
/* Return a pointer to a buffer for an exception object of type TYPE. */
......
......@@ -1549,8 +1549,6 @@ reinit_parse_for_method (yychar, decl)
reinit_parse_for_block (yychar, &inline_text_obstack);
len = obstack_object_size (&inline_text_obstack);
current_base_init_list = NULL_TREE;
current_member_init_list = NULL_TREE;
if (decl == void_type_node
|| (current_class_type && TYPE_REDEFINED (current_class_type)))
{
......
......@@ -2104,6 +2104,7 @@ emit_thunk (thunk_fndecl)
assemble_end_function (thunk_fndecl, fnname);
permanent_allocation (1);
current_function_decl = 0;
current_function = 0;
#else /* ASM_OUTPUT_MI_THUNK */
/* If we don't have the necessary macro for efficient thunks, generate a
thunk function that just makes a call to the real function.
......@@ -2132,7 +2133,8 @@ emit_thunk (thunk_fndecl)
DECL_INTERFACE_KNOWN (thunk_fndecl) = 1;
DECL_NOT_REALLY_EXTERN (thunk_fndecl) = 1;
start_function (NULL_TREE, thunk_fndecl, NULL_TREE, 1);
start_function (NULL_TREE, thunk_fndecl, NULL_TREE,
SF_DEFAULT | SF_PRE_PARSED);
store_parm_decls ();
current_function_is_thunk = 1;
......@@ -2363,7 +2365,7 @@ synthesize_method (fndecl)
push_function_context_to (context);
interface_unknown = 1;
start_function (NULL_TREE, fndecl, NULL_TREE, 1);
start_function (NULL_TREE, fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
store_parm_decls ();
clear_last_expr ();
......
......@@ -2064,7 +2064,9 @@ initlist:
fn.defpen:
PRE_PARSED_FUNCTION_DECL
{ start_function (NULL_TREE, $1->fndecl, NULL_TREE, 2);
{ start_function (NULL_TREE, $1->fndecl, NULL_TREE,
(SF_DEFAULT | SF_PRE_PARSED
| SF_INCLASS_INLINE));
reinit_parse_for_function (); }
pending_inline:
......@@ -2079,7 +2081,9 @@ pending_inline:
process_next_inline ($1);
}
| fn.defpen maybe_return_init error
{ process_next_inline ($1); }
{ free_after_compilation (current_function);
current_function = NULL;
process_next_inline ($1); }
;
pending_inlines:
......
......@@ -9683,13 +9683,9 @@ instantiate_decl (d)
{
extern struct obstack *saveable_obstack;
extern struct obstack *rtl_obstack;
int saved_expanding_p = expanding_p;
/* We're not expanding all the way to RTL here. */
expanding_p = 0;
/* Set up context. */
start_function (NULL_TREE, d, NULL_TREE, 1);
start_function (NULL_TREE, d, NULL_TREE, SF_PRE_PARSED);
store_parm_decls ();
/* Anything we might
......@@ -9710,7 +9706,6 @@ instantiate_decl (d)
/* Clean up. */
pop_obstacks ();
finish_function (lineno, 0);
expanding_p = saved_expanding_p;
/* Now, generate RTL for the function. */
expand_body (d);
......@@ -9869,8 +9864,13 @@ add_tree (t)
void
begin_tree ()
{
saved_trees = tree_cons (NULL_TREE, last_tree, saved_trees);
last_tree = NULL_TREE;
if (current_function)
{
saved_trees = tree_cons (NULL_TREE, last_tree, saved_trees);
last_tree = NULL_TREE;
}
else
saved_trees = tree_cons (NULL_TREE, NULL_TREE, saved_trees);
}
......@@ -9879,7 +9879,8 @@ end_tree ()
{
my_friendly_assert (saved_trees != NULL_TREE, 0);
last_tree = TREE_VALUE (saved_trees);
if (current_function)
last_tree = TREE_VALUE (saved_trees);
saved_trees = TREE_CHAIN (saved_trees);
}
......
......@@ -1120,7 +1120,8 @@ synthesize_tinfo_fn (fndecl)
DECL_ALIGN (tdecl) = TYPE_ALIGN (ptr_type_node);
cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
start_function (NULL_TREE, fndecl, NULL_TREE, 1);
start_function (NULL_TREE, fndecl, NULL_TREE,
SF_DEFAULT | SF_PRE_PARSED);
store_parm_decls ();
clear_last_expr ();
push_momentary ();
......
......@@ -1394,7 +1394,7 @@ begin_function_definition (decl_specs, declarator)
tree specs;
tree attrs;
split_specs_attrs (decl_specs, &specs, &attrs);
if (!start_function (specs, declarator, attrs, 0))
if (!start_function (specs, declarator, attrs, SF_DEFAULT))
return 0;
reinit_parse_for_function ();
......@@ -2182,16 +2182,10 @@ void
expand_body (fn)
tree fn;
{
int saved_expanding_p;
tree t;
tree try_block;
/* Let the compiler know that now is the time to really generate
actualy RTL. */
saved_expanding_p = expanding_p;
expanding_p = 1;
start_function (NULL_TREE, fn, NULL_TREE, 1);
start_function (NULL_TREE, fn, NULL_TREE, SF_PRE_PARSED | SF_EXPAND);
store_parm_decls ();
/* There are a few things that we do not handle recursively. For
......@@ -2242,7 +2236,4 @@ expand_body (fn)
}
finish_function (lineno, 0);
/* Restore EXPANDING_P. */
expanding_p = saved_expanding_p;
}
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