Makefile.in (c-lang.o): Depend on $(VARRAY_H).

* Makefile.in (c-lang.o): Depend on $(VARRAY_H).
* c-decl.c (c_expand_body): Take argument can_defer_p.  Use it
to decide whether to defer a function.
(finish_function): Adjust.
(c_expand_deferred_function): New function.
* c-lang.c (deferred_fns): New variable.
(c_init): Initialize it, and mark it as a root.
(defer_fn): New function.
(finish_file): Expand all deferred functions.
* c-tree.h (defer_fn): Declare.
(c_expand_deferred_function): Likewise.
* objc/Make-lang.in (objc-act.o): Depend on $(VARRAY_H).
* objc-act.c (deferred_fns): New variable.
(objc_init): Initialize it, and mark it as a root.
(defer_fn): New function.
(finish_file): Expand all deferred functions.

From-SVN: r46933
This commit is contained in:
Alexandre Oliva 2001-11-12 00:02:36 +00:00 committed by Alexandre Oliva
parent 950a3816a7
commit 8b0e9a7297
7 changed files with 108 additions and 8 deletions

View File

@ -1,3 +1,22 @@
2001-11-11 Alexandre Oliva <aoliva@redhat.com>
* Makefile.in (c-lang.o): Depend on $(VARRAY_H).
* c-decl.c (c_expand_body): Take argument can_defer_p. Use it
to decide whether to defer a function.
(finish_function): Adjust.
(c_expand_deferred_function): New function.
* c-lang.c (deferred_fns): New variable.
(c_init): Initialize it, and mark it as a root.
(defer_fn): New function.
(finish_file): Expand all deferred functions.
* c-tree.h (defer_fn): Declare.
(c_expand_deferred_function): Likewise.
* objc/Make-lang.in (objc-act.o): Depend on $(VARRAY_H).
* objc-act.c (deferred_fns): New variable.
(objc_init): Initialize it, and mark it as a root.
(defer_fn): New function.
(finish_file): Expand all deferred functions.
2001-11-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* alpha.c (unicosmk_special_name): Prototype.

View File

@ -1169,7 +1169,7 @@ c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) $(C_TREE_H) \
c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
$(TARGET_H) flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h $(TM_P_H)
c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
$(GGC_H) c-lex.h toplev.h diagnostic.h output.h function.h \
$(GGC_H) c-lex.h toplev.h diagnostic.h output.h function.h $(VARRAY_H) \
$(RTL_H) $(EXPR_H) tree-inline.h insn-config.h integrate.h langhooks.h \
langhooks-def.h
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) c-lex.h \

View File

@ -279,7 +279,7 @@ static tree grokdeclarator PARAMS ((tree, tree, enum decl_context,
static tree grokparms PARAMS ((tree, int));
static void layout_array_type PARAMS ((tree));
static tree c_make_fname_decl PARAMS ((tree, int));
static void c_expand_body PARAMS ((tree, int));
static void c_expand_body PARAMS ((tree, int, int));
/* C-specific option variables. */
@ -6748,7 +6748,7 @@ finish_function (nested)
if (! nested)
{
/* Generate RTL for the body of this function. */
c_expand_body (fndecl, nested);
c_expand_body (fndecl, nested, 1);
/* Let the error reporting routines know that we're outside a
function. For a nested function, this value is used in
pop_c_function_context and then reset via pop_function_context. */
@ -6756,14 +6756,25 @@ finish_function (nested)
}
}
/* Generate the RTL for a deferred function FNDECL. */
void
c_expand_deferred_function (fndecl)
tree fndecl;
{
c_expand_body (fndecl, 0, 0);
current_function_decl = NULL;
}
/* Generate the RTL for the body of FNDECL. If NESTED_P is non-zero,
then we are already in the process of generating RTL for another
function. */
function. If can_defer_p is zero, we won't attempt to defer the
generation of RTL. */
static void
c_expand_body (fndecl, nested_p)
c_expand_body (fndecl, nested_p, can_defer_p)
tree fndecl;
int nested_p;
int nested_p, can_defer_p;
{
int uninlinable = 1;
@ -6781,6 +6792,17 @@ c_expand_body (fndecl, nested_p)
function completely. */
uninlinable = ! tree_inlinable_function_p (fndecl);
if (! uninlinable && can_defer_p
/* Save function tree for inlining. Should return 0 if the
language does not support function deferring or the
function could not be deferred. */
&& defer_fn (fndecl))
{
/* Let the back-end know that this funtion exists. */
(*debug_hooks->deferred_inline_function) (fndecl);
return;
}
/* Then, inline any functions called in it. */
optimize_inline_calls (fndecl);
}
@ -7202,7 +7224,7 @@ c_expand_decl_stmt (t)
if (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_CONTEXT (decl) == current_function_decl
&& DECL_SAVED_TREE (decl))
c_expand_body (decl, /*nested_p=*/1);
c_expand_body (decl, /*nested_p=*/1, /*can_defer_p=*/0);
}
/* Return the IDENTIFIER_GLOBAL_VALUE of T, for use in common code, since

View File

@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "cpplib.h"
#include "insn-config.h"
#include "integrate.h"
#include "varray.h"
#include "langhooks.h"
#include "langhooks-def.h"
@ -79,6 +80,8 @@ static int c_cannot_inline_tree_fn PARAMS ((tree *));
/* Each front end provides its own. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
static varray_type deferred_fns;
/* Post-switch processing. */
static void
c_post_options ()
@ -136,6 +139,9 @@ c_init ()
lang_missing_noreturn_ok_p = &c_missing_noreturn_ok_p;
c_parse_init ();
VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
ggc_add_tree_varray_root (&deferred_fns, 1);
}
/* Used by c-lex.c, but only for objc. */
@ -242,11 +248,33 @@ finish_cdtor (body)
}
#endif
/* Register a function tree, so that its optimization and conversion
to RTL is only done at the end of the compilation. */
int
defer_fn (fn)
tree fn;
{
VARRAY_PUSH_TREE (deferred_fns, fn);
return 1;
}
/* Called at end of parsing, but before end-of-file processing. */
void
finish_file ()
{
int i;
for (i = 0; i < VARRAY_ACTIVE_SIZE (deferred_fns); i++)
/* Don't output the same function twice. We may run into such
situations when an extern inline function is later given a
non-extern-inline definition. */
if (! TREE_ASM_WRITTEN (VARRAY_TREE (deferred_fns, i)))
c_expand_deferred_function (VARRAY_TREE (deferred_fns, i));
VARRAY_FREE (deferred_fns);
#ifndef ASM_OUTPUT_CONSTRUCTOR
if (static_ctors)
{

View File

@ -152,6 +152,8 @@ extern int maybe_objc_comptypes PARAMS ((tree, tree, int));
extern tree maybe_building_objc_message_expr PARAMS ((void));
extern int recognize_objc_keyword PARAMS ((void));
extern tree lookup_objc_ivar PARAMS ((tree));
/* in c-lang.c and objc/objc-act.c */
extern int defer_fn PARAMS ((tree));
/* in c-parse.in */
extern void c_parse_init PARAMS ((void));
@ -219,6 +221,7 @@ extern tree start_struct PARAMS ((enum tree_code, tree));
extern void store_parm_decls PARAMS ((void));
extern tree xref_tag PARAMS ((enum tree_code, tree));
extern tree c_begin_compound_stmt PARAMS ((void));
extern void c_expand_deferred_function PARAMS ((tree));
extern void c_expand_decl_stmt PARAMS ((tree));
/* in c-typeck.c */

View File

@ -78,7 +78,7 @@ $(srcdir)/objc/objc-parse.y: $(srcdir)/c-parse.in
objc-act.o : $(srcdir)/objc/objc-act.c \
$(CONFIG_H) $(TREE_H) $(RTL_H) $(SYSTEM_H) $(EXPR_H) $(TARGET_H) \
$(srcdir)/c-tree.h $(srcdir)/c-common.h $(srcdir)/c-lex.h \
$(srcdir)/c-tree.h $(srcdir)/c-common.h $(srcdir)/c-lex.h $(VARRAY_H) \
$(srcdir)/toplev.h $(srcdir)/flags.h $(srcdir)/objc/objc-act.h \
$(srcdir)/input.h $(srcdir)/function.h $(srcdir)/output.h $(srcdir)/debug.h \
$(srcdir)/langhooks.h $(srcdir)/langhooks-def.h

View File

@ -58,6 +58,7 @@ Boston, MA 02111-1307, USA. */
#include "cpplib.h"
#include "debug.h"
#include "target.h"
#include "varray.h"
#include "langhooks.h"
#include "langhooks-def.h"
@ -469,6 +470,8 @@ static int print_struct_values = 0;
/* Each front end provides its own. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
static varray_type deferred_fns;
/* Post-switch processing. */
static void
objc_post_options ()
@ -593,11 +596,36 @@ objc_init ()
objc_act_parse_init ();
c_parse_init ();
VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
ggc_add_tree_varray_root (&deferred_fns, 1);
}
/* Register a function tree, so that its optimization and conversion
to RTL is only done at the end of the compilation. */
int
defer_fn (fn)
tree fn;
{
VARRAY_PUSH_TREE (deferred_fns, fn);
return 1;
}
void
finish_file ()
{
int i;
for (i = 0; i < VARRAY_ACTIVE_SIZE (deferred_fns); i++)
/* Don't output the same function twice. We may run into such
situations when an extern inline function is later given a
non-extern-inline definition. */
if (! TREE_ASM_WRITTEN (VARRAY_TREE (deferred_fns, i)))
c_expand_deferred_function (VARRAY_TREE (deferred_fns, i));
VARRAY_FREE (deferred_fns);
finish_objc (); /* Objective-C finalization */
if (gen_declaration_file)