diff mbox

[ARC] RFA: Use new rtl iterators in small_data_pattern

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

Commit Message

Richard Sandiford Oct. 25, 2014, 9:54 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 arc-elf.  OK to install?

Thanks,
Richard


gcc/
	* config/arc/arc.c (arc_rewrite_small_data_p): Constify argument.
	(small_data_pattern_1): Delete.
	(small_data_pattern): Use FOR_EACH_SUBRTX.

Comments

Joern Rennecke Nov. 2, 2014, 6:30 p.m. UTC | #1
On 25 October 2014 10:54, Richard Sandiford <rdsandiford@googlemail.com> wrote:
> 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 arc-elf.  OK to install?

OK.
diff mbox

Patch

Index: gcc/config/arc/arc.c
===================================================================
--- gcc/config/arc/arc.c	2014-10-25 09:51:25.501884042 +0100
+++ gcc/config/arc/arc.c	2014-10-25 09:51:25.901887608 +0100
@@ -6337,7 +6337,7 @@  arc_in_small_data_p (const_tree decl)
    as a gp+symref.  */
 
 static bool
-arc_rewrite_small_data_p (rtx x)
+arc_rewrite_small_data_p (const_rtx x)
 {
   if (GET_CODE (x) == CONST)
     x = XEXP (x, 0);
@@ -6387,26 +6387,25 @@  arc_rewrite_small_data (rtx op)
   return op;
 }
 
-/* A for_each_rtx callback for small_data_pattern.  */
-
-static int
-small_data_pattern_1 (rtx *loc, void *data ATTRIBUTE_UNUSED)
-{
-  if (GET_CODE (*loc) == PLUS
-      && rtx_equal_p (XEXP (*loc, 0), pic_offset_table_rtx))
-    return  -1;
-
-  return arc_rewrite_small_data_p (*loc);
-}
-
 /* Return true if OP refers to small data symbols directly, not through
    a PLUS.  */
 
 bool
 small_data_pattern (rtx op, enum machine_mode)
 {
-  return (GET_CODE (op) != SEQUENCE
-	  && for_each_rtx (&op, small_data_pattern_1, 0));
+  if (GET_CODE (op) == SEQUENCE)
+    return false;
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, op, ALL)
+    {
+      const_rtx x = *iter;
+      if (GET_CODE (x) == PLUS
+	  && rtx_equal_p (XEXP (x, 0), pic_offset_table_rtx))
+	iter.skip_subrtxes ();
+      else if (arc_rewrite_small_data_p (x))
+	return true;
+    }
+  return false;
 }
 
 /* Return true if OP is an acceptable memory operand for ARCompact