summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-05 02:49:16 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-05 02:49:16 +0000
commit1431bff66dcbda6e40f7b502fa82c7eae209ed2c (patch)
tree2f6c9d765b33ae23a613a61116ed9e165f3ee6d9
parent1e3b023ca8a1e3c71fbc30d4bb9b84cd1623903d (diff)
downloadppe42-gcc-1431bff66dcbda6e40f7b502fa82c7eae209ed2c.tar.gz
ppe42-gcc-1431bff66dcbda6e40f7b502fa82c7eae209ed2c.zip
* Makefile.in (OBJS): Added tree-inline.o.
(c-common.o): Depend on tree-inline.h. (tree-inline.o): New target. * c-common.c: Include tree-inline.h. (c_mark_lang_decl): Don't mark saved_tree. (c_common_lang_init): Set lang_anon_aggr_type_p. * c-common.h (walk_tree_fn, DECL_SAVED_TREE): Moved to tree.h. (struct c_lang_decl): Moved saved_tree to tree_decl. * ggc-common.c: Mark saved_tree and inlined_fns of FUNCTION_DECLs. * integrate.h (function_attribute_inlinable_p): Declare it. * integrate.c (function_attribute_inlinable_p): Export it. * tree-inline.c: New file. Define variables declared in... * tree-inline.h: New file. Declare functions to be moved to tree-inline.c. Define macros and declare types and hooks for language-specific tree inlining. (flag_inline_trees): Moved definition from cp/decl2.c. * tree.h (walk_tree_fn, DECL_SAVED_TREE): Moved from c-common.h. (TREE_READONLY_DECL_P, DECL_INLINED_FNS): Moved from cp/cp-tree.h. (struct tree_decl): Moved saved_tree from c_lang_decl and inlined_fns from C++'s lang_decl. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46021 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog23
-rw-r--r--gcc/Makefile.in7
-rw-r--r--gcc/c-common.c4
-rw-r--r--gcc/c-common.h16
-rw-r--r--gcc/ggc-common.c9
-rw-r--r--gcc/integrate.c4
-rw-r--r--gcc/integrate.h5
-rw-r--r--gcc/tree-inline.c43
-rw-r--r--gcc/tree-inline.h139
-rw-r--r--gcc/tree.h23
10 files changed, 250 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1acf2d3f359..4fe40a3f123 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,26 @@
+2001-10-04 Alexandre Oliva <aoliva@redhat.com>
+
+ * Makefile.in (OBJS): Added tree-inline.o.
+ (c-common.o): Depend on tree-inline.h.
+ (tree-inline.o): New target.
+ * c-common.c: Include tree-inline.h.
+ (c_mark_lang_decl): Don't mark saved_tree.
+ (c_common_lang_init): Set lang_anon_aggr_type_p.
+ * c-common.h (walk_tree_fn, DECL_SAVED_TREE): Moved to tree.h.
+ (struct c_lang_decl): Moved saved_tree to tree_decl.
+ * ggc-common.c: Mark saved_tree and inlined_fns of FUNCTION_DECLs.
+ * integrate.h (function_attribute_inlinable_p): Declare it.
+ * integrate.c (function_attribute_inlinable_p): Export it.
+ * tree-inline.c: New file. Define variables declared in...
+ * tree-inline.h: New file. Declare functions to be moved to
+ tree-inline.c. Define macros and declare types and hooks for
+ language-specific tree inlining.
+ (flag_inline_trees): Moved definition from cp/decl2.c.
+ * tree.h (walk_tree_fn, DECL_SAVED_TREE): Moved from c-common.h.
+ (TREE_READONLY_DECL_P, DECL_INLINED_FNS): Moved from cp/cp-tree.h.
+ (struct tree_decl): Moved saved_tree from c_lang_decl and
+ inlined_fns from C++'s lang_decl.
+
2001-10-04 Loren J. Rittle <ljrittle@acm.org>
* Makefile.in (STAGE2_FLAGS_TO_PASS): Remove patches which
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index e0c0daa2420..f6a4d74ca33 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -748,7 +748,7 @@ OBJS = \
sdbout.o sibcall.o simplify-rtx.o splay-tree.o ssa.o ssa-ccp.o \
ssa-dce.o stmt.o stor-layout.o stringpool.o timevar.o toplev.o tree.o \
unroll.o varasm.o varray.o version.o xcoffout.o cfg.o cfganal.o \
- cfgbuild.o cfgcleanup.o cfgloop.o cfgrtl.o \
+ cfgbuild.o cfgcleanup.o cfgloop.o cfgrtl.o tree-inline.o \
$(GGC) $(out_object_file) $(EXTRA_OBJS)
BACKEND = main.o libbackend.a
@@ -1249,7 +1249,8 @@ 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)
+ $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def $(TARGET_H) \
+ tree-inline.h
# A file used by all variants of C and some other languages.
@@ -1350,6 +1351,8 @@ convert.o: convert.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h convert.h toplev.
tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h function.h toplev.h \
$(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H)
+tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) $(TREE_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 \
function.h $(EXPR_H) $(RTL_H) toplev.h $(GGC_H) $(TM_P_H)
diff --git a/gcc/c-common.c b/gcc/c-common.c
index e6c81c385c0..2f5b00a4b00 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -22,6 +22,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "config.h"
#include "system.h"
#include "tree.h"
+#include "tree-inline.h"
#include "flags.h"
#include "toplev.h"
#include "output.h"
@@ -3331,7 +3332,6 @@ void
c_mark_lang_decl (c)
struct c_lang_decl *c;
{
- ggc_mark_tree (c->saved_tree);
}
/* Mark F for GC. */
@@ -3831,6 +3831,8 @@ c_common_lang_init ()
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. */
if (warn_format_y2k && !warn_format)
diff --git a/gcc/c-common.h b/gcc/c-common.h
index aadbee8f3c4..2212ceea865 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -316,12 +316,6 @@ extern void (*lang_expand_function_end) PARAMS ((void));
extern int (*lang_missing_noreturn_ok_p) PARAMS ((tree));
-/* The type of a function that walks over tree structure. */
-
-typedef tree (*walk_tree_fn) PARAMS ((tree *,
- int *,
- void *));
-
extern stmt_tree current_stmt_tree PARAMS ((void));
extern tree *current_scope_stmt_stack PARAMS ((void));
extern void begin_stmt_tree PARAMS ((tree *));
@@ -344,17 +338,9 @@ extern void mark_stmt_tree PARAMS ((void *));
DECL_LANG_SPECIFIC field. */
struct c_lang_decl {
- /* In a FUNCTION_DECL, this is DECL_SAVED_TREE. */
- tree saved_tree;
+ char dummy;
};
-/* In a FUNCTION_DECL, the saved representation of the body of the
- entire function. Usually a COMPOUND_STMT, but in C++ this may also
- be a RETURN_INIT, CTOR_INITIALIZER, or TRY_BLOCK. */
-#define DECL_SAVED_TREE(NODE) \
- (((struct c_lang_decl *) DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))) \
- ->saved_tree)
-
/* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this is
the approximate number of statements in this function. There is
no need for this number to be exact; it is only used in various
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 53057c8a75b..5fdd5e16fdd 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -463,8 +463,13 @@ ggc_mark_trees ()
ggc_mark_tree (DECL_VINDEX (t));
if (DECL_ASSEMBLER_NAME_SET_P (t))
ggc_mark_tree (DECL_ASSEMBLER_NAME (t));
- if (TREE_CODE (t) == FUNCTION_DECL && DECL_SAVED_INSNS (t))
- ggc_mark_struct_function (DECL_SAVED_INSNS (t));
+ if (TREE_CODE (t) == FUNCTION_DECL)
+ {
+ ggc_mark_tree (DECL_SAVED_TREE (t));
+ ggc_mark_tree (DECL_INLINED_FNS (t));
+ if (DECL_SAVED_INSNS (t))
+ ggc_mark_struct_function (DECL_SAVED_INSNS (t));
+ }
lang_mark_tree (t);
break;
diff --git a/gcc/integrate.c b/gcc/integrate.c
index 154d47b9699..9105deef854 100644
--- a/gcc/integrate.c
+++ b/gcc/integrate.c
@@ -77,8 +77,6 @@ typedef struct initial_value_struct {
initial_value_pair *entries;
} initial_value_struct;
-static bool function_attribute_inlinable_p PARAMS ((tree));
-
static void setup_initial_hard_reg_value_integration PARAMS ((struct function *, struct inline_remap *));
static rtvec initialize_for_inline PARAMS ((tree));
@@ -129,7 +127,7 @@ get_label_from_map (map, i)
/* Return false if the function FNDECL cannot be inlined on account of its
attributes, true otherwise. */
-static bool
+bool
function_attribute_inlinable_p (fndecl)
tree fndecl;
{
diff --git a/gcc/integrate.h b/gcc/integrate.h
index c88e2cd9e0c..888a8b4f709 100644
--- a/gcc/integrate.h
+++ b/gcc/integrate.h
@@ -152,6 +152,11 @@ extern union tree_node *copy_decl_for_inlining PARAMS ((union tree_node *,
union tree_node *,
union tree_node *));
+/* Check whether there's any attribute in a function declaration that
+ makes the function uninlinable. Returns false if it finds any,
+ true otherwise. */
+extern bool function_attribute_inlinable_p PARAMS ((union tree_node *));
+
extern void try_constants PARAMS ((rtx, struct inline_remap *));
/* Return the label indicated. */
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
new file mode 100644
index 00000000000..3679e20df45
--- /dev/null
+++ b/gcc/tree-inline.c
@@ -0,0 +1,43 @@
+/* Control and data flow functions for trees.
+ 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 "tree-inline.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.
+ 2 if we should consider *all* functions to be inline
+ candidates. */
+
+int flag_inline_trees = 0;
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
new file mode 100644
index 00000000000..6e00f962789
--- /dev/null
+++ b/gcc/tree-inline.h
@@ -0,0 +1,139 @@
+/* Tree inlining hooks and declarations.
+ 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_TREE_INLINE_H
+#define GCC_TREE_INLINE_H
+
+/* Function prototypes. */
+
+void optimize_inline_calls PARAMS ((tree));
+tree walk_tree PARAMS ((tree*, walk_tree_fn, void*, void*));
+tree walk_tree_without_duplicates PARAMS ((tree*, walk_tree_fn, void*));
+tree copy_tree_r PARAMS ((tree*, int*, void*));
+void clone_body PARAMS ((tree, tree, void*));
+void remap_save_expr PARAMS ((tree*, void*, tree, int*));
+
+/* LANG_WALK_SUBTREES is called by walk_tree() after handling common
+ cases, but before walking code-specific sub-trees. If
+ lang_walk_subtrees is defined for a language, it should handle
+ language-specific tree codes, as well as language-specific
+ information associated to common tree codes. If a tree node is
+ completely handled within this function, it should set *SUBTREES to
+ 0, so that generic handling isn't attempted. For language-specific
+ tree codes, generic handling would abort(), so make sure it is set
+ properly. Both SUBTREES and *SUBTREES is guaranteed to be non-zero
+ 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)) \
+ : 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_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_ADD_PENDING_FN_DECLS is called before starting to inline a
+ function, to push any language-specific functions that should not
+ be inlined into the current function, into VAFNP. PFN is the top
+ of varray, and should be returned if no functions are pushed into
+ 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)) \
+ : (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_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)) \
+ : (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
+ an integer that should be set in case a new declaration wasn't
+ created (presumably because RES was of aggregate type, such that a
+ TARGET_EXPR is used for the result). TEXPS is a pointer to a
+ varray with the stack of TARGET_EXPRs seen while inlining functions
+ 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)) \
+ : 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;
+
+/* 0 if we should not perform inlining.
+ 1 if we should expand functions calls inline at the tree level.
+ 2 if we should consider *all* functions to be inline
+ candidates. */
+
+extern int flag_inline_trees;
+
+#endif /* GCC_TREE_INLINE_H */
diff --git a/gcc/tree.h b/gcc/tree.h
index efa0b83c684..def0e132ed5 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -560,6 +560,10 @@ extern void tree_class_check_failed PARAMS ((const tree, int,
when the node is a type). */
#define TREE_READONLY(NODE) ((NODE)->common.readonly_flag)
+/* Non-zero if NODE is a _DECL with TREE_READONLY set. */
+#define TREE_READONLY_DECL_P(NODE) \
+ (TREE_READONLY (NODE) && DECL_P (NODE))
+
/* Value of expression is constant.
Always appears in all ..._CST nodes.
May also appear in an arithmetic expression, an ADDR_EXPR or a CONSTRUCTOR
@@ -1547,6 +1551,14 @@ struct tree_type
/* In a FUNCTION_DECL, nonzero if the function cannot be inlined. */
#define DECL_UNINLINABLE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.uninlinable)
+/* In a FUNCTION_DECL, the saved representation of the body of the
+ entire function. Usually a COMPOUND_STMT, but in C++ this may also
+ be a RETURN_INIT, CTOR_INITIALIZER, or TRY_BLOCK. */
+#define DECL_SAVED_TREE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.saved_tree)
+
+/* List of FUNCION_DECLs inlined into this function's body. */
+#define DECL_INLINED_FNS(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.inlined_fns)
+
/* Nonzero in a FUNCTION_DECL means this is a built-in function
that is not specified by ansi C and that users are supposed to be allowed
to redefine for any purpose whatever. */
@@ -1769,6 +1781,13 @@ struct tree_decl
int i;
} u2;
+ /* In a FUNCTION_DECL, this is DECL_SAVED_TREE. */
+ tree saved_tree;
+
+ /* In a FUNCTION_DECL, these are function data which is to be kept
+ as long as FUNCTION_DECL is kept. */
+ tree inlined_fns;
+
tree vindex;
HOST_WIDE_INT pointer_alias_set;
/* Points to a structure whose details depend on the language in use. */
@@ -3050,6 +3069,10 @@ extern void dwarf2out_return_save PARAMS ((const char *, long));
extern void dwarf2out_return_reg PARAMS ((const char *, unsigned));
+/* The type of a function that walks over tree structure. */
+
+typedef tree (*walk_tree_fn) PARAMS ((tree *, int *, void *));
+
/* Redefine abort to report an internal error w/o coredump, and
reporting the location of the error in the source file. This logic
OpenPOWER on IntegriCloud