diff mbox

[MIPS] RFA: Use new rtl iterators in mips_rewrite_small_data

Message ID 874muszed3.fsf@googlemail.com
State New
Headers show

Commit Message

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

Thanks,
Richard


gcc/
	* config/mips/mips.c (mips_rewrite_small_data_1): Take the context
	as a parameter instead of the containing MEM.  Iterate over all
	subrtxes.  Don't return a value.
	(mips_rewrite_small_data): Update call accordingly.

Comments

Matthew Fortune Oct. 25, 2014, 8:53 p.m. UTC | #1
> gcc/
> 	* config/mips/mips.c (mips_rewrite_small_data_1): Take the context
> 	as a parameter instead of the containing MEM.  Iterate over all
> 	subrtxes.  Don't return a value.
> 	(mips_rewrite_small_data): Update call accordingly.

OK
diff mbox

Patch

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2014-10-25 09:51:19.145827388 +0100
+++ gcc/config/mips/mips.c	2014-10-25 09:51:19.543830935 +0100
@@ -3487,28 +3487,29 @@  mips_small_data_pattern_p (rtx op)
   return mips_small_data_pattern_1 (op, SYMBOL_CONTEXT_LEA);
 }
 
-/* A for_each_rtx callback, used by mips_rewrite_small_data.
-   DATA is the containing MEM, or null if none.  */
+/* Rewrite *LOC so that it refers to small data using explicit
+   relocations.  CONTEXT is the context in which *LOC appears.  */
 
-static int
-mips_rewrite_small_data_1 (rtx *loc, void *data)
+static void
+mips_rewrite_small_data_1 (rtx *loc, enum mips_symbol_context context)
 {
-  enum mips_symbol_context context;
-
-  if (MEM_P (*loc))
+  subrtx_ptr_iterator::array_type array;
+  FOR_EACH_SUBRTX_PTR (iter, array, loc, ALL)
     {
-      for_each_rtx (&XEXP (*loc, 0), mips_rewrite_small_data_1, *loc);
-      return -1;
+      rtx *loc = *iter;
+      if (MEM_P (*loc))
+	{
+	  mips_rewrite_small_data_1 (&XEXP (*loc, 0), SYMBOL_CONTEXT_MEM);
+	  iter.skip_subrtxes ();
+	}
+      else if (mips_rewrite_small_data_p (*loc, context))
+	{
+	  *loc = gen_rtx_LO_SUM (Pmode, pic_offset_table_rtx, *loc);
+	  iter.skip_subrtxes ();
+	}
+      else if (GET_CODE (*loc) == LO_SUM)
+	iter.skip_subrtxes ();
     }
-
-  context = data ? SYMBOL_CONTEXT_MEM : SYMBOL_CONTEXT_LEA;
-  if (mips_rewrite_small_data_p (*loc, context))
-    *loc = gen_rtx_LO_SUM (Pmode, pic_offset_table_rtx, *loc);
-
-  if (GET_CODE (*loc) == LO_SUM)
-    return -1;
-
-  return 0;
 }
 
 /* Rewrite instruction pattern PATTERN so that it refers to small data
@@ -3518,7 +3519,7 @@  mips_rewrite_small_data_1 (rtx *loc, voi
 mips_rewrite_small_data (rtx pattern)
 {
   pattern = copy_insn (pattern);
-  for_each_rtx (&pattern, mips_rewrite_small_data_1, NULL);
+  mips_rewrite_small_data_1 (&pattern, SYMBOL_CONTEXT_LEA);
   return pattern;
 }