This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Replace first_rtl_op with TREE_CODE_LENGTH - Part 1/2


Hi,

Attached is a patch to replace first_rtl_op with TREE_CODE_LENGTH as
the function has become as boring as

int
first_rtl_op (enum tree_code code)
{
  switch (code)
    {
    default:
      return TREE_CODE_LENGTH (code);
    }
}

It used to have non-default cases, but ever since this July, this
function has had the default case only.  I don't think we want to have
call overhead for this sort of thing.

This patch does mechanical replacement only.  The next patch will
clean/speed up some places where the value of TREE_CODE_LENGTH is
known.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

gcc/
2004-12-07  Kazu Hirata  <kazu@cs.umass.edu>

	* c-common.c, expr.c, fold-const.c, print-tree.c,
	tree-gimple.c, tree-inline.c, tree-pretty-print.c,
	tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c: Replace uses of
	first_rtl_op with TREE_CODE_LENGTH.
	* tree.c (first_rtl_op): Remove.
	Replace uses of first_rtl_op with TREE_CODE_LENGTH.
	* tree.h: Remove the prototype for first_rtl_op.

gcc/cp/
2004-12-07  Kazu Hirata  <kazu@cs.umass.edu>

	* pt.c: Replace a use of first_rtl_op with TREE_CODE_LENGTH.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.589
diff -u -d -p -r1.589 c-common.c
--- c-common.c	29 Nov 2004 23:11:23 -0000	1.589
+++ c-common.c	7 Dec 2004 15:01:49 -0000
@@ -1365,7 +1365,7 @@ verify_tree (tree x, struct tlist **pbef
 	 Other non-expressions need not be processed.  */
       if (cl == tcc_unary)
 	{
-	  if (first_rtl_op (code) == 0)
+	  if (TREE_CODE_LENGTH (code) == 0)
 	    return;
 	  x = TREE_OPERAND (x, 0);
 	  writer = 0;
@@ -1374,7 +1374,7 @@ verify_tree (tree x, struct tlist **pbef
       else if (IS_EXPR_CODE_CLASS (cl))
 	{
 	  int lp;
-	  int max = first_rtl_op (TREE_CODE (x));
+	  int max = TREE_CODE_LENGTH (TREE_CODE (x));
 	  for (lp = 0; lp < max; lp++)
 	    {
 	      tmp_before = tmp_nosp = 0;
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.756
diff -u -d -p -r1.756 expr.c
--- expr.c	6 Dec 2004 18:52:10 -0000	1.756
+++ expr.c	7 Dec 2004 15:01:50 -0000
@@ -5944,7 +5944,7 @@ safe_from_p (rtx x, tree exp, int top_p)
       if (exp_rtl)
 	break;
 
-      nops = first_rtl_op (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))
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.482
diff -u -d -p -r1.482 fold-const.c
--- fold-const.c	30 Nov 2004 20:33:34 -0000	1.482
+++ fold-const.c	7 Dec 2004 15:01:52 -0000
@@ -3550,7 +3550,7 @@ make_range (tree exp, int *pin_p, tree *
 
       if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
 	{
-	  if (first_rtl_op (code) > 0)
+	  if (TREE_CODE_LENGTH (code) > 0)
 	    arg0 = TREE_OPERAND (exp, 0);
 	  if (TREE_CODE_CLASS (code) == tcc_comparison
 	      || TREE_CODE_CLASS (code) == tcc_unary
@@ -6277,7 +6277,7 @@ fold (tree expr)
     }
   else if (IS_EXPR_CODE_CLASS (kind))
     {
-      int len = first_rtl_op (code);
+      int len = TREE_CODE_LENGTH (code);
       int i;
       for (i = 0; i < len; i++)
 	{
@@ -9418,7 +9418,7 @@ fold_checksum_tree (tree expr, struct md
     case tcc_unary:
     case tcc_binary:
     case tcc_statement:
-      len = first_rtl_op (code);
+      len = TREE_CODE_LENGTH (code);
       for (i = 0; i < len; ++i)
 	fold_checksum_tree (TREE_OPERAND (expr, i), ctx, ht);
       break;
Index: print-tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/print-tree.c,v
retrieving revision 1.94
diff -u -d -p -r1.94 print-tree.c
--- print-tree.c	17 Sep 2004 21:54:36 -0000	1.94
+++ print-tree.c	7 Dec 2004 15:01:52 -0000
@@ -593,7 +593,7 @@ print_node (FILE *file, const char *pref
 
       /* 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));
+      first_rtl = TREE_CODE_LENGTH (TREE_CODE (node));
 
       for (i = 0; i < len; i++)
 	{
Index: tree-gimple.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-gimple.c,v
retrieving revision 2.31
diff -u -d -p -r2.31 tree-gimple.c
--- tree-gimple.c	30 Nov 2004 03:52:37 -0000	2.31
+++ tree-gimple.c	7 Dec 2004 15:01:52 -0000
@@ -443,7 +443,7 @@ void
 recalculate_side_effects (tree t)
 {
   enum tree_code code = TREE_CODE (t);
-  int fro = first_rtl_op (code);
+  int fro = TREE_CODE_LENGTH (code);
   int i;
 
   switch (TREE_CODE_CLASS (code))
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.153
diff -u -d -p -r1.153 tree-inline.c
--- tree-inline.c	28 Nov 2004 14:02:56 -0000	1.153
+++ tree-inline.c	7 Dec 2004 15:01:53 -0000
@@ -1391,7 +1391,7 @@ expand_call_inline (tree *tp, int *walk_
   if (TREE_CODE (*tp) == TARGET_EXPR)
     {
 #if 0
-      int i, len = first_rtl_op (TARGET_EXPR);
+      int i, len = TREE_CODE_LENGTH (TARGET_EXPR);
 
       /* We're walking our own subtrees.  */
       *walk_subtrees = 0;
@@ -2088,7 +2088,7 @@ walk_tree (tree *tp, walk_tree_fn func, 
       int i, len;
 
       /* Walk over all the sub-trees of this operand.  */
-      len = first_rtl_op (code);
+      len = TREE_CODE_LENGTH (code);
       /* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
 	 But, we only want to walk once.  */
       if (code == TARGET_EXPR
Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pretty-print.c,v
retrieving revision 2.49
diff -u -d -p -r2.49 tree-pretty-print.c
--- tree-pretty-print.c	24 Nov 2004 16:10:06 -0000	2.49
+++ tree-pretty-print.c	7 Dec 2004 15:01:53 -0000
@@ -72,7 +72,7 @@ do_niy (pretty_printer *buffer, tree nod
 
   if (EXPR_P (node))
     {
-      len = first_rtl_op (TREE_CODE (node));
+      len = TREE_CODE_LENGTH (TREE_CODE (node));
       for (i = 0; i < len; ++i)
 	{
 	  newline_and_indent (buffer, 2);
Index: tree-ssa-loop-im.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-im.c,v
retrieving revision 2.23
diff -u -d -p -r2.23 tree-ssa-loop-im.c
--- tree-ssa-loop-im.c	16 Nov 2004 00:08:04 -0000	2.23
+++ tree-ssa-loop-im.c	7 Dec 2004 15:01:53 -0000
@@ -283,7 +283,7 @@ outermost_invariant_loop_expr (tree expr
       && class != tcc_comparison)
     return NULL;
 
-  nops = first_rtl_op (TREE_CODE (expr));
+  nops = TREE_CODE_LENGTH (TREE_CODE (expr));
   for (i = 0; i < nops; i++)
     {
       aloop = outermost_invariant_loop_expr (TREE_OPERAND (expr, i), loop);
@@ -743,7 +743,7 @@ force_move_till_expr (tree expr, struct 
       && class != tcc_comparison)
     return;
 
-  nops = first_rtl_op (TREE_CODE (expr));
+  nops = TREE_CODE_LENGTH (TREE_CODE (expr));
   for (i = 0; i < nops; i++)
     force_move_till_expr (TREE_OPERAND (expr, i), orig_loop, loop);
 }
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.34
diff -u -d -p -r2.34 tree-ssa-loop-ivopts.c
--- tree-ssa-loop-ivopts.c	30 Nov 2004 03:52:37 -0000	2.34
+++ tree-ssa-loop-ivopts.c	7 Dec 2004 15:01:54 -0000
@@ -1270,7 +1270,7 @@ expr_invariant_in_loop_p (struct loop *l
   if (!EXPR_P (expr))
     return false;
 
-  len = first_rtl_op (TREE_CODE (expr));
+  len = TREE_CODE_LENGTH (TREE_CODE (expr));
   for (i = 0; i < len; i++)
     if (!expr_invariant_in_loop_p (loop, TREE_OPERAND (expr, i)))
       return false;
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.453
diff -u -d -p -r1.453 tree.c
--- tree.c	2 Dec 2004 19:25:55 -0000	1.453
+++ tree.c	7 Dec 2004 15:01:55 -0000
@@ -1734,19 +1734,6 @@ skip_simple_arithmetic (tree expr)
   return inner;
 }
 
-/* Returns the index of the first non-tree operand for CODE, or the number
-   of operands if all are trees.  */
-
-int
-first_rtl_op (enum tree_code code)
-{
-  switch (code)
-    {
-    default:
-      return TREE_CODE_LENGTH (code);
-    }
-}
-
 /* Return which tree structure is used by T.  */
 
 enum tree_node_structure_enum
@@ -1845,7 +1832,7 @@ contains_placeholder_p (tree exp)
 	  break;
 	}
 
-      switch (first_rtl_op (code))
+      switch (TREE_CODE_LENGTH (code))
 	{
 	case 1:
 	  return CONTAINS_PLACEHOLDER_P (TREE_OPERAND (exp, 0));
@@ -2012,7 +1999,7 @@ substitute_in_expr (tree exp, tree f, tr
       case tcc_comparison:
       case tcc_expression:
       case tcc_reference:
-	switch (first_rtl_op (code))
+	switch (TREE_CODE_LENGTH (code))
 	  {
 	  case 0:
 	    return exp;
@@ -2132,7 +2119,7 @@ substitute_placeholder_in_expr (tree exp
       case tcc_expression:
       case tcc_reference:
       case tcc_statement:
-	switch (first_rtl_op (code))
+	switch (TREE_CODE_LENGTH (code))
 	  {
 	  case 0:
 	    return exp;
@@ -2508,7 +2495,7 @@ build1_stat (enum tree_code code, tree t
   TREE_COMPLEXITY (t) = 0;
   TREE_OPERAND (t, 0) = node;
   TREE_BLOCK (t) = NULL_TREE;
-  if (node && !TYPE_P (node) && first_rtl_op (code) != 0)
+  if (node && !TYPE_P (node) && TREE_CODE_LENGTH (code) != 0)
     {
       TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (node);
       TREE_READONLY (t) = TREE_READONLY (node);
@@ -2593,7 +2580,7 @@ build2_stat (enum tree_code code, tree t
      result based on those same flags for the arguments.  But if the
      arguments aren't really even `tree' expressions, we shouldn't be trying
      to do this.  */
-  fro = first_rtl_op (code);
+  fro = TREE_CODE_LENGTH (code);
 
   /* Expressions without side effects may be constant if their
      arguments are as well.  */
@@ -2630,7 +2617,7 @@ build3_stat (enum tree_code code, tree t
   t = make_node_stat (code PASS_MEM_STAT);
   TREE_TYPE (t) = tt;
 
-  fro = first_rtl_op (code);
+  fro = TREE_CODE_LENGTH (code);
 
   side_effects = TREE_SIDE_EFFECTS (t);
 
@@ -2679,7 +2666,7 @@ build4_stat (enum tree_code code, tree t
   t = make_node_stat (code PASS_MEM_STAT);
   TREE_TYPE (t) = tt;
 
-  fro = first_rtl_op (code);
+  fro = TREE_CODE_LENGTH (code);
 
   side_effects = TREE_SIDE_EFFECTS (t);
 
@@ -4196,7 +4183,7 @@ iterative_hash_expr (tree t, hashval_t v
 	      val = iterative_hash_hashval_t (two, val);
 	    }
 	  else
-	    for (i = first_rtl_op (code) - 1; i >= 0; --i)
+	    for (i = TREE_CODE_LENGTH (code) - 1; i >= 0; --i)
 	      val = iterative_hash_expr (TREE_OPERAND (t, i), val);
 	}
       return val;
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.663
diff -u -d -p -r1.663 tree.h
--- tree.h	4 Dec 2004 14:11:45 -0000	1.663
+++ tree.h	7 Dec 2004 15:01:56 -0000
@@ -3279,11 +3279,6 @@ extern tree save_expr (tree);
 
 extern tree skip_simple_arithmetic (tree);
 
-/* Returns the index of the first non-tree operand for CODE, or the number
-   of operands if all are trees.  */
-
-extern int first_rtl_op (enum tree_code);
-
 /* Return which tree structure is used by T.  */
 
 enum tree_node_structure_enum tree_node_structure (tree);
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.954
diff -u -d -p -r1.954 pt.c
--- cp/pt.c	4 Dec 2004 06:45:06 -0000	1.954
+++ cp/pt.c	7 Dec 2004 15:01:58 -0000
@@ -12010,7 +12010,7 @@ value_dependent_expression_p (tree expre
 	case tcc_expression:
 	  {
 	    int i;
-	    for (i = 0; i < first_rtl_op (TREE_CODE (expression)); ++i)
+	    for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (expression)); ++i)
 	      /* In some cases, some of the operands may be missing.
 		 (For example, in the case of PREDECREMENT_EXPR, the
 		 amount to increment by may be missing.)  That doesn't


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]