diff mbox

Remove for_each_rtx

Message ID 87vbmlivy5.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Nov. 11, 2014, 3:44 p.m. UTC
There are no more callers to for_each_rtx or for_each_rtx_in_insn,
so this patch removes the functions.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
	* rtl.h (rtx_function, for_each_rtx, for_each_rtx_in_insn): Delete.
	* rtlanal.c (non_rtx_starting_operands, for_each_rtx_1, for_each_rtx):
	(for_each_rtx_in_insn): Delete.
	(init_rtlanal): Remove initialization of non_rtx_starting_operands.
	* df-core.c: Remove reference to for_each_rtx in comment.

Comments

Jeff Law Nov. 11, 2014, 4:26 p.m. UTC | #1
On 11/11/14 08:44, Richard Sandiford wrote:
> There are no more callers to for_each_rtx or for_each_rtx_in_insn,
> so this patch removes the functions.
>
> Tested on x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> 	* rtl.h (rtx_function, for_each_rtx, for_each_rtx_in_insn): Delete.
> 	* rtlanal.c (non_rtx_starting_operands, for_each_rtx_1, for_each_rtx):
> 	(for_each_rtx_in_insn): Delete.
> 	(init_rtlanal): Remove initialization of non_rtx_starting_operands.
> 	* df-core.c: Remove reference to for_each_rtx in comment.
Yes.  And in general, I think removing an unused, non-debug function 
ought to be considered obvious to install w/o review.

While there's some concern about breaking out-of-tree ports, I think 
getting the dead code out of GCC proper trumps that concern.   There's a 
path forward for out-of-tree ports and it's the natural cost of keeping 
a port out-of-tree.

jeff
diff mbox

Patch

diff --git a/gcc/df-core.c b/gcc/df-core.c
index 691ed71..8e7a92f 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -181,7 +181,7 @@  There are four ways of doing the incremental scanning:
    next call to df_analyze or df_process_deferred_rescans.
 
    This mode is also used by a few passes that still rely on note_uses,
-   note_stores and for_each_rtx instead of using the DF data.  This
+   note_stores and rtx iterators instead of using the DF data.  This
    can be said to fall under case 1c.
 
    To enable this mode, call df_set_flags (DF_DEFER_INSN_RESCAN).
diff --git a/gcc/rtl.h b/gcc/rtl.h
index fa38abb..3bfb6bf 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2885,10 +2885,6 @@  extern bool tablejump_p (const rtx_insn *, rtx *, rtx_jump_table_data **);
 extern int computed_jump_p (const_rtx);
 extern bool tls_referenced_p (const_rtx);
 
-typedef int (*rtx_function) (rtx *, void *);
-extern int for_each_rtx (rtx *, rtx_function, void *);
-extern int for_each_rtx_in_insn (rtx_insn **, rtx_function, void *);
-
 /* Callback for for_each_inc_dec, to process the autoinc operation OP
    within MEM that sets DEST to SRC + SRCOFF, or SRC if SRCOFF is
    NULL.  The callback is passed the same opaque ARG passed to
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index c9bf69c..49c2d4e 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -65,10 +65,6 @@  static unsigned int cached_num_sign_bit_copies (const_rtx, machine_mode, const_r
 static unsigned int num_sign_bit_copies1 (const_rtx, machine_mode, const_rtx,
                                           machine_mode, unsigned int);
 
-/* Offset of the first 'e', 'E' or 'V' operand for each rtx code, or
-   -1 if a code has no such operand.  */
-static int non_rtx_starting_operands[NUM_RTX_CODE];
-
 rtx_subrtx_bound_info rtx_all_subrtx_bounds[NUM_RTX_CODE];
 rtx_subrtx_bound_info rtx_nonconst_subrtx_bounds[NUM_RTX_CODE];
 
@@ -3020,137 +3016,6 @@  computed_jump_p (const_rtx insn)
   return 0;
 }
 
-/* Optimized loop of for_each_rtx, trying to avoid useless recursive
-   calls.  Processes the subexpressions of EXP and passes them to F.  */
-static int
-for_each_rtx_1 (rtx exp, int n, rtx_function f, void *data)
-{
-  int result, i, j;
-  const char *format = GET_RTX_FORMAT (GET_CODE (exp));
-  rtx *x;
-
-  for (; format[n] != '\0'; n++)
-    {
-      switch (format[n])
-	{
-	case 'e':
-	  /* Call F on X.  */
-	  x = &XEXP (exp, n);
-	  result = (*f) (x, data);
-	  if (result == -1)
-	    /* Do not traverse sub-expressions.  */
-	    continue;
-	  else if (result != 0)
-	    /* Stop the traversal.  */
-	    return result;
-
-	  if (*x == NULL_RTX)
-	    /* There are no sub-expressions.  */
-	    continue;
-
-	  i = non_rtx_starting_operands[GET_CODE (*x)];
-	  if (i >= 0)
-	    {
-	      result = for_each_rtx_1 (*x, i, f, data);
-	      if (result != 0)
-		return result;
-	    }
-	  break;
-
-	case 'V':
-	case 'E':
-	  if (XVEC (exp, n) == 0)
-	    continue;
-	  for (j = 0; j < XVECLEN (exp, n); ++j)
-	    {
-	      /* Call F on X.  */
-	      x = &XVECEXP (exp, n, j);
-	      result = (*f) (x, data);
-	      if (result == -1)
-		/* Do not traverse sub-expressions.  */
-		continue;
-	      else if (result != 0)
-		/* Stop the traversal.  */
-		return result;
-
-	      if (*x == NULL_RTX)
-		/* There are no sub-expressions.  */
-		continue;
-
-	      i = non_rtx_starting_operands[GET_CODE (*x)];
-	      if (i >= 0)
-		{
-		  result = for_each_rtx_1 (*x, i, f, data);
-		  if (result != 0)
-		    return result;
-	        }
-	    }
-	  break;
-
-	default:
-	  /* Nothing to do.  */
-	  break;
-	}
-    }
-
-  return 0;
-}
-
-/* Traverse X via depth-first search, calling F for each
-   sub-expression (including X itself).  F is also passed the DATA.
-   If F returns -1, do not traverse sub-expressions, but continue
-   traversing the rest of the tree.  If F ever returns any other
-   nonzero value, stop the traversal, and return the value returned
-   by F.  Otherwise, return 0.  This function does not traverse inside
-   tree structure that contains RTX_EXPRs, or into sub-expressions
-   whose format code is `0' since it is not known whether or not those
-   codes are actually RTL.
-
-   This routine is very general, and could (should?) be used to
-   implement many of the other routines in this file.  */
-
-int
-for_each_rtx (rtx *x, rtx_function f, void *data)
-{
-  int result;
-  int i;
-
-  /* Call F on X.  */
-  result = (*f) (x, data);
-  if (result == -1)
-    /* Do not traverse sub-expressions.  */
-    return 0;
-  else if (result != 0)
-    /* Stop the traversal.  */
-    return result;
-
-  if (*x == NULL_RTX)
-    /* There are no sub-expressions.  */
-    return 0;
-
-  i = non_rtx_starting_operands[GET_CODE (*x)];
-  if (i < 0)
-    return 0;
-
-  return for_each_rtx_1 (*x, i, f, data);
-}
-
-/* Like "for_each_rtx", but for calling on an rtx_insn **.  */
-
-int
-for_each_rtx_in_insn (rtx_insn **insn, rtx_function f, void *data)
-{
-  rtx insn_as_rtx = *insn;
-  int result;
-
-  result = for_each_rtx (&insn_as_rtx, f, data);
-
-  if (insn_as_rtx != *insn)
-    *insn = safe_as_a <rtx_insn *> (insn_as_rtx);
-
-  return result;
-}
-
 
 
 /* MEM has a PRE/POST-INC/DEC/MODIFY address X.  Extract the operands of
@@ -5496,17 +5361,13 @@  setup_reg_subrtx_bounds (unsigned int code)
   return true;
 }
 
-/* Initialize non_rtx_starting_operands, which is used to speed up
-   for_each_rtx, and rtx_all_subrtx_bounds.  */
+/* Initialize rtx_all_subrtx_bounds.  */
 void
 init_rtlanal (void)
 {
   int i;
   for (i = 0; i < NUM_RTX_CODE; i++)
     {
-      const char *format = GET_RTX_FORMAT (i);
-      const char *first = strpbrk (format, "eEV");
-      non_rtx_starting_operands[i] = first ? first - format : -1;
       if (!setup_reg_subrtx_bounds (i))
 	rtx_all_subrtx_bounds[i].count = UCHAR_MAX;
       if (GET_RTX_CLASS (i) != RTX_CONST_OBJ)