This is part of a series to remove uses of for_each_rtx from the ports.

Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
and g++.dg for m68k-elf.  OK to install?

Thanks,
Richard


gcc/
        * config/m68k/m68k.c: Include rtl-iter.h.
        (m68k_final_prescan_insn_1): Delete.
        (m68k_final_prescan_insn): Use FOR_EACH_SUBRTX_VAR.

Index: gcc/config/m68k/m68k.c
===================================================================
--- gcc/config/m68k/m68k.c      2014-10-25 09:48:52.914536337 +0100
+++ gcc/config/m68k/m68k.c      2014-10-25 09:51:16.781806316 +0100
@@ -55,6 +55,7 @@ the Free Software Foundation; either ver
 #include "opts.h"
 #include "optabs.h"
 #include "builtins.h"
+#include "rtl-iter.h"
 
 enum reg_class regno_reg_class[] =
 {
@@ -2279,49 +2280,6 @@ m68k_unwrap_symbol (rtx orig, bool unwra
   return m68k_unwrap_symbol_1 (orig, unwrap_reloc32_p, NULL);
 }
 
-/* Helper for m68k_final_prescan_insn.  */
-
-static int
-m68k_final_prescan_insn_1 (rtx *x_ptr, void *data ATTRIBUTE_UNUSED)
-{
-  rtx x = *x_ptr;
-
-  if (m68k_unwrap_symbol (x, true) != x)
-    /* For rationale of the below, see comment in m68k_final_prescan_insn.  */
-    {
-      rtx plus;
-
-      gcc_assert (GET_CODE (x) == CONST);
-      plus = XEXP (x, 0);
-
-      if (GET_CODE (plus) == PLUS || GET_CODE (plus) == MINUS)
-       {
-         rtx unspec;
-         rtx addend;
-
-         unspec = XEXP (plus, 0);
-         gcc_assert (GET_CODE (unspec) == UNSPEC);
-         addend = XEXP (plus, 1);
-         gcc_assert (CONST_INT_P (addend));
-
-         /* We now have all the pieces, rearrange them.  */
-
-         /* Move symbol to plus.  */
-         XEXP (plus, 0) = XVECEXP (unspec, 0, 0);
-
-         /* Move plus inside unspec.  */
-         XVECEXP (unspec, 0, 0) = plus;
-
-         /* Move unspec to top level of const.  */
-         XEXP (x, 0) = unspec;
-       }
-
-      return -1;
-    }
-
-  return 0;
-}
-
 /* Prescan insn before outputing assembler for it.  */
 
 void
@@ -2347,13 +2305,47 @@ m68k_final_prescan_insn (rtx_insn *insn
      Note, that the top level of operand remains intact, so we don't have
      to patch up anything outside of the operand.  */
 
+  subrtx_var_iterator::array_type array;
   for (i = 0; i < n_operands; ++i)
     {
       rtx op;
 
       op = operands[i];
 
-      for_each_rtx (&op, m68k_final_prescan_insn_1, NULL);
+      FOR_EACH_SUBRTX_VAR (iter, array, op, ALL)
+       {
+         rtx x = *iter;
+         if (m68k_unwrap_symbol (x, true) != x)
+           {
+             rtx plus;
+
+             gcc_assert (GET_CODE (x) == CONST);
+             plus = XEXP (x, 0);
+
+             if (GET_CODE (plus) == PLUS || GET_CODE (plus) == MINUS)
+               {
+                 rtx unspec;
+                 rtx addend;
+
+                 unspec = XEXP (plus, 0);
+                 gcc_assert (GET_CODE (unspec) == UNSPEC);
+                 addend = XEXP (plus, 1);
+                 gcc_assert (CONST_INT_P (addend));
+
+                 /* We now have all the pieces, rearrange them.  */
+
+                 /* Move symbol to plus.  */
+                 XEXP (plus, 0) = XVECEXP (unspec, 0, 0);
+
+                 /* Move plus inside unspec.  */
+                 XVECEXP (unspec, 0, 0) = plus;
+
+                 /* Move unspec to top level of const.  */
+                 XEXP (x, 0) = unspec;
+               }
+             iter.skip_subrtxes ();
+           }
+       }
     }
 }
 

Reply via email to