Commit bc4c7159 by Alexandre Oliva Committed by Alexandre Oliva

optimize.c (struct inline_data): Moved to ../tree-inline.c.

* optimize.c (struct inline_data): Moved to ../tree-inline.c.
(INSNS_PER_STMT): Likewise.
(remap_decl, remap_block, copy_scopy_stmt, copy_body_r): Likewise.
(copy_body, initialize_inlined_parameters): Likewise.
(declare_return_variable, inlinable_function_p): Likewise.
(expand_call_inline, expand_calls_inline): Likewise.
(optimize_inline_calls, clone_body): Likewise.
* tree.c (walk_tree): Moved to ../tree-inline.c.
(walk_tree_without_duplicates): Likewise.
(copy_tree_r, remap_save_expr): Likewise.

From-SVN: r46022
parent 588d3ade
2001-10-05 Alexandre Oliva <aoliva@redhat.com>
* optimize.c (struct inline_data): Moved to ../tree-inline.c.
(INSNS_PER_STMT): Likewise.
(remap_decl, remap_block, copy_scopy_stmt, copy_body_r): Likewise.
(copy_body, initialize_inlined_parameters): Likewise.
(declare_return_variable, inlinable_function_p): Likewise.
(expand_call_inline, expand_calls_inline): Likewise.
(optimize_inline_calls, clone_body): Likewise.
* tree.c (walk_tree): Moved to ../tree-inline.c.
(walk_tree_without_duplicates): Likewise.
(copy_tree_r, remap_save_expr): Likewise.
2001-10-04 Alexandre Oliva <aoliva@redhat.com>
* Make-lang.in (cp/decl.o, cp/tree.o): Depend on tree-inline.h.
......
......@@ -1153,241 +1153,6 @@ bind_template_template_parm (t, newargs)
return t2;
}
/* Apply FUNC to all the sub-trees of TP in a pre-order traversal.
FUNC is called with the DATA and the address of each sub-tree. If
FUNC returns a non-NULL value, the traversal is aborted, and the
value returned by FUNC is returned. If HTAB is non-NULL it is used
to record the nodes visited, and to avoid visiting a node more than
once. */
tree
walk_tree (tp, func, data, htab_)
tree *tp;
walk_tree_fn func;
void *data;
void *htab_;
{
htab_t htab = (htab_t) htab_;
enum tree_code code;
int walk_subtrees;
tree result;
#define WALK_SUBTREE(NODE) \
do \
{ \
result = walk_tree (&(NODE), func, data, htab); \
if (result) \
return result; \
} \
while (0)
/* Skip empty subtrees. */
if (!*tp)
return NULL_TREE;
if (htab)
{
void **slot;
/* Don't walk the same tree twice, if the user has requested
that we avoid doing so. */
if (htab_find (htab, *tp))
return NULL_TREE;
/* If we haven't already seen this node, add it to the table. */
slot = htab_find_slot (htab, *tp, INSERT);
*slot = *tp;
}
/* Call the function. */
walk_subtrees = 1;
result = (*func) (tp, &walk_subtrees, data);
/* If we found something, return it. */
if (result)
return result;
code = TREE_CODE (*tp);
/* Even if we didn't, FUNC may have decided that there was nothing
interesting below this point in the tree. */
if (!walk_subtrees)
{
if (statement_code_p (code) || code == TREE_LIST
|| LANG_TREE_CHAIN_MATTERS_P (*tp))
/* But we still need to check our siblings. */
return walk_tree (&TREE_CHAIN (*tp), func, data, htab);
else
return NULL_TREE;
}
/* Handle common cases up front. */
if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
|| TREE_CODE_CLASS (code) == 'r'
|| TREE_CODE_CLASS (code) == 's')
{
int i, len;
/* Set lineno here so we get the right instantiation context
if we call instantiate_decl from inlinable_function_p. */
if (statement_code_p (code) && !STMT_LINENO_FOR_FN_P (*tp))
lineno = STMT_LINENO (*tp);
/* Walk over all the sub-trees of this operand. */
len = first_rtl_op (code);
/* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
But, we only want to walk once. */
if (code == TARGET_EXPR
&& TREE_OPERAND (*tp, 3) == TREE_OPERAND (*tp, 1))
--len;
/* Go through the subtrees. We need to do this in forward order so
that the scope of a FOR_EXPR is handled properly. */
for (i = 0; i < len; ++i)
WALK_SUBTREE (TREE_OPERAND (*tp, i));
/* For statements, we also walk the chain so that we cover the
entire statement tree. */
if (statement_code_p (code))
{
if (code == DECL_STMT
&& DECL_STMT_DECL (*tp)
&& DECL_P (DECL_STMT_DECL (*tp)))
{
/* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk
into declarations that are just mentioned, rather than
declared; they don't really belong to this part of the tree.
And, we can see cycles: the initializer for a declaration can
refer to the declaration itself. */
WALK_SUBTREE (DECL_INITIAL (DECL_STMT_DECL (*tp)));
WALK_SUBTREE (DECL_SIZE (DECL_STMT_DECL (*tp)));
WALK_SUBTREE (DECL_SIZE_UNIT (DECL_STMT_DECL (*tp)));
}
/* This can be tail-recursion optimized if we write it this way. */
return walk_tree (&TREE_CHAIN (*tp), func, data, htab);
}
/* We didn't find what we were looking for. */
return NULL_TREE;
}
else if (TREE_CODE_CLASS (code) == 'd')
{
WALK_SUBTREE (TREE_TYPE (*tp));
/* We didn't find what we were looking for. */
return NULL_TREE;
}
result = LANG_WALK_SUBTREES (tp, &walk_subtrees, func, data, htab);
if (result || ! walk_subtrees)
return result;
/* Not one of the easy cases. We must explicitly go through the
children. */
switch (code)
{
case ERROR_MARK:
case IDENTIFIER_NODE:
case INTEGER_CST:
case REAL_CST:
case STRING_CST:
case REAL_TYPE:
case COMPLEX_TYPE:
case VECTOR_TYPE:
case VOID_TYPE:
case BOOLEAN_TYPE:
case UNION_TYPE:
case ENUMERAL_TYPE:
case BLOCK:
case RECORD_TYPE:
/* None of thse have subtrees other than those already walked
above. */
break;
case POINTER_TYPE:
case REFERENCE_TYPE:
WALK_SUBTREE (TREE_TYPE (*tp));
break;
case TREE_LIST:
WALK_SUBTREE (TREE_VALUE (*tp));
WALK_SUBTREE (TREE_CHAIN (*tp));
break;
case TREE_VEC:
{
int len = TREE_VEC_LENGTH (*tp);
while (len--)
WALK_SUBTREE (TREE_VEC_ELT (*tp, len));
}
break;
case COMPLEX_CST:
WALK_SUBTREE (TREE_REALPART (*tp));
WALK_SUBTREE (TREE_IMAGPART (*tp));
break;
case CONSTRUCTOR:
WALK_SUBTREE (CONSTRUCTOR_ELTS (*tp));
break;
case METHOD_TYPE:
WALK_SUBTREE (TYPE_METHOD_BASETYPE (*tp));
/* Fall through. */
case FUNCTION_TYPE:
WALK_SUBTREE (TREE_TYPE (*tp));
{
tree arg = TYPE_ARG_TYPES (*tp);
/* We never want to walk into default arguments. */
for (; arg; arg = TREE_CHAIN (arg))
WALK_SUBTREE (TREE_VALUE (arg));
}
break;
case ARRAY_TYPE:
WALK_SUBTREE (TREE_TYPE (*tp));
WALK_SUBTREE (TYPE_DOMAIN (*tp));
break;
case INTEGER_TYPE:
WALK_SUBTREE (TYPE_MIN_VALUE (*tp));
WALK_SUBTREE (TYPE_MAX_VALUE (*tp));
break;
case OFFSET_TYPE:
WALK_SUBTREE (TREE_TYPE (*tp));
WALK_SUBTREE (TYPE_OFFSET_BASETYPE (*tp));
break;
default:
abort ();
}
/* We didn't find what we were looking for. */
return NULL_TREE;
#undef WALK_SUBTREE
}
/* Like walk_tree, but does not walk duplicate nodes more than
once. */
tree
walk_tree_without_duplicates (tp, func, data)
tree *tp;
walk_tree_fn func;
void *data;
{
tree result;
htab_t htab;
htab = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
result = walk_tree (tp, func, data, htab);
htab_delete (htab);
return result;
}
/* Called from count_trees via walk_tree. */
static tree
......@@ -1512,51 +1277,6 @@ no_linkage_check (t)
return NULL_TREE;
}
/* Passed to walk_tree. Copies the node pointed to, if appropriate. */
tree
copy_tree_r (tp, walk_subtrees, data)
tree *tp;
int *walk_subtrees;
void *data ATTRIBUTE_UNUSED;
{
enum tree_code code = TREE_CODE (*tp);
/* We make copies of most nodes. */
if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
|| TREE_CODE_CLASS (code) == 'r'
|| TREE_CODE_CLASS (code) == 'c'
|| TREE_CODE_CLASS (code) == 's'
|| code == TREE_LIST
|| code == TREE_VEC
|| LANG_TREE_CHAIN_MATTERS_P (*tp))
{
/* Because the chain gets clobbered when we make a copy, we save it
here. */
tree chain = TREE_CHAIN (*tp);
/* Copy the node. */
*tp = copy_node (*tp);
/* Now, restore the chain, if appropriate. That will cause
walk_tree to walk into the chain as well. */
if (code == PARM_DECL || code == TREE_LIST
|| LANG_TREE_CHAIN_MATTERS_P (*tp)
|| statement_code_p (code))
TREE_CHAIN (*tp) = chain;
/* For now, we don't update BLOCKs when we make copies. So, we
have to nullify all scope-statements. */
if (TREE_CODE (*tp) == SCOPE_STMT)
SCOPE_STMT_BLOCK (*tp) = NULL_TREE;
}
else if (TREE_CODE_CLASS (code) == 't')
/* There's no need to copy types, or anything beneath them. */
*walk_subtrees = 0;
return NULL_TREE;
}
#ifdef GATHER_STATISTICS
extern int depth_reached;
#endif
......@@ -2565,48 +2285,6 @@ init_tree ()
mark_tree_hashtable);
}
/* The SAVE_EXPR pointed to by TP is being copied. If ST contains
information indicating to what new SAVE_EXPR this one should be
mapped, use that one. Otherwise, create a new node and enter it in
ST. FN is the function into which the copy will be placed. */
void
remap_save_expr (tp, st_, fn, walk_subtrees)
tree *tp;
void *st_;
tree fn;
int *walk_subtrees;
{
splay_tree st = (splay_tree) st_;
splay_tree_node n;
/* See if we already encountered this SAVE_EXPR. */
n = splay_tree_lookup (st, (splay_tree_key) *tp);
/* If we didn't already remap this SAVE_EXPR, do so now. */
if (!n)
{
tree t = copy_node (*tp);
/* The SAVE_EXPR is now part of the function into which we
are inlining this body. */
SAVE_EXPR_CONTEXT (t) = fn;
/* And we haven't evaluated it yet. */
SAVE_EXPR_RTL (t) = NULL_RTX;
/* Remember this SAVE_EXPR. */
n = splay_tree_insert (st,
(splay_tree_key) *tp,
(splay_tree_value) t);
}
else
/* We've already walked into this SAVE_EXPR, so we needn't do it
again. */
*walk_subtrees = 0;
/* Replace this SAVE_EXPR with the copy. */
*tp = (tree) n->value;
}
/* Called via walk_tree. If *TP points to a DECL_STMT for a local
declaration, copies the declaration and enters it in the splay_tree
pointed to by DATA (which is really a `splay_tree *'). */
......
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