[33/50] reg-stack.c:subst_all_stack_regs_in_debug_insn
diff mbox

Message ID 87zjfl7j2q.fsf@googlemail.com
State New
Headers show

Commit Message

Richard Sandiford Aug. 3, 2014, 2:18 p.m. UTC
gcc/
	* reg-stack.c: Include rtl-iter.h.
	(subst_stack_regs_in_debug_insn): Delete.
	(subst_all_stack_regs_in_debug_insn): Use FOR_EACH_SUBRTX_PTR
	instead of for_each_rtx.

Comments

Jeff Law Aug. 5, 2014, 9:13 p.m. UTC | #1
On 08/03/14 08:18, Richard Sandiford wrote:
> gcc/
> 	* reg-stack.c: Include rtl-iter.h.
> 	(subst_stack_regs_in_debug_insn): Delete.
> 	(subst_all_stack_regs_in_debug_insn): Use FOR_EACH_SUBRTX_PTR
> 	instead of for_each_rtx.
OK.
Jeff

Patch
diff mbox

Index: gcc/reg-stack.c
===================================================================
--- gcc/reg-stack.c	2014-08-03 11:25:09.766952738 +0100
+++ gcc/reg-stack.c	2014-08-03 11:25:29.318146033 +0100
@@ -170,6 +170,7 @@ 
 #include "target.h"
 #include "df.h"
 #include "emit-rtl.h"  /* FIXME: Can go away once crtl is moved to rtl.h.  */
+#include "rtl-iter.h"
 
 #ifdef STACK_REGS
 
@@ -1307,31 +1308,6 @@  compare_for_stack_reg (rtx insn, stack_p
     }
 }
 
-/* Substitute new registers in LOC, which is part of a debug insn.
-   REGSTACK is the current register layout.  */
-
-static int
-subst_stack_regs_in_debug_insn (rtx *loc, void *data)
-{
-  stack_ptr regstack = (stack_ptr)data;
-  int hard_regno;
-
-  if (!STACK_REG_P (*loc))
-    return 0;
-
-  hard_regno = get_hard_regnum (regstack, *loc);
-
-  /* If we can't find an active register, reset this debug insn.  */
-  if (hard_regno == -1)
-    return 1;
-
-  gcc_assert (hard_regno >= FIRST_STACK_REG);
-
-  replace_reg (loc, hard_regno);
-
-  return -1;
-}
-
 /* Substitute hardware stack regs in debug insn INSN, using stack
    layout REGSTACK.  If we can't find a hardware stack reg for any of
    the REGs in it, reset the debug insn.  */
@@ -1339,14 +1315,27 @@  subst_stack_regs_in_debug_insn (rtx *loc
 static void
 subst_all_stack_regs_in_debug_insn (rtx insn, struct stack_def *regstack)
 {
-  int ret = for_each_rtx (&INSN_VAR_LOCATION_LOC (insn),
-			  subst_stack_regs_in_debug_insn,
-			  regstack);
+  subrtx_ptr_iterator::array_type array;
+  FOR_EACH_SUBRTX_PTR (iter, array, &INSN_VAR_LOCATION_LOC (insn), NONCONST)
+    {
+      rtx *loc = *iter;
+      rtx x = *loc;
+      if (STACK_REG_P (x))
+	{
+	  int hard_regno = get_hard_regnum (regstack, x);
 
-  if (ret == 1)
-    INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
-  else
-    gcc_checking_assert (ret == 0);
+	  /* If we can't find an active register, reset this debug insn.  */
+	  if (hard_regno == -1)
+	    {
+	      INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
+	      return;
+	    }
+
+	  gcc_assert (hard_regno >= FIRST_STACK_REG);
+	  replace_reg (loc, hard_regno);
+	  iter.skip_subrtxes ();
+	}
+    }
 }
 
 /* Substitute new registers in PAT, which is part of INSN.  REGSTACK