* 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
+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.
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 \
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));
\f
/* C-specific option variables. */
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. */
}
}
+/* 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;
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);
}
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
#include "cpplib.h"
#include "insn-config.h"
#include "integrate.h"
+#include "varray.h"
#include "langhooks.h"
#include "langhooks-def.h"
/* 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 ()
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. */
}
#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)
{
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));
\f
/* in c-parse.in */
extern void c_parse_init PARAMS ((void));
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 */
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
#include "cpplib.h"
#include "debug.h"
#include "target.h"
+#include "varray.h"
#include "langhooks.h"
#include "langhooks-def.h"
/* 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 ()
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)