* 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
+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
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)
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;
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;
{
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)
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:
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;
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++)
+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.
static int deep_const_expr PARAMS ((tree));
static void chill_print_error_function PARAMS ((const char *));
\f
-/* 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;
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;
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;
+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
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;
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))
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);
#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++)
#endif
t = make_node (code);
- length = tree_code_length[(int) code];
+ length = TREE_CODE_LENGTH (code);
TREE_TYPE (t) = tt;
TREE_COMPLEXITY (t) = lineno;
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)
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);
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))
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))
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)
{
;
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));
}
}
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));
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':
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)
|| 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");
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 */
#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
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. */
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;
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
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 *);
}
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 */
case METHOD_CALL_EXPR:
return 3;
default:
- return tree_code_length [(int) code];
+ return TREE_CODE_LENGTH (code);
}
}
break;
}
- switch (tree_code_length[(int) code])
+ switch (TREE_CODE_LENGTH (code))
{
case 1:
return contains_placeholder_p (TREE_OPERAND (exp, 0));
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);
#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
#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);
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);
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)
#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
/* 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. */