tree.h (TREE_CODE_LENGTH): New macro.

* tree.h (TREE_CODE_LENGTH): New macro.
	* c-common.c (c_find_base_decl): Use it.
	* expr.c (safe_from_p): Likewise.
	* print-tree.c (print_node): Likewise.
	* tree.c (make_node, copy_node, get_identifier): Likewie.
	(first_rtl_op, contains_placeholder_p, substitute_in_expr): Likewise.
	(build, build_nt, build_parse_node, simple_cst_equal): Likewise.
	* fold-const.c (make_range): Likewise.
	(fold): Likewise; also use first_rtl_op.
	* c-iterate.c (collect_iterators): Use first_rtl_op.
	* calls.c (calls_function_1): Likewise; also rename TYPE to CLASS.
	Use IS_EXPR_CODE_CLASS.
	(preexpand_calls): Likewise.
	* ggc-common.c (ggc_mark_trees): Rework to use first_rtl_op
	and TREE_CODE_LENGTH.
	* stmt.c (warn_if_unused_value): If no operands, no unused value.
	* ch/lang.c (deep_const_expr): Use first_rtl_op.
	* ch/satisfy.c (satisfy): Use TREE_CODE_LENGTH.
	* cp/method.c (mangle_expression): Use TREE_CODE_LENGTH.
	* cp/tree.c (break_out_calls, build_min_nt): Use TREE_CODE_LENGTH.
	(built_min, cp_tree_equal): Likewise.

From-SVN: r34203
This commit is contained in:
Richard Kenner 2000-05-27 15:21:17 +00:00 committed by Richard Kenner
parent 0777f60c79
commit 8d5e6e2527
16 changed files with 107 additions and 106 deletions

View File

@ -1,3 +1,22 @@
Sat May 27 11:01:27 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* tree.h (TREE_CODE_LENGTH): New macro.
* c-common.c (c_find_base_decl): Use it.
* expr.c (safe_from_p): Likewise.
* print-tree.c (print_node): Likewise.
* tree.c (make_node, copy_node, get_identifier): Likewie.
(first_rtl_op, contains_placeholder_p, substitute_in_expr): Likewise.
(build, build_nt, build_parse_node, simple_cst_equal): Likewise.
* fold-const.c (make_range): Likewise.
(fold): Likewise; also use first_rtl_op.
* c-iterate.c (collect_iterators): Use first_rtl_op.
* calls.c (calls_function_1): Likewise; also rename TYPE to CLASS.
Use IS_EXPR_CODE_CLASS.
(preexpand_calls): Likewise.
* ggc-common.c (ggc_mark_trees): Rework to use first_rtl_op
and TREE_CODE_LENGTH.
* stmt.c (warn_if_unused_value): If no operands, no unused value.
2000-05-26 Geoffrey Keating <geoffk@cygnus.com>
* config/rs6000/rs6000.md (movsi_internal1): Use '%a1' rather

View File

@ -3297,7 +3297,7 @@ c_find_base_decl (t)
case '1':
case '2':
case '3':
for (i = tree_code_length [(int) TREE_CODE (t)]; --i >= 0;)
for (i = TREE_CODE_LENGTH (TREE_CODE (t)); --i >= 0;)
{
tree d = c_find_base_decl (TREE_OPERAND (t, i));
if (d)

View File

@ -241,27 +241,9 @@ collect_iterators (exp, list)
case 'e':
case 'r':
{
int num_args = tree_code_length[(int) TREE_CODE (exp)];
int num_args = first_rtl_op (TREE_CODE (exp));
int i;
/* Some tree codes have RTL, not trees, as operands. */
switch (TREE_CODE (exp))
{
case CALL_EXPR:
num_args = 2;
break;
case METHOD_CALL_EXPR:
num_args = 3;
break;
case WITH_CLEANUP_EXPR:
num_args = 1;
break;
case RTL_EXPR:
return list;
default:
break;
}
for (i = 0; i < num_args; i++)
list = collect_iterators (TREE_OPERAND (exp, i), list);
return list;

View File

@ -238,12 +238,15 @@ calls_function (exp, which)
int which;
{
int val;
calls_function_save_exprs = 0;
val = calls_function_1 (exp, which);
calls_function_save_exprs = 0;
return val;
}
/* Recursive function to do the work of above function. */
static int
calls_function_1 (exp, which)
tree exp;
@ -251,8 +254,8 @@ calls_function_1 (exp, which)
{
register int i;
enum tree_code code = TREE_CODE (exp);
int type = TREE_CODE_CLASS (code);
int length = tree_code_length[(int) code];
int class = TREE_CODE_CLASS (code);
int length = first_rtl_op (code);
/* If this code is language-specific, we don't know what it will do. */
if ((int) code >= NUM_TREE_CODES)
@ -265,16 +268,12 @@ calls_function_1 (exp, which)
return 1;
else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
&& (TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
== FUNCTION_DECL))
{
tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
int flags = special_function_p (fndecl, 0);
if (flags & ECF_MAY_BE_ALLOCA)
return 1;
}
== FUNCTION_DECL)
&& (special_function_p (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
0)
& ECF_MAY_BE_ALLOCA))
return 1;
/* Third operand is RTL. */
length = 2;
break;
case SAVE_EXPR:
@ -290,14 +289,12 @@ calls_function_1 (exp, which)
case BLOCK:
{
register tree local;
register tree subblock;
for (local = BLOCK_VARS (exp); local; local = TREE_CHAIN (local))
if (DECL_INITIAL (local) != 0
&& calls_function_1 (DECL_INITIAL (local), which))
return 1;
}
{
register tree subblock;
for (subblock = BLOCK_SUBBLOCKS (exp);
subblock;
@ -306,30 +303,19 @@ calls_function_1 (exp, which)
return 1;
}
return 0;
case TREE_LIST:
for (; exp != 0; exp = TREE_CHAIN (exp))
if (calls_function_1 (TREE_VALUE (exp), which))
return 1;
return 0;
case METHOD_CALL_EXPR:
length = 3;
break;
case WITH_CLEANUP_EXPR:
length = 1;
break;
case RTL_EXPR:
return 0;
default:
break;
}
/* Only expressions and references can contain calls. */
if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r'
&& type != 'b')
/* Only expressions, references, and blocks can contain calls. */
if (! IS_EXPR_CODE_CLASS (class) && class != 'r' && class != 'b')
return 0;
for (i = 0; i < length; i++)

View File

@ -1,3 +1,8 @@
Sat May 27 11:24:26 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* lang.c (deep_const_expr): Use first_rtl_op.
* satisfy.c (satisfy): Use TREE_CODE_LENGTH.
2000-05-18 Chris Demetriou <cgd@netbsd.org>
* Makefile.in (hash.h): Delete a redundant use of gawk and sed.

View File

@ -53,8 +53,9 @@ extern FILE* finput;
static int deep_const_expr PARAMS ((tree));
static void chill_print_error_function PARAMS ((const char *));
/* return 1 if the expression tree given has all
constant nodes as its leaves; return 0 otherwise. */
/* Return 1 if the expression tree given has all
constant nodes as its leaves,otherwise. */
static int
deep_const_expr (exp)
tree exp;
@ -67,13 +68,13 @@ deep_const_expr (exp)
return 0;
code = TREE_CODE (exp);
length = tree_code_length[(int) code];
length = first_rtl_op (TREE_CODE (exp));
/* constant leaf? return TRUE */
if (TREE_CODE_CLASS (code) == 'c')
return 1;
/* recursively check next level down */
/* Recursively check next level down. */
for (i = 0; i < length; i++)
if (! deep_const_expr (TREE_OPERAND (exp, i)))
return 0;

View File

@ -371,7 +371,8 @@ satisfy (exp, chain)
default:
;
}
arg_length = tree_code_length[TREE_CODE (exp)];
arg_length = TREE_CODE_LENGTH (TREE_CODE (exp));
for (i = 0; i < arg_length; i++)
SATISFY (TREE_OPERAND (exp, i));
return exp;

View File

@ -1,3 +1,9 @@
Sat May 27 11:25:46 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* method.c (mangle_expression): Use TREE_CODE_LENGTH.
* tree.c (break_out_calls, build_min_nt): Use TREE_CODE_LENGTH.
(built_min, cp_tree_equal): Likewise.
2000-05-26 Mark Mitchell <mark@codesourcery.com>
* class.c (layout_nonempty_base_or_field): Replace

View File

@ -519,7 +519,7 @@ mangle_expression (value)
if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (value))))
{
int i;
int operands = tree_code_length[(int) TREE_CODE (value)];
int operands = TREE_CODE_LENGTH (TREE_CODE (value));
tree id;
const char *name;

View File

@ -405,7 +405,7 @@ break_out_calls (exp)
case 'e': /* an expression */
case 'r': /* a reference */
case 's': /* an expression with side effects */
for (i = tree_code_length[(int) code] - 1; i >= 0; i--)
for (i = TREE_CODE_LENGTH (code) - 1; i >= 0; i--)
{
t1 = break_out_calls (TREE_OPERAND (exp, i));
if (t1 != TREE_OPERAND (exp, i))
@ -427,7 +427,7 @@ break_out_calls (exp)
changed = 1;
if (changed)
{
if (tree_code_length[(int) code] == 1)
if (TREE_CODE_LENGTH (code) == 1)
return build1 (code, TREE_TYPE (exp), t1);
else
return build (code, TREE_TYPE (exp), t1, t2);
@ -1659,7 +1659,7 @@ build_min_nt VPARAMS ((enum tree_code code, ...))
#endif
t = make_node (code);
length = tree_code_length[(int) code];
length = TREE_CODE_LENGTH (code);
TREE_COMPLEXITY (t) = lineno;
for (i = 0; i < length; i++)
@ -1695,7 +1695,7 @@ build_min VPARAMS ((enum tree_code code, tree tt, ...))
#endif
t = make_node (code);
length = tree_code_length[(int) code];
length = TREE_CODE_LENGTH (code);
TREE_TYPE (t) = tt;
TREE_COMPLEXITY (t) = lineno;
@ -1944,7 +1944,7 @@ cp_tree_equal (t1, t2)
case 'r':
case 's':
cmp = 1;
for (i=0; i<tree_code_length[(int) code1]; ++i)
for (i = 0; i < TREE_CODE_LENGTH (code1); ++i)
{
cmp = cp_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
if (cmp <= 0)

View File

@ -5499,7 +5499,7 @@ safe_from_p (x, exp, top_p)
return 0;
save_expr_rewritten[save_expr_count++] = exp;
nops = tree_code_length[(int) SAVE_EXPR];
nops = TREE_CODE_LENGTH (SAVE_EXPR);
for (i = 0; i < nops; i++)
{
tree operand = TREE_OPERAND (exp, i);
@ -5530,7 +5530,7 @@ safe_from_p (x, exp, top_p)
if (exp_rtl)
break;
nops = tree_code_length[(int) TREE_CODE (exp)];
nops = TREE_CODE_LENGTH (TREE_CODE (exp));
for (i = 0; i < nops; i++)
if (TREE_OPERAND (exp, i) != 0
&& ! safe_from_p (x, TREE_OPERAND (exp, i), 0))
@ -9079,14 +9079,14 @@ preexpand_calls (exp)
tree exp;
{
register int nops, i;
int type = TREE_CODE_CLASS (TREE_CODE (exp));
int class = TREE_CODE_CLASS (TREE_CODE (exp));
if (! do_preexpand_calls)
return;
/* Only expressions and references can contain calls. */
if (type != 'e' && type != '<' && type != '1' && type != '2' && type != 'r')
if (! IS_EXPR_CODE_CLASS (class) && class != 'r')
return;
switch (TREE_CODE (exp))
@ -9134,7 +9134,7 @@ preexpand_calls (exp)
break;
}
nops = tree_code_length[(int) TREE_CODE (exp)];
nops = TREE_CODE_LENGTH (TREE_CODE (exp));
for (i = 0; i < nops; i++)
if (TREE_OPERAND (exp, i) != 0)
{
@ -9144,9 +9144,8 @@ preexpand_calls (exp)
;
else
{
type = TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, i)));
if (type == 'e' || type == '<' || type == '1' || type == '2'
|| type == 'r')
class = TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (exp, i)));
if (IS_EXPR_CODE_CLASS (class) || class == 'r')
preexpand_calls (TREE_OPERAND (exp, i));
}
}

View File

@ -348,28 +348,12 @@ ggc_mark_trees ()
case TREE_VEC:
{
int i = TREE_VEC_LENGTH (t);
while (--i >= 0)
ggc_mark_tree (TREE_VEC_ELT (t, i));
continue;
}
case SAVE_EXPR:
ggc_mark_tree (TREE_OPERAND (t, 0));
ggc_mark_tree (SAVE_EXPR_CONTEXT (t));
ggc_mark_rtx (SAVE_EXPR_RTL (t));
continue;
case RTL_EXPR:
ggc_mark_rtx (RTL_EXPR_SEQUENCE (t));
ggc_mark_rtx (RTL_EXPR_RTL (t));
continue;
case CALL_EXPR:
ggc_mark_tree (TREE_OPERAND (t, 0));
ggc_mark_tree (TREE_OPERAND (t, 1));
ggc_mark_rtx (CALL_EXPR_RTL (t));
continue;
case COMPLEX_CST:
ggc_mark_tree (TREE_REALPART (t));
ggc_mark_tree (TREE_IMAGPART (t));
@ -450,10 +434,17 @@ ggc_mark_trees ()
case 'r': case '<': case '1':
case '2': case 'e': case 's': /* Expressions. */
{
int i = tree_code_length[TREE_CODE (t)];
int i = TREE_CODE_LENGTH (TREE_CODE (t));
int first_rtl = first_rtl_op (TREE_CODE (t));
while (--i >= 0)
ggc_mark_tree (TREE_OPERAND (t, i));
break;
{
if (i >= first_rtl)
ggc_mark_rtx ((rtx) TREE_OPERAND (t, i));
else
ggc_mark_tree (TREE_OPERAND (t, i));
}
break;
}
case 'x':

View File

@ -580,10 +580,12 @@ print_node (file, prefix, node, indent)
break;
}
len = tree_code_length[(int) TREE_CODE (node)];
len = TREE_CODE_LENGTH (TREE_CODE (node));
/* Some nodes contain rtx's, not trees,
after a certain point. Print the rtx's as rtx's. */
first_rtl = first_rtl_op (TREE_CODE (node));
for (i = 0; i < len; i++)
{
if (i >= first_rtl)

View File

@ -2004,6 +2004,14 @@ warn_if_unused_value (exp)
|| TREE_CODE_CLASS (TREE_CODE (exp)) == 'r')
&& TREE_THIS_VOLATILE (exp))
return 0;
/* If this is an expression which has no operands, there is no value
to be unused. There are no such language-independent codes,
but front ends may define such. */
if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'e'
&& TREE_CODE_LENGTH (TREE_CODE (exp)) == 0)
return 0;
warn:
warning_with_file_and_line (emit_filename, emit_lineno,
"value computed is not used");

View File

@ -996,7 +996,7 @@ make_node (code)
if (code == BIND_EXPR && obstack != &permanent_obstack)
obstack = saveable_obstack;
length = sizeof (struct tree_exp)
+ (tree_code_length[(int) code] - 1) * sizeof (char *);
+ (TREE_CODE_LENGTH (code) - 1) * sizeof (char *);
break;
case 'c': /* a constant */
@ -1005,7 +1005,7 @@ make_node (code)
#endif
obstack = expression_obstack;
/* We can't use tree_code_length for INTEGER_CST, since the number of
/* We can't use TREE_CODE_LENGTH for INTEGER_CST, since the number of
words is machine-dependent due to varying length of HOST_WIDE_INT,
which might be wider than a pointer (e.g., long long). Similarly
for REAL_CST, since the number of words is machine-dependent due
@ -1017,7 +1017,7 @@ make_node (code)
length = sizeof (struct tree_real_cst);
else
length = sizeof (struct tree_common)
+ tree_code_length[(int) code] * sizeof (char *);
+ TREE_CODE_LENGTH (code) * sizeof (char *);
break;
case 'x': /* something random, like an identifier. */
@ -1032,7 +1032,7 @@ make_node (code)
kind = x_kind;
#endif
length = sizeof (struct tree_common)
+ tree_code_length[(int) code] * sizeof (char *);
+ TREE_CODE_LENGTH (code) * sizeof (char *);
/* Identifier nodes are always permanent since they are
unique in a compiler run. */
if (code == IDENTIFIER_NODE) obstack = &permanent_obstack;
@ -1171,11 +1171,11 @@ copy_node (node)
case '1': /* a unary arithmetic expression */
case '2': /* a binary arithmetic expression */
length = sizeof (struct tree_exp)
+ (tree_code_length[(int) code] - 1) * sizeof (char *);
+ (TREE_CODE_LENGTH (code) - 1) * sizeof (char *);
break;
case 'c': /* a constant */
/* We can't use tree_code_length for INTEGER_CST, since the number of
/* We can't use TREE_CODE_LENGTH for INTEGER_CST, since the number of
words is machine-dependent due to varying length of HOST_WIDE_INT,
which might be wider than a pointer (e.g., long long). Similarly
for REAL_CST, since the number of words is machine-dependent due
@ -1186,12 +1186,12 @@ copy_node (node)
length = sizeof (struct tree_real_cst);
else
length = (sizeof (struct tree_common)
+ tree_code_length[(int) code] * sizeof (char *));
+ TREE_CODE_LENGTH (code) * sizeof (char *));
break;
case 'x': /* something random, like an identifier. */
length = sizeof (struct tree_common)
+ tree_code_length[(int) code] * sizeof (char *);
+ TREE_CODE_LENGTH (code) * sizeof (char *);
if (code == TREE_VEC)
length += (TREE_VEC_LENGTH (node) - 1) * sizeof (char *);
}
@ -1298,7 +1298,7 @@ get_identifier (text)
break;
}
if (tree_code_length[(int) IDENTIFIER_NODE] < 0)
if (TREE_CODE_LENGTH (IDENTIFIER_NODE) < 0)
abort (); /* set_identifier_size hasn't been called. */
/* Not found, create one, add to chain */
@ -2590,7 +2590,7 @@ first_rtl_op (code)
case METHOD_CALL_EXPR:
return 3;
default:
return tree_code_length [(int) code];
return TREE_CODE_LENGTH (code);
}
}
@ -2862,7 +2862,7 @@ contains_placeholder_p (exp)
break;
}
switch (tree_code_length[(int) code])
switch (TREE_CODE_LENGTH (code))
{
case 1:
return contains_placeholder_p (TREE_OPERAND (exp, 0));
@ -2981,7 +2981,7 @@ substitute_in_expr (exp, f, r)
case '2':
case '<':
case 'e':
switch (tree_code_length[(int) code])
switch (TREE_CODE_LENGTH (code))
{
case 1:
op0 = substitute_in_expr (TREE_OPERAND (exp, 0), f, r);
@ -3301,7 +3301,7 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
#endif
t = make_node (code);
length = tree_code_length[(int) code];
length = TREE_CODE_LENGTH (code);
TREE_TYPE (t) = tt;
/* Below, we automatically set TREE_SIDE_EFFECTS and TREE_RAISED for
@ -3451,7 +3451,7 @@ build_nt VPARAMS ((enum tree_code code, ...))
#endif
t = make_node (code);
length = tree_code_length[(int) code];
length = TREE_CODE_LENGTH (code);
for (i = 0; i < length; i++)
TREE_OPERAND (t, i) = va_arg (p, tree);
@ -3484,7 +3484,7 @@ build_parse_node VPARAMS ((enum tree_code code, ...))
expression_obstack = &temp_decl_obstack;
t = make_node (code);
length = tree_code_length[(int) code];
length = TREE_CODE_LENGTH (code);
for (i = 0; i < length; i++)
TREE_OPERAND (t, i) = va_arg (p, tree);
@ -4529,7 +4529,7 @@ simple_cst_equal (t1, t2)
case 'r':
case 's':
cmp = 1;
for (i = 0; i < tree_code_length[(int) code1]; i++)
for (i = 0; i < TREE_CODE_LENGTH (code1); i++)
{
cmp = simple_cst_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
if (cmp <= 0)

View File

@ -39,8 +39,8 @@ enum tree_code {
#undef DEFTREECODE
/* Number of tree codes. */
#define NUM_TREE_CODES ((int)LAST_AND_UNUSED_TREE_CODE)
/* Number of language-independent tree codes. */
#define NUM_TREE_CODES ((int) LAST_AND_UNUSED_TREE_CODE)
/* Indexed by enum tree_code, contains a character which is
`<' for a comparison expression, `1', for a unary arithmetic
@ -62,6 +62,7 @@ extern char tree_code_type[MAX_TREE_CODES];
/* Number of argument-words in each kind of tree-node. */
extern int tree_code_length[MAX_TREE_CODES];
#define TREE_CODE_LENGTH(CODE) tree_code_length[(int) (CODE)]
/* Names of tree components. */