This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to add 'r' and 's' to IS_EXPR_CODE_CLASS
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Aug 2003 03:42:36 -0400
- Subject: Re: PATCH to add 'r' and 's' to IS_EXPR_CODE_CLASS
- References: <wvlhe4cgg1v.fsf@prospero.boston.redhat.com>
And here's the version for tree-ssa.
The internal_get_tmp_var hunk improves debugging information; previously a
statement copying the value of a memory var into a temp would get the locus
of the variable, rather than the use.
Tested athlon-pc-linux-gnu, applied to tree-ssa.
2003-08-20 Jason Merrill <jason@redhat.com>
* tree.h (IS_EXPR_CODE_CLASS): Also include 'r' and 's'.
(EXPR_CHECK): Don't check for 'r' or 's' if we're
checking IS_EXPR_CODE_CLASS.
* calls.c (calls_function_1): Likewise.
* fold-const.c (fold): Likewise.
* tree.c (iterative_hash_expr): Likewise.
* tree-inline.c (walk_tree, copy_tree_r): Likewise.
* expr.c (expand_expr): Don't check for 'r' or 's' if we're
checking IS_EXPR_CODE_CLASS.
* tree-dfa.c (may_access_global_mem_p): Likewise.
* tree-browser.c (browse_tree): Likewise.
* tree-ssa-pre.c (defs_hash_expr): Likewise.
* gimplify.c (gimplify_expr): Likewise.
(internal_get_tmp_var): Only copy TREE_LOCUS from an expr.
*** ./tree.c.~1~ 2003-08-19 14:36:28.000000000 -0400
--- ./tree.c 2003-08-19 15:08:49.000000000 -0400
*************** iterative_hash_expr (tree t, hashval_t v
*** 3521,3527 ****
else
abort ();
}
! else if (IS_EXPR_CODE_CLASS (class) || class == 'r')
{
val = iterative_hash_object (code, val);
--- 3522,3528 ----
else
abort ();
}
! else if (IS_EXPR_CODE_CLASS (class))
{
val = iterative_hash_object (code, val);
*************** make_ssa_name (tree var, tree stmt)
*** 5068,5075 ****
if ((!DECL_P (var)
&& TREE_CODE (var) != INDIRECT_REF)
|| (!IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (stmt)))
- && TREE_CODE (stmt) != ASM_EXPR
- && TREE_CODE (stmt) != RETURN_EXPR
&& TREE_CODE (stmt) != PHI_NODE))
abort ();
#endif
--- 5069,5074 ----
*** ./expr.c.~1~ 2003-07-24 19:29:55.000000000 -0400
--- ./expr.c 2003-08-19 15:05:11.000000000 -0400
*************** expand_expr (tree exp, rtx target, enum
*** 6725,6733 ****
than globals. */
if (cfun
&& TREE_LOCUS (exp)
! && (IS_EXPR_CODE_CLASS (class)
! || class == 'r'
! || class == 's'))
{
const char *saved_input_filename = input_filename;
int saved_lineno = input_line;
--- 6725,6731 ----
than globals. */
if (cfun
&& TREE_LOCUS (exp)
! && IS_EXPR_CODE_CLASS (class))
{
const char *saved_input_filename = input_filename;
int saved_lineno = input_line;
*** ./tree.h.~1~ 2003-08-05 22:11:26.000000000 -0400
--- ./tree.h 2003-08-19 15:35:16.000000000 -0400
*************** extern const char tree_code_type[];
*** 57,63 ****
expression. */
#define IS_EXPR_CODE_CLASS(CLASS) \
! ((CLASS) == '<' || (CLASS) == '1' || (CLASS) == '2' || (CLASS) == 'e')
/* Number of argument-words in each kind of tree-node. */
--- 57,64 ----
expression. */
#define IS_EXPR_CODE_CLASS(CLASS) \
! ((CLASS) == '<' || (CLASS) == '1' || (CLASS) == '2' || (CLASS) == 'e' \
! || (CLASS) == 'r' || (CLASS) == 's')
/* Number of argument-words in each kind of tree-node. */
*************** struct tree_common GTY(())
*** 311,317 ****
#define EXPR_CHECK(T) __extension__ \
({ const tree __t = (T); \
char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \
! if (!IS_EXPR_CODE_CLASS (__c) && __c != 'r' && __c != 's') \
tree_class_check_failed (__t, 'e', __FILE__, __LINE__, \
__FUNCTION__); \
__t; })
--- 312,318 ----
#define EXPR_CHECK(T) __extension__ \
({ const tree __t = (T); \
char const __c = TREE_CODE_CLASS (TREE_CODE (__t)); \
! if (!IS_EXPR_CODE_CLASS (__c)) \
tree_class_check_failed (__t, 'e', __FILE__, __LINE__, \
__FUNCTION__); \
__t; })
*** ./gimplify.c.~1~ 2003-08-19 14:36:28.000000000 -0400
--- ./gimplify.c 2003-08-19 15:34:46.000000000 -0400
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 367,376 ****
class = TREE_CODE_CLASS (TREE_CODE (*expr_p));
locus = TREE_LOCUS (*expr_p);
! if (locus
! && (IS_EXPR_CODE_CLASS (class)
! || class == 'r'
! || class == 's'))
{
saved_input_filename = input_filename;
saved_lineno = input_line;
--- 369,375 ----
class = TREE_CODE_CLASS (TREE_CODE (*expr_p));
locus = TREE_LOCUS (*expr_p);
! if (locus && IS_EXPR_CODE_CLASS (class))
{
saved_input_filename = input_filename;
saved_lineno = input_line;
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 765,774 ****
annotate_all_with_file_line (&tmp, input_filename, input_line);
*expr_p = tmp;
! if (locus
! && (IS_EXPR_CODE_CLASS (class)
! || class == 'r'
! || class == 's'))
{
input_filename = saved_input_filename;
input_line = saved_lineno;
--- 718,724 ----
annotate_all_with_file_line (&tmp, input_filename, input_line);
*expr_p = tmp;
! if (locus && IS_EXPR_CODE_CLASS (class))
{
input_filename = saved_input_filename;
input_line = saved_lineno;
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 784,793 ****
copy into a temp before adding the post-effects to the tree. */
if (!internal_post && (*gimple_test_f) (*expr_p))
{
! if (locus
! && (IS_EXPR_CODE_CLASS (class)
! || class == 'r'
! || class == 's'))
{
input_filename = saved_input_filename;
input_line = saved_lineno;
--- 734,740 ----
copy into a temp before adding the post-effects to the tree. */
if (!internal_post && (*gimple_test_f) (*expr_p))
{
! if (locus && IS_EXPR_CODE_CLASS (class))
{
input_filename = saved_input_filename;
input_line = saved_lineno;
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 849,858 ****
add_tree (internal_post, pre_p);
}
! if (locus
! && (IS_EXPR_CODE_CLASS (class)
! || class == 'r'
! || class == 's'))
{
input_filename = saved_input_filename;
input_line = saved_lineno;
--- 797,803 ----
add_tree (internal_post, pre_p);
}
! if (locus && IS_EXPR_CODE_CLASS (class))
{
input_filename = saved_input_filename;
input_line = saved_lineno;
*************** static tree
*** 2596,2608 ****
internal_get_tmp_var (tree val, tree *pre_p, bool is_formal)
{
tree t, mod;
gimplify_expr (&val, pre_p, NULL, is_gimple_rhs, fb_rvalue);
t = lookup_tmp_var (val, is_formal);
mod = build (MODIFY_EXPR, TREE_TYPE (t), t, val);
! if (TREE_LOCUS (val))
TREE_LOCUS (mod) = TREE_LOCUS (val);
else
annotate_with_file_line (mod, input_filename, input_line);
--- 2634,2649 ----
internal_get_tmp_var (tree val, tree *pre_p, bool is_formal)
{
tree t, mod;
+ char class;
gimplify_expr (&val, pre_p, NULL, is_gimple_rhs, fb_rvalue);
t = lookup_tmp_var (val, is_formal);
mod = build (MODIFY_EXPR, TREE_TYPE (t), t, val);
!
! class = TREE_CODE_CLASS (TREE_CODE (val));
! if (TREE_LOCUS (val) && IS_EXPR_CODE_CLASS (class))
TREE_LOCUS (mod) = TREE_LOCUS (val);
else
annotate_with_file_line (mod, input_filename, input_line);
*** ./tree-dfa.c.~1~ 2003-08-19 14:36:28.000000000 -0400
--- ./tree-dfa.c 2003-08-19 15:12:09.000000000 -0400
*************** may_access_global_mem_p (tree expr)
*** 2187,2193 ****
/* Recursively check the expression's operands. */
class = TREE_CODE_CLASS (TREE_CODE (expr));
! if (IS_EXPR_CODE_CLASS (class) || class == 'r')
{
unsigned char i;
--- 2178,2184 ----
/* Recursively check the expression's operands. */
class = TREE_CODE_CLASS (TREE_CODE (expr));
! if (IS_EXPR_CODE_CLASS (class))
{
unsigned char i;
*** ./tree-inline.c.~1~ 2003-08-19 14:36:28.000000000 -0400
--- ./tree-inline.c 2003-08-19 15:12:45.000000000 -0400
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 1487,1495 ****
if (code != EXIT_BLOCK_EXPR
&& code != SAVE_EXPR
! && (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
! || TREE_CODE_CLASS (code) == 'r'
! || TREE_CODE_CLASS (code) == 's'))
{
int i, len;
--- 1515,1521 ----
if (code != EXIT_BLOCK_EXPR
&& code != SAVE_EXPR
! && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
{
int i, len;
*************** copy_tree_r (tree *tp, int *walk_subtree
*** 1669,1677 ****
/* 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_hooks.tree_inlining.tree_chain_matters_p) (*tp))
--- 1695,1701 ----
*** ./fold-const.c.~1~ 2003-08-15 02:28:17.000000000 -0400
--- ./fold-const.c 2003-08-19 15:05:50.000000000 -0400
*************** fold (tree expr)
*** 4992,4998 ****
do arithmetic on them. */
wins = 0;
}
! else if (IS_EXPR_CODE_CLASS (kind) || kind == 'r')
{
int len = first_rtl_op (code);
int i;
--- 4992,4998 ----
do arithmetic on them. */
wins = 0;
}
! else if (IS_EXPR_CODE_CLASS (kind))
{
int len = first_rtl_op (code);
int i;
*** ./calls.c.~1~ 2003-07-23 18:28:29.000000000 -0400
--- ./calls.c 2003-08-19 15:10:24.000000000 -0400
*************** calls_function_1 (tree exp, int which)
*** 262,269 ****
break;
}
! /* 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++)
--- 262,269 ----
break;
}
! /* Only expressions and blocks can contain calls. */
! if (! IS_EXPR_CODE_CLASS (class) && class != 'b')
return 0;
for (i = 0; i < length; i++)
*** ./tree-browser.c.~1~ 2003-07-23 18:28:45.000000000 -0400
--- ./tree-browser.c 2003-08-19 15:07:17.000000000 -0400
*************** browse_tree (tree begin)
*** 441,449 ****
break;
case TB_CHILD_0:
! if (head && (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
! || TREE_CODE_CLASS (TREE_CODE (head)) == 'r'
! || TREE_CODE_CLASS (TREE_CODE (head)) == 's')
&& TREE_OPERAND (head, 0))
TB_SET_HEAD (TREE_OPERAND (head, 0));
else
--- 441,447 ----
break;
case TB_CHILD_0:
! if (head && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
&& TREE_OPERAND (head, 0))
TB_SET_HEAD (TREE_OPERAND (head, 0));
else
*************** browse_tree (tree begin)
*** 451,459 ****
break;
case TB_CHILD_1:
! if (head && (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
! || TREE_CODE_CLASS (TREE_CODE (head)) == 'r'
! || TREE_CODE_CLASS (TREE_CODE (head)) == 's')
&& TREE_OPERAND (head, 1))
TB_SET_HEAD (TREE_OPERAND (head, 1));
else
--- 449,455 ----
break;
case TB_CHILD_1:
! if (head && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
&& TREE_OPERAND (head, 1))
TB_SET_HEAD (TREE_OPERAND (head, 1));
else
*************** browse_tree (tree begin)
*** 461,479 ****
break;
case TB_CHILD_2:
! if (head && (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
! || TREE_CODE_CLASS (TREE_CODE (head)) == 'r'
! || TREE_CODE_CLASS (TREE_CODE (head)) == 's')
&& TREE_OPERAND (head, 2))
TB_SET_HEAD (TREE_OPERAND (head, 2));
else
TB_WF;
! break;
case TB_CHILD_3:
! if (head && (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
! || TREE_CODE_CLASS (TREE_CODE (head)) == 'r'
! || TREE_CODE_CLASS (TREE_CODE (head)) == 's')
&& TREE_OPERAND (head, 3))
TB_SET_HEAD (TREE_OPERAND (head, 3));
else
--- 457,471 ----
break;
case TB_CHILD_2:
! if (head && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
&& TREE_OPERAND (head, 2))
TB_SET_HEAD (TREE_OPERAND (head, 2));
else
TB_WF;
! break;
case TB_CHILD_3:
! if (head && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (head)))
&& TREE_OPERAND (head, 3))
TB_SET_HEAD (TREE_OPERAND (head, 3));
else
*** ./tree-ssa-pre.c.~1~ 2003-08-05 22:11:25.000000000 -0400
--- ./tree-ssa-pre.c 2003-08-19 15:13:09.000000000 -0400
*************** defs_hash_expr (struct expr_info *ei, tr
*** 889,895 ****
else
abort ();
}
! else if (IS_EXPR_CODE_CLASS (class) || class == 'r')
{
val = iterative_hash_object (code, val);
--- 889,895 ----
else
abort ();
}
! else if (IS_EXPR_CODE_CLASS (class))
{
val = iterative_hash_object (code, val);