This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Tree inlining for the C front end (part 1 of 3)
On Oct 3, 2001, Richard Henderson <rth@redhat.com> wrote:
> On Wed, Oct 03, 2001 at 04:27:17AM -0300, Alexandre Oliva wrote:
>> I promise to start working on the additional patch as soon as the 4
>> patches go in, and having it tested and posted no later than the end
>> of this week, otherwise I will myself revert my current patch set. Deal?
> I wasn't requiring you to do this. But if you will anyway... ;-)
As promised, here's the patch that introduces langhooks.h and adjusts
the C and the C++ front ends to use the new mechanism to initialize
lang_hooks. The change is backward-compatible, so I didn't have to
touch other front-ends I'm not familiar with. I'd rather defer this
change to the maintainers of each front-end. If they don't act on it,
they'll probably just get a warning about the short initializer of
lang_hooks.
I ended up keeping the macros in tree-inline.h because I found
something like:
(lang_hooks.tree_inlining.a_relatively_long_name
? (*lang_hooks.tree_inlining.a_relatively_long_name)(args)
: 0)
quite ugly. I'm still unsure about moving the default of
LANG_AUTO_VAR_IN_FN_P to a function. For example, where would this
function be declared, so that langhooks.h could refer to it? And
where would it be defined, so that all languages to which it applies
get it? The underlying assumption of this alleged difficulty is that
I suppose the default macro is going to be good enough for most
languages. If this assumption is not true, I'll just move the default
definition of the macro to a function in the C front-end and be done
with it. Should I do this?
This was tested on athlon-pc-linux-gnu. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* langhooks.h: New file.
* Makefile.in (c-lang.o): Depend on langhooks.h.
(tree-inline.o): Depend on toplev.h.
(c-common.o): Don't depend on tree-inline.h.
* c-common.c: Likewise.
(c_mark_lang_decl): Mark argument c as unused.
(c_common_lang_init): Don't initialize hooks here.
* c-lang.c: Include langhooks.h, then override some macros.
(lang_hooks): Initialize with macros in langhooks.h.
(c_init): Don't initialize hooks here.
* toplev.c (struct lang_hooks_for_tree_inlining): New struct.
(struct lang_hooks): Add tree_inlining. Refer to langhooks.h.
* tree-inline.c: Include toplev.h. Don't define hook variables.
* tree-inline.h: Don't define hook types nor declare hook
variables. Adjust macros to use lang_hooks.
Index: gcc/cp/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* Make-lang.in (CXX_OBJS): Added cp-lang.o.
(cp/cp-lang.o): New rule.
* cp-tree.h: Declare hooks.
* tree.c: Make hooks non-static.
(init_tree): Don't initialize hooks here.
* lex.c: Likewise. Move definition of lang_hooks to...
* cp-lang.c: ... new file.
Index: gcc/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.747
diff -u -p -r1.747 Makefile.in
--- gcc/Makefile.in 2001/10/05 04:20:26 1.747
+++ gcc/Makefile.in 2001/10/05 06:18:53
@@ -1173,7 +1173,7 @@ c-typeck.o : c-typeck.c $(CONFIG_H) $(SY
$(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 \
- $(RTL_H) $(EXPR_H) tree-inline.h insn-config.h integrate.h
+ $(RTL_H) $(EXPR_H) tree-inline.h insn-config.h integrate.h langhooks.h
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) c-lex.h \
debug.h $(C_TREE_H) \
c-pragma.h input.h intl.h flags.h toplev.h output.h \
@@ -1249,8 +1249,7 @@ s-under: $(GCC_PASSES)
c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(OBSTACK_H) \
$(C_COMMON_H) flags.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
- $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def $(TARGET_H) \
- tree-inline.h
+ $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def $(TARGET_H)
# A file used by all variants of C and some other languages.
@@ -1353,7 +1352,7 @@ tree.o : tree.c $(CONFIG_H) $(SYSTEM_H)
$(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H)
tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) \
expr.h flags.h params.h input.h insn-config.h $(INTEGRATE_H) \
- $(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) \
+ $(VARRAY_H) $(HASHTAB_H) $(SPLAY_TREE_H) toplev.h \
$(C_COMMON_H) tree-inline.h
print-tree.o : print-tree.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(GGC_H)
stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h \
Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.c,v
retrieving revision 1.259
diff -u -p -r1.259 c-common.c
--- gcc/c-common.c 2001/10/05 02:49:15 1.259
+++ gcc/c-common.c 2001/10/05 06:18:54
@@ -22,7 +22,6 @@ Software Foundation, 59 Temple Place - S
#include "config.h"
#include "system.h"
#include "tree.h"
-#include "tree-inline.h"
#include "flags.h"
#include "toplev.h"
#include "output.h"
@@ -3330,7 +3329,7 @@ mark_stmt_tree (p)
void
c_mark_lang_decl (c)
- struct c_lang_decl *c;
+ struct c_lang_decl *c ATTRIBUTE_UNUSED;
{
}
@@ -3830,8 +3829,6 @@ c_common_lang_init ()
/* If still "unspecified", make it match -fbounded-pointers. */
if (flag_bounds_check < 0)
flag_bounds_check = flag_bounded_pointers;
-
- lang_anon_aggr_type_p = anon_aggr_type_p;
/* Special format checking options don't work without -Wformat; warn if
they are used. */
Index: gcc/c-lang.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lang.c,v
retrieving revision 1.55
diff -u -p -r1.55 c-lang.c
--- gcc/c-lang.c 2001/10/05 04:20:27 1.55
+++ gcc/c-lang.c 2001/10/05 06:18:54
@@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - S
#include "cpplib.h"
#include "insn-config.h"
#include "integrate.h"
+#include "langhooks.h"
static int c_tree_printer PARAMS ((output_buffer *));
static int c_missing_noreturn_ok_p PARAMS ((tree));
@@ -47,12 +48,26 @@ static void c_post_options PARAMS ((void
static int c_disregard_inline_limits PARAMS ((tree));
static int c_cannot_inline_tree_fn PARAMS ((tree *));
+#undef LANG_HOOKS_INIT
+#define LANG_HOOKS_INIT c_init
+#undef LANG_HOOKS_INIT_OPTIONS
+#define LANG_HOOKS_INIT_OPTIONS c_init_options
+#undef LANG_HOOKS_DECODE_OPTION
+#define LANG_HOOKS_DECODE_OPTION c_decode_option
+#undef LANG_HOOKS_POST_OPTIONS
+#define LANG_HOOKS_POST_OPTIONS c_post_options
+#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
+#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
+ c_cannot_inline_tree_fn
+#undef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS
+#define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \
+ c_disregard_inline_limits
+#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
+#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \
+ anon_aggr_type_p
+
/* Each front end provides its own. */
-struct lang_hooks lang_hooks = {c_init,
- NULL, /* c_finish */
- c_init_options,
- c_decode_option,
- c_post_options};
+struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
/* Post-switch processing. */
static void
@@ -112,8 +127,6 @@ c_init ()
diagnostic_format_decoder (global_dc) = &c_tree_printer;
lang_expand_decl_stmt = &c_expand_decl_stmt;
lang_missing_noreturn_ok_p = &c_missing_noreturn_ok_p;
- lang_disregard_inline_limits = &c_disregard_inline_limits;
- lang_cannot_inline_tree_fn = &c_cannot_inline_tree_fn;
c_parse_init ();
}
Index: gcc/langhooks.h
===================================================================
RCS file: langhooks.h
diff -N langhooks.h
--- /dev/null Tue May 5 13:32:27 1998
+++ gcc/langhooks.h Thu Oct 4 23:18:54 2001
@@ -0,0 +1,90 @@
+/* Macros to initialize the lang_hooks data structure.
+ Copyright 2001 Free Software Foundation, Inc.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifndef GCC_LANG_HOOKS_H
+#define GCC_LANG_HOOKS_H
+
+/* Older hooks, that don't go in sub-structures for backward
+ compatibility. */
+#ifndef LANG_HOOKS_INIT
+#define LANG_HOOKS_INIT NULL
+#endif
+#ifndef LANG_HOOKS_FINISH
+#define LANG_HOOKS_FINISH NULL
+#endif
+#ifndef LANG_HOOKS_INIT_OPTIONS
+#define LANG_HOOKS_INIT_OPTIONS NULL
+#endif
+#ifndef LANG_HOOKS_DECODE_OPTION
+#define LANG_HOOKS_DECODE_OPTION NULL
+#endif
+#ifndef LANG_HOOKS_POST_OPTIONS
+#define LANG_HOOKS_POST_OPTIONS NULL
+#endif
+
+/* Tree inlining hooks. */
+#ifndef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
+#define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES NULL
+#endif
+#ifndef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
+#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN NULL
+#endif
+#ifndef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS
+#define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS NULL
+#endif
+#ifndef LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS
+#define LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS NULL
+#endif
+#ifndef LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P
+#define LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P NULL
+#endif
+#ifndef LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P
+#define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P NULL
+#endif
+#ifndef LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING
+#define LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING NULL
+#endif
+#ifndef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
+#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P NULL
+#endif
+
+#define LANG_HOOKS_TREE_INLINING_INITIALIZER { \
+ LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \
+ LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN, \
+ LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS, \
+ LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS, \
+ LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P, \
+ LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P, \
+ LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING, \
+ LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \
+} \
+
+/* The whole thing. The structure is defined in toplev.h. */
+#define LANG_HOOKS_INITIALIZER { \
+ LANG_HOOKS_INIT, \
+ LANG_HOOKS_FINISH, \
+ LANG_HOOKS_INIT_OPTIONS, \
+ LANG_HOOKS_DECODE_OPTION, \
+ LANG_HOOKS_POST_OPTIONS, \
+ LANG_HOOKS_TREE_INLINING_INITIALIZER \
+}
+
+#endif /* GCC_LANG_HOOKS_H */
Index: gcc/toplev.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.h,v
retrieving revision 1.73
diff -u -p -r1.73 toplev.h
--- gcc/toplev.h 2001/09/24 00:27:31 1.73
+++ gcc/toplev.h 2001/10/05 06:18:54
@@ -115,7 +115,28 @@ extern void check_global_declarations
extern const char *progname;
extern const char *dump_base_name;
+/* The following hooks are documented in tree-inline.h. */
+
+struct lang_hooks_for_tree_inlining {
+ union tree_node *(*walk_subtrees) PARAMS ((union tree_node **, int *,
+ union tree_node *(*)
+ (union tree_node **,
+ int *, void *),
+ void *, void *));
+ int (*cannot_inline_tree_fn) PARAMS ((union tree_node **));
+ int (*disregard_inline_limits) PARAMS ((union tree_node *));
+ union tree_node *(*add_pending_fn_decls) PARAMS ((void*, union tree_node *));
+ int (*tree_chain_matters_p) PARAMS ((union tree_node *));
+ int (*auto_var_in_fn_p) PARAMS ((union tree_node *, union tree_node *));
+ union tree_node *(*copy_res_decl_for_inlining) PARAMS ((union tree_node *,
+ union tree_node *,
+ union tree_node *,
+ void*, int*, void*));
+ int (*anon_aggr_type_p) PARAMS ((union tree_node *));
+};
+
/* Language-specific hooks. Can be NULL unless otherwise specified. */
+
struct lang_hooks
{
/* Called first, to initialize the front end. */
@@ -141,6 +162,11 @@ struct lang_hooks
/* Called when all command line options have been processed. */
void (*post_options) PARAMS ((void));
+
+ struct lang_hooks_for_tree_inlining tree_inlining;
+
+ /* Whenever you add entries here, make sure you adjust langhooks.h
+ accordingly. */
};
/* Each front end provides its own. */
Index: gcc/tree-inline.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree-inline.c,v
retrieving revision 1.3
diff -u -p -r1.3 tree-inline.c
--- gcc/tree-inline.c 2001/10/05 04:20:27 1.3
+++ gcc/tree-inline.c 2001/10/05 06:18:54
@@ -21,6 +21,7 @@ Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
+#include "toplev.h"
#include "tree.h"
#include "tree-inline.h"
#include "rtl.h"
@@ -37,17 +38,6 @@ Boston, MA 02111-1307, USA. */
/* This should be eventually be generalized to other languages, but
this would require a shared function-as-trees infrastructure. */
#include "c-common.h"
-
-/* Definitions of language hooks. */
-
-treeopt_walk_subtrees_type *lang_walk_subtrees;
-treeopt_cannot_inline_tree_fn_type *lang_cannot_inline_tree_fn;
-treeopt_disregard_inline_limits_type *lang_disregard_inline_limits;
-treeopt_add_pending_fn_decls_type *lang_add_pending_fn_decls;
-treeopt_tree_chain_matters_p_type *lang_tree_chain_matters_p;
-treeopt_auto_var_in_fn_p_type *lang_auto_var_in_fn_p;
-treeopt_copy_res_decl_for_inlining_type *lang_copy_res_decl_for_inlining;
-treeopt_anon_aggr_type_p *lang_anon_aggr_type_p;
/* 0 if we should not perform inlining.
1 if we should expand functions calls inline at the tree level.
Index: gcc/tree-inline.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree-inline.h,v
retrieving revision 1.2
diff -u -p -r1.2 tree-inline.h
--- gcc/tree-inline.h 2001/10/05 04:20:27 1.2
+++ gcc/tree-inline.h 2001/10/05 06:18:54
@@ -44,28 +44,24 @@ void remap_save_expr PARAMS ((tree*, voi
when the function is called. */
#define LANG_WALK_SUBTREES(TP,SUBTREES,FUNC,DATA,HTAB) \
- (lang_walk_subtrees \
- ? (*lang_walk_subtrees)((TP),(SUBTREES),(FUNC),(DATA),(HTAB)) \
+ (lang_hooks.tree_inlining.walk_subtrees \
+ ? ((*lang_hooks.tree_inlining.walk_subtrees) \
+ ((TP),(SUBTREES),(FUNC),(DATA),(HTAB))) \
: 0)
-typedef tree treeopt_walk_subtrees_type PARAMS ((tree*, int*, walk_tree_fn,
- void*, void*));
-extern treeopt_walk_subtrees_type *lang_walk_subtrees;
/* LANG_CANNOT_INLINE_TREE_FN is called to determine whether there are
language-specific reasons for not inlining a given function. */
#define LANG_CANNOT_INLINE_TREE_FN(FNP) \
- (lang_cannot_inline_tree_fn ? (*lang_cannot_inline_tree_fn)(FNP) : 0)
-typedef int treeopt_cannot_inline_tree_fn_type PARAMS ((tree*));
-extern treeopt_cannot_inline_tree_fn_type *lang_cannot_inline_tree_fn;
+ (lang_hooks.tree_inlining.cannot_inline_tree_fn \
+ ? (*lang_hooks.tree_inlining.cannot_inline_tree_fn)(FNP) : 0)
/* LANG_DISREGARD_INLINE_LIMITS is called to determine whether a
function should be inlined even if it would exceed inlining limits. */
#define LANG_DISREGARD_INLINE_LIMITS(FN) \
- (lang_disregard_inline_limits ? (*lang_disregard_inline_limits)(FN) : 0)
-typedef int treeopt_disregard_inline_limits_type PARAMS ((tree));
-extern treeopt_disregard_inline_limits_type *lang_disregard_inline_limits;
+ (lang_hooks.tree_inlining.disregard_inline_limits \
+ ? (*lang_hooks.tree_inlining.disregard_inline_limits)(FN) : 0)
/* LANG_ADD_PENDING_FN_DECLS is called before starting to inline a
function, to push any language-specific functions that should not
@@ -74,33 +70,29 @@ extern treeopt_disregard_inline_limits_t
VAFNP. The top of the varray should be returned. */
#define LANG_ADD_PENDING_FN_DECLS(VAFNP,PFN) \
- (lang_add_pending_fn_decls \
- ? (*lang_add_pending_fn_decls)((VAFNP),(PFN)) \
+ (lang_hooks.tree_inlining.add_pending_fn_decls \
+ ? (*lang_hooks.tree_inlining.add_pending_fn_decls)((VAFNP),(PFN)) \
: (PFN))
-typedef tree treeopt_add_pending_fn_decls_type PARAMS ((void*,tree));
-extern treeopt_add_pending_fn_decls_type *lang_add_pending_fn_decls;
/* LANG_TREE_CHAIN_MATTERS_P indicates whether the TREE_CHAIN of a
language-specific tree node is relevant, i.e., whether it should be
walked, copied and preserved across copies. */
#define LANG_TREE_CHAIN_MATTERS_P(T) \
- (lang_tree_chain_matters_p ? (*lang_tree_chain_matters_p)(T) : 0)
-typedef int treeopt_tree_chain_matters_p_type PARAMS ((tree));
-extern treeopt_tree_chain_matters_p_type *lang_tree_chain_matters_p;
+ (lang_hooks.tree_inlining.tree_chain_matters_p \
+ ? (*lang_hooks.tree_inlining.tree_chain_matters_p)(T) : 0)
/* LANG_AUTO_VAR_IN_FN_P is called to determine whether VT is an
automatic variable defined in function FT. */
#define LANG_AUTO_VAR_IN_FN_P(VT,FT) \
- (lang_auto_var_in_fn_p ? (*lang_auto_var_in_fn_p)((VT),(FT)) \
+ (lang_hooks.tree_inlining.auto_var_in_fn_p \
+ ? (*lang_hooks.tree_inlining.auto_var_in_fn_p)((VT),(FT)) \
: (DECL_P (VT) && DECL_CONTEXT (VT) == (FT) \
&& (((TREE_CODE (VT) == VAR_DECL || TREE_CODE (VT) == PARM_DECL) \
&& ! TREE_STATIC (VT)) \
|| TREE_CODE (VT) == LABEL_DECL \
|| TREE_CODE (VT) == RESULT_DECL)))
-typedef int treeopt_auto_var_in_fn_p_type PARAMS ((tree,tree));
-extern treeopt_auto_var_in_fn_p_type *lang_auto_var_in_fn_p;
/* LANG_COPY_RES_DECL_FOR_INLINING should return a declaration for the
result RES of function FN to be inlined into CALLER. NDP points to
@@ -111,24 +103,18 @@ extern treeopt_auto_var_in_fn_p_type *la
into caller; the top of TEXPS is supposed to match RES. */
#define LANG_COPY_RES_DECL_FOR_INLINING(RES,FN,CALLER,DM,NDP,TEXPS) \
- (lang_copy_res_decl_for_inlining \
- ? (*lang_copy_res_decl_for_inlining)((RES),(FN),(CALLER),\
- (DM),(NDP),(TEXPS)) \
+ (lang_hooks.tree_inlining.copy_res_decl_for_inlining \
+ ? ((*lang_hooks.tree_inlining.copy_res_decl_for_inlining) \
+ ((RES),(FN),(CALLER),(DM),(NDP),(TEXPS))) \
: copy_decl_for_inlining ((RES), (FN), (CALLER)))
-typedef tree treeopt_copy_res_decl_for_inlining_type PARAMS ((tree, tree,
- tree, void*,
- int*, void*));
-extern treeopt_copy_res_decl_for_inlining_type
-*lang_copy_res_decl_for_inlining;
/* LANG_ANON_AGGR_TYPE_P determines whether T is a type node
representing an anonymous aggregate (union, struct, etc), i.e., one
whose members are in the same scope as the union itself. */
#define LANG_ANON_AGGR_TYPE_P(T) \
- (lang_anon_aggr_type_p ? (*lang_anon_aggr_type_p)(T) : 0)
-typedef int treeopt_anon_aggr_type_p PARAMS ((tree));
-extern treeopt_anon_aggr_type_p *lang_anon_aggr_type_p;
+ (lang_hooks.tree_inlining.anon_aggr_type_p \
+ ? (*lang_hooks.tree_inlining.anon_aggr_type_p)(T) : 0)
/* 0 if we should not perform inlining.
1 if we should expand functions calls inline at the tree level.
Index: gcc/cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/Make-lang.in,v
retrieving revision 1.93
diff -u -p -r1.93 Make-lang.in
--- gcc/cp/Make-lang.in 2001/10/05 02:48:44 1.93
+++ gcc/cp/Make-lang.in 2001/10/05 06:18:54
@@ -101,7 +101,7 @@ CXX_OBJS = cp/call.o cp/decl.o cp/expr.o
cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parse.o cp/ptree.o cp/rtti.o \
cp/spew.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
cp/search.o cp/semantics.o cp/tree.o cp/xref.o cp/repo.o cp/dump.o \
- cp/optimize.o cp/mangle.o
+ cp/optimize.o cp/mangle.o cp/cp-lang.o
# Use loose warnings for this front end.
cp-warn =
@@ -241,6 +241,7 @@ cp/spew.o: cp/spew.c $(CXX_TREE_H) cp/pa
cp/lex.o: cp/lex.c $(CXX_TREE_H) cp/parse.h flags.h cp/lex.h c-pragma.h \
toplev.h output.h mbchar.h $(GGC_H) input.h diagnostic.h cp/operators.def \
$(TM_P_H)
+cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) toplev.h langhooks.h
cp/decl.o: cp/decl.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h stack.h \
output.h $(EXPR_H) except.h toplev.h hash.h $(GGC_H) $(RTL_H) \
cp/operators.def $(TM_P_H) tree-inline.h
Index: gcc/cp/cp-lang.c
===================================================================
RCS file: cp-lang.c
diff -N cp-lang.c
--- /dev/null Tue May 5 13:32:27 1998
+++ gcc/cp/cp-lang.c Thu Oct 4 23:18:54 2001
@@ -0,0 +1,62 @@
+/* Language-dependent hooks for C++.
+ Copyright 2001 Free Software Foundation, Inc.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+#include "system.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "toplev.h"
+#include "langhooks.h"
+
+#undef LANG_HOOKS_INIT
+#define LANG_HOOKS_INIT cxx_init
+#undef LANG_HOOKS_FINISH
+#define LANG_HOOKS_FINISH cxx_finish
+#undef LANG_HOOKS_INIT_OPTIONS
+#define LANG_HOOKS_INIT_OPTIONS cxx_init_options
+#undef LANG_HOOKS_DECODE_OPTION
+#define LANG_HOOKS_DECODE_OPTION cxx_decode_option
+#undef LANG_HOOKS_POST_OPTIONS
+#define LANG_HOOKS_POST_OPTIONS cxx_post_options
+
+#undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
+#define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES \
+ cp_walk_subtrees
+#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
+#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
+ cp_cannot_inline_tree_fn
+#undef LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS
+#define LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS \
+ cp_add_pending_fn_decls
+#undef LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P
+#define LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P \
+ cp_is_overload_p
+#undef LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P
+#define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P \
+ cp_auto_var_in_fn_p
+#undef LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING
+#define LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING \
+ cp_copy_res_decl_for_inlining
+#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
+#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P anon_aggr_type_p
+
+/* Each front end provides its own hooks, for toplev.c. */
+struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
Index: gcc/cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.645
diff -u -p -r1.645 cp-tree.h
--- gcc/cp/cp-tree.h 2001/10/05 02:48:44 1.645
+++ gcc/cp/cp-tree.h 2001/10/05 06:18:54
@@ -3867,6 +3867,10 @@ extern void yyerror PARAMS ((const ch
extern void clear_inline_text_obstack PARAMS ((void));
extern void yyhook PARAMS ((int));
extern int cp_type_qual_from_rid PARAMS ((tree));
+extern void cxx_init PARAMS ((void));
+extern void cxx_finish PARAMS ((void));
+extern void cxx_init_options PARAMS ((void));
+extern void cxx_post_options PARAMS ((void));
/* in method.c */
extern void init_method PARAMS ((void));
@@ -4190,6 +4194,14 @@ extern int char_type_p
extern void verify_stmt_tree PARAMS ((tree));
extern tree find_tree PARAMS ((tree, tree));
extern linkage_kind decl_linkage PARAMS ((tree));
+extern tree cp_walk_subtrees PARAMS ((tree*, int*, walk_tree_fn,
+ void*, void*));
+extern int cp_cannot_inline_tree_fn PARAMS ((tree*));
+extern tree cp_add_pending_fn_decls PARAMS ((void*,tree));
+extern int cp_is_overload_p PARAMS ((tree));
+extern int cp_auto_var_in_fn_p PARAMS ((tree,tree));
+extern tree cp_copy_res_decl_for_inlining PARAMS ((tree, tree, tree, void*,
+ int*, void*));
/* in typeck.c */
extern int string_conv_p PARAMS ((tree, tree, int));
Index: gcc/cp/lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.248
diff -u -p -r1.248 lex.c
--- gcc/cp/lex.c 2001/09/12 16:25:07 1.248
+++ gcc/cp/lex.c 2001/10/05 06:18:55
@@ -62,10 +62,6 @@ static void handle_pragma_unit PARAMS ((
static void handle_pragma_interface PARAMS ((cpp_reader *));
static void handle_pragma_implementation PARAMS ((cpp_reader *));
static void handle_pragma_java_exceptions PARAMS ((cpp_reader *));
-static void cxx_init PARAMS ((void));
-static void cxx_finish PARAMS ((void));
-static void cxx_init_options PARAMS ((void));
-static void cxx_post_options PARAMS ((void));
#ifdef GATHER_STATISTICS
#ifdef REDUCE_LENGTH
@@ -241,21 +237,14 @@ static const char *const cplus_tree_code
};
#undef DEFTREECODE
-/* Each front end provides its own hooks, for toplev.c. */
-struct lang_hooks lang_hooks = {cxx_init,
- cxx_finish,
- cxx_init_options,
- cxx_decode_option,
- cxx_post_options};
-
/* Post-switch processing. */
-static void
+void
cxx_post_options ()
{
cpp_post_options (parse_in);
}
-static void
+void
cxx_init_options ()
{
/* Make identifier nodes long enough for the language-specific slots. */
@@ -275,7 +264,7 @@ cxx_init_options ()
diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
}
-static void
+void
cxx_init ()
{
c_common_lang_init ();
@@ -284,10 +273,11 @@ cxx_init ()
init_repo (input_filename);
}
-static void
+void
cxx_finish ()
{
- if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount);
+ if (flag_gnu_xref)
+ GNU_xref_end (errorcount+sorrycount);
}
const char *
Index: gcc/cp/tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tree.c,v
retrieving revision 1.255
diff -u -p -r1.255 tree.c
--- gcc/cp/tree.c 2001/10/05 03:47:57 1.255
+++ gcc/cp/tree.c 2001/10/05 06:18:56
@@ -50,12 +50,6 @@ static tree count_trees_r PARAMS ((tree
static tree verify_stmt_tree_r PARAMS ((tree *, int *, void *));
static tree find_tree_r PARAMS ((tree *, int *, void *));
extern int cp_statement_code_p PARAMS ((enum tree_code));
-static treeopt_walk_subtrees_type cp_walk_subtrees;
-static treeopt_cannot_inline_tree_fn_type cp_cannot_inline_tree_fn;
-static treeopt_add_pending_fn_decls_type cp_add_pending_fn_decls;
-static treeopt_tree_chain_matters_p_type cp_is_overload_p;
-static treeopt_auto_var_in_fn_p_type cp_auto_var_in_fn_p;
-static treeopt_copy_res_decl_for_inlining_type cp_copy_res_decl_for_inlining;
static tree handle_java_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
static tree handle_com_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
@@ -2058,7 +2052,7 @@ make_ptrmem_cst (type, member)
/* Apply FUNC to all language-specific sub-trees of TP in a pre-order
traversal. Called from walk_tree(). */
-static tree
+tree
cp_walk_subtrees (tp, walk_subtrees_p, func, data, htab)
tree *tp;
int *walk_subtrees_p;
@@ -2129,7 +2123,7 @@ cp_walk_subtrees (tp, walk_subtrees_p, f
/* Decide whether there are language-specific reasons to not inline a
function as a tree. */
-static int
+int
cp_cannot_inline_tree_fn (fnp)
tree *fnp;
{
@@ -2163,7 +2157,7 @@ cp_cannot_inline_tree_fn (fnp)
handled by the caller), that thus cannot be inlined, to FNS_P, then
return the latest function added to the array, PREV_FN. */
-static tree
+tree
cp_add_pending_fn_decls (fns_p, prev_fn)
void *fns_p;
tree prev_fn;
@@ -2185,7 +2179,7 @@ cp_add_pending_fn_decls (fns_p, prev_fn)
whether to copy a node or to preserve its chain when inlining a
function. */
-static int
+int
cp_is_overload_p (t)
tree t;
{
@@ -2195,7 +2189,7 @@ cp_is_overload_p (t)
/* Determine whether VAR is a declaration of an automatic variable in
function FN. */
-static int
+int
cp_auto_var_in_fn_p (var, fn)
tree var, fn;
{
@@ -2207,7 +2201,7 @@ cp_auto_var_in_fn_p (var, fn)
FN being inlined into CALLER or if the top node of target_exprs is
to be used. */
-static tree
+tree
cp_copy_res_decl_for_inlining (result, fn, caller, decl_map_,
need_decl, target_exprs)
tree result, fn, caller;
@@ -2270,12 +2264,6 @@ void
init_tree ()
{
make_lang_type_fn = cp_make_lang_type;
- lang_walk_subtrees = cp_walk_subtrees;
- lang_cannot_inline_tree_fn = cp_cannot_inline_tree_fn;
- lang_add_pending_fn_decls = cp_add_pending_fn_decls;
- lang_tree_chain_matters_p = cp_is_overload_p;
- lang_auto_var_in_fn_p = cp_auto_var_in_fn_p;
- lang_copy_res_decl_for_inlining = cp_copy_res_decl_for_inlining;
lang_unsave = cp_unsave;
lang_statement_code_p = cp_statement_code_p;
lang_set_decl_assembler_name = mangle_decl;
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me