[FRV] RFA: Use new rtl iterators in frv_registers_conflict_p_1
diff mbox

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

Commit Message

Richard Sandiford Oct. 25, 2014, 9:48 a.m. UTC
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 frv-elf.  OK to install?

Thanks,
Richard


gcc/
	* config/frv/frv.c (frv_registers_conflict_p_1): Take an rtx rather
	than an rtx *.  Take the regstate_t directly rather than via a void *.
	Return a bool rather than an int.  Iterate over all subrtxes here.
	(frv_registers_conflict_p): Update accordingly.

Patch
diff mbox

Index: gcc/config/frv/frv.c
===================================================================
--- gcc/config/frv/frv.c	2014-10-25 09:51:23.053862222 +0100
+++ gcc/config/frv/frv.c	2014-10-25 09:51:23.450865761 +0100
@@ -334,7 +334,6 @@  static unsigned int frv_insn_unit		(rtx_
 static bool frv_issues_to_branch_unit_p		(rtx_insn *);
 static int frv_cond_flags 			(rtx);
 static bool frv_regstate_conflict_p 		(regstate_t, regstate_t);
-static int frv_registers_conflict_p_1 		(rtx *, void *);
 static bool frv_registers_conflict_p 		(rtx);
 static void frv_registers_update_1 		(rtx, const_rtx, void *);
 static void frv_registers_update 		(rtx);
@@ -7162,53 +7161,49 @@  frv_regstate_conflict_p (regstate_t cond
 }
 
 
-/* A for_each_rtx callback.  Return 1 if *X depends on an instruction in
-   the current packet.  DATA points to a regstate_t that describes the
-   condition under which *X might be set or used.  */
+/* Return true if an instruction with pattern PAT depends on an
+   instruction in the current packet.  COND describes the condition
+   under which PAT might be set or used.  */
 
-static int
-frv_registers_conflict_p_1 (rtx *x, void *data)
+static bool
+frv_registers_conflict_p_1 (rtx pat, regstate_t cond)
 {
-  unsigned int regno, i;
-  regstate_t cond;
-
-  cond = *(regstate_t *) data;
-
-  if (GET_CODE (*x) == REG)
-    FOR_EACH_REGNO (regno, *x)
-      if ((frv_packet.regstate[regno] & REGSTATE_MODIFIED) != 0)
-	if (frv_regstate_conflict_p (frv_packet.regstate[regno], cond))
-	  return 1;
-
-  if (GET_CODE (*x) == MEM)
+  subrtx_var_iterator::array_type array;
+  FOR_EACH_SUBRTX_VAR (iter, array, pat, NONCONST)
     {
-      /* If we ran out of memory slots, assume a conflict.  */
-      if (frv_packet.num_mems > ARRAY_SIZE (frv_packet.mems))
-	return 1;
+      rtx x = *iter;
+      if (GET_CODE (x) == REG)
+	{
+	  unsigned int regno;
+	  FOR_EACH_REGNO (regno, x)
+	    if ((frv_packet.regstate[regno] & REGSTATE_MODIFIED) != 0)
+	      if (frv_regstate_conflict_p (frv_packet.regstate[regno], cond))
+		return true;
+	}
+      else if (GET_CODE (x) == MEM)
+	{
+	  /* If we ran out of memory slots, assume a conflict.  */
+	  if (frv_packet.num_mems > ARRAY_SIZE (frv_packet.mems))
+	    return 1;
 
-      /* Check for output or true dependencies with earlier MEMs.  */
-      for (i = 0; i < frv_packet.num_mems; i++)
-	if (frv_regstate_conflict_p (frv_packet.mems[i].cond, cond))
-	  {
-	    if (true_dependence (frv_packet.mems[i].mem, VOIDmode, *x))
-	      return 1;
+	  /* Check for output or true dependencies with earlier MEMs.  */
+	  for (unsigned int i = 0; i < frv_packet.num_mems; i++)
+	    if (frv_regstate_conflict_p (frv_packet.mems[i].cond, cond))
+	      {
+		if (true_dependence (frv_packet.mems[i].mem, VOIDmode, x))
+		  return true;
 
-	    if (output_dependence (frv_packet.mems[i].mem, *x))
-	      return 1;
-	  }
-    }
+		if (output_dependence (frv_packet.mems[i].mem, x))
+		  return true;
+	      }
+	}
 
-  /* The return values of calls aren't significant: they describe
-     the effect of the call as a whole, not of the insn itself.  */
-  if (GET_CODE (*x) == SET && GET_CODE (SET_SRC (*x)) == CALL)
-    {
-      if (for_each_rtx (&SET_SRC (*x), frv_registers_conflict_p_1, data))
-	return 1;
-      return -1;
+      /* The return values of calls aren't significant: they describe
+	 the effect of the call as a whole, not of the insn itself.  */
+      else if (GET_CODE (x) == SET && GET_CODE (SET_SRC (x)) == CALL)
+	iter.substitute (SET_SRC (x));
     }
-
-  /* Check subexpressions.  */
-  return 0;
+  return false;
 }
 
 
@@ -7223,13 +7218,13 @@  frv_registers_conflict_p (rtx x)
   flags = 0;
   if (GET_CODE (x) == COND_EXEC)
     {
-      if (for_each_rtx (&XEXP (x, 0), frv_registers_conflict_p_1, &flags))
+      if (frv_registers_conflict_p_1 (XEXP (x, 0), flags))
 	return true;
 
       flags |= frv_cond_flags (XEXP (x, 0));
       x = XEXP (x, 1);
     }
-  return for_each_rtx (&x, frv_registers_conflict_p_1, &flags);
+  return frv_registers_conflict_p_1 (x, flags);
 }