diff mbox

[MIPS] RFA: Use new rtl iterators in mips16_rewrite_pool_refs

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

Commit Message

Richard Sandiford Oct. 25, 2014, 9:35 a.m. UTC
This is part of a series to remove uses of for_each_rtx from the ports.
Note that the order of the UNSPEC and TARGET_MIPS16_TEXT_LOADS handling
didn't matter because we never rewrite the unspec itself; the check is
there to protect the contents of the unspec.

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 (mips16_rewrite_pool_refs_info): Delete.
	(mips16_rewrite_pool_refs): Take the insn and constant pool as
	parameters.  Iterate over the instruction's pattern and return void.
	(mips16_lay_out_constants): Update accordingly.

Comments

Matthew Fortune Oct. 25, 2014, 8:54 p.m. UTC | #1
> gcc/
> 	* config/mips/mips.c (mips16_rewrite_pool_refs_info): Delete.
> 	(mips16_rewrite_pool_refs): Take the insn and constant pool as
> 	parameters.  Iterate over the instruction's pattern and return void.
> 	(mips16_lay_out_constants): Update accordingly.

OK
diff mbox

Patch

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2014-10-25 09:51:19.947834536 +0100
+++ gcc/config/mips/mips.c	2014-10-25 09:51:20.330837950 +0100
@@ -14778,44 +14778,39 @@  mips16_rewrite_pool_constant (struct mip
     }
 }
 
-/* This structure is used to communicate with mips16_rewrite_pool_refs.
-   INSN is the instruction we're rewriting and POOL points to the current
-   constant pool.  */
-struct mips16_rewrite_pool_refs_info {
-  rtx_insn *insn;
-  struct mips16_constant_pool *pool;
-};
-
-/* Rewrite *X so that constant pool references refer to the constant's
-   label instead.  DATA points to a mips16_rewrite_pool_refs_info
-   structure.  */
+/* Rewrite INSN so that constant pool references refer to the constant's
+   label instead.  */
 
-static int
-mips16_rewrite_pool_refs (rtx *x, void *data)
+static void
+mips16_rewrite_pool_refs (rtx_insn *insn, struct mips16_constant_pool *pool)
 {
-  struct mips16_rewrite_pool_refs_info *info =
-    (struct mips16_rewrite_pool_refs_info *) data;
-
-  if (force_to_mem_operand (*x, Pmode))
+  subrtx_ptr_iterator::array_type array;
+  FOR_EACH_SUBRTX_PTR (iter, array, &PATTERN (insn), ALL)
     {
-      rtx mem = force_const_mem (GET_MODE (*x), *x);
-      validate_change (info->insn, x, mem, false);
-    }
+      rtx *loc = *iter;
 
-  if (MEM_P (*x))
-    {
-      mips16_rewrite_pool_constant (info->pool, &XEXP (*x, 0));
-      return -1;
-    }
-
-  /* Don't rewrite the __mips16_rdwr symbol.  */
-  if (GET_CODE (*x) == UNSPEC && XINT (*x, 1) == UNSPEC_TLS_GET_TP)
-    return -1;
-
-  if (TARGET_MIPS16_TEXT_LOADS)
-    mips16_rewrite_pool_constant (info->pool, x);
+      if (force_to_mem_operand (*loc, Pmode))
+	{
+	  rtx mem = force_const_mem (GET_MODE (*loc), *loc);
+	  validate_change (insn, loc, mem, false);
+	}
 
-  return GET_CODE (*x) == CONST ? -1 : 0;
+      if (MEM_P (*loc))
+	{
+	  mips16_rewrite_pool_constant (pool, &XEXP (*loc, 0));
+	  iter.skip_subrtxes ();
+	}
+      else
+	{
+	  if (TARGET_MIPS16_TEXT_LOADS)
+	    mips16_rewrite_pool_constant (pool, loc);
+	  if (GET_CODE (*loc) == CONST
+	      /* Don't rewrite the __mips16_rdwr symbol.  */
+	      || (GET_CODE (*loc) == UNSPEC
+		  && XINT (*loc, 1) == UNSPEC_TLS_GET_TP))
+	    iter.skip_subrtxes ();
+	}
+    }
 }
 
 /* Return whether CFG is used in mips_reorg.  */
@@ -14834,7 +14829,6 @@  mips_cfg_in_reorg (void)
 mips16_lay_out_constants (bool split_p)
 {
   struct mips16_constant_pool pool;
-  struct mips16_rewrite_pool_refs_info info;
   rtx_insn *insn, *barrier;
 
   if (!TARGET_MIPS16_PCREL_LOADS)
@@ -14853,11 +14847,7 @@  mips16_lay_out_constants (bool split_p)
     {
       /* Rewrite constant pool references in INSN.  */
       if (USEFUL_INSN_P (insn))
-	{
-	  info.insn = insn;
-	  info.pool = &pool;
-	  for_each_rtx (&PATTERN (insn), mips16_rewrite_pool_refs, &info);
-	}
+	mips16_rewrite_pool_refs (insn, &pool);
 
       pool.insn_address += mips16_insn_length (insn);