[xtensa] RFA: Use new rtl iterators in xtensa_tls_referenced_p
diff mbox

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

Commit Message

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

Thanks,
Richard


gcc/
	* config/xtensa/xtensa.c: Include rtl-iter.h.
	(xtensa_tls_referenced_p_1): Delete.
	(xtensa_tls_referenced_p): Use FOR_EACH_SUBRTX.

Comments

augustine.sterling@gmail.com Oct. 25, 2014, 7:56 p.m. UTC | #1
On Sat, Oct 25, 2014 at 2:17 AM, 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 xtensa-elf.  OK to install?

OK for Xtensa

Patch
diff mbox

Index: gcc/config/xtensa/xtensa.c
===================================================================
--- gcc/config/xtensa/xtensa.c	2014-10-25 09:48:52.858535844 +0100
+++ gcc/config/xtensa/xtensa.c	2014-10-25 09:51:17.602813634 +0100
@@ -66,6 +66,7 @@  Software Foundation; either version 3, o
 #include "gimplify.h"
 #include "df.h"
 #include "builtins.h"
+#include "rtl-iter.h"
 
 
 /* Enumeration for all of the relational tests, so that we can build
@@ -1986,34 +1987,6 @@  xtensa_mode_dependent_address_p (const_r
   return constantpool_address_p (addr);
 }
 
-/* Helper for xtensa_tls_referenced_p.  */
-
-static int
-xtensa_tls_referenced_p_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
-{
-  if (GET_CODE (*x) == SYMBOL_REF)
-    return SYMBOL_REF_TLS_MODEL (*x) != 0;
-
-  /* Ignore TLS references that have already been legitimized.  */
-  if (GET_CODE (*x) == UNSPEC)
-    {
-      switch (XINT (*x, 1))
-	{
-	case UNSPEC_TPOFF:
-	case UNSPEC_DTPOFF:
-	case UNSPEC_TLS_FUNC:
-	case UNSPEC_TLS_ARG:
-	case UNSPEC_TLS_CALL:
-	  return -1;
-	default:
-	  break;
-	}
-    }
-
-  return 0;
-}
-
-
 /* Return TRUE if X contains any TLS symbol references.  */
 
 bool
@@ -2022,7 +1995,29 @@  xtensa_tls_referenced_p (rtx x)
   if (! TARGET_HAVE_TLS)
     return false;
 
-  return for_each_rtx (&x, xtensa_tls_referenced_p_1, NULL);
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, x, ALL)
+    {
+      const_rtx x = *iter;
+      if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (x) != 0)
+	return true;
+
+      /* Ignore TLS references that have already been legitimized.  */
+      if (GET_CODE (x) == UNSPEC)
+	switch (XINT (x, 1))
+	  {
+	  case UNSPEC_TPOFF:
+	  case UNSPEC_DTPOFF:
+	  case UNSPEC_TLS_FUNC:
+	  case UNSPEC_TLS_ARG:
+	  case UNSPEC_TLS_CALL:
+	    iter.skip_subrtxes ();
+	    break;
+	  default:
+	    break;
+	  }
+    }
+  return false;
 }