diff mbox

[microblaze] RFA: Use new rtl iterators in microblaze_tls_referenced_p

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

Commit Message

Richard Sandiford Oct. 25, 2014, 10:05 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 microblaze-elf.  OK to install?

Thanks,
Richard


gcc/
	* config/microblaze/microblaze.c: Include rtl-iter.h.
	(microblaze_tls_referenced_p_1): Delete.
	(microblaze_tls_referenced_p): Use FOR_EACH_SUBRTX.

Comments

Michael Eager Oct. 26, 2014, 4:21 p.m. UTC | #1
On 10/25/14 03:05, Richard Sandiford 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 microblaze-elf.  OK to install?

Yes, this is OK.  Please check for trailing whitespace.

>
> Thanks,
> Richard
>
>
> gcc/
> 	* config/microblaze/microblaze.c: Include rtl-iter.h.
> 	(microblaze_tls_referenced_p_1): Delete.
> 	(microblaze_tls_referenced_p): Use FOR_EACH_SUBRTX.
>
> Index: gcc/config/microblaze/microblaze.c
> ===================================================================
> --- gcc/config/microblaze/microblaze.c	2014-10-25 09:40:37.967516501 +0100
> +++ gcc/config/microblaze/microblaze.c	2014-10-25 09:51:27.863905096 +0100
> @@ -56,6 +56,7 @@
>   #include "diagnostic-core.h"
>   #include "cgraph.h"
>   #include "builtins.h"
> +#include "rtl-iter.h"
>
>   #define MICROBLAZE_VERSION_COMPARE(VA,VB) strcasecmp (VA, VB)
>
> @@ -444,20 +445,6 @@ microblaze_tls_symbol_p (rtx x)
>     return SYMBOL_REF_TLS_MODEL (x) != 0;
>   }
>
> -static int
> -microblaze_tls_operand_p_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
> -{
> -  if (GET_CODE (*x) == SYMBOL_REF)
> -    return SYMBOL_REF_TLS_MODEL (*x) != 0;
> -
> -  /* Don't recurse into UNSPEC_TLS looking for TLS symbols; these are
> -     TLS offsets, not real symbol references.  */
> -  if (GET_CODE (*x) == UNSPEC && XINT (*x, 1) == UNSPEC_TLS)
> -    return -1;
> -
> -  return 0;
> -}
> -
>   /* Return TRUE if X contains any TLS symbol references.  */
>
>   bool
> @@ -465,8 +452,18 @@ microblaze_tls_referenced_p (rtx x)
>   {
>     if (!TARGET_HAVE_TLS)
>       return false;
> -
> -  return for_each_rtx (&x, microblaze_tls_operand_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;
> +      /* Don't recurse into UNSPEC_TLS looking for TLS symbols; these are
> +	 TLS offsets, not real symbol references.  */
> +      if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_TLS)
> +	iter.skip_subrtxes ();
> +    }
> +  return false;
>   }
>
>   bool
>
diff mbox

Patch

Index: gcc/config/microblaze/microblaze.c
===================================================================
--- gcc/config/microblaze/microblaze.c	2014-10-25 09:40:37.967516501 +0100
+++ gcc/config/microblaze/microblaze.c	2014-10-25 09:51:27.863905096 +0100
@@ -56,6 +56,7 @@ 
 #include "diagnostic-core.h"
 #include "cgraph.h"
 #include "builtins.h"
+#include "rtl-iter.h"
 
 #define MICROBLAZE_VERSION_COMPARE(VA,VB) strcasecmp (VA, VB)
 
@@ -444,20 +445,6 @@  microblaze_tls_symbol_p (rtx x)
   return SYMBOL_REF_TLS_MODEL (x) != 0;
 }
 
-static int
-microblaze_tls_operand_p_1 (rtx *x, void *data ATTRIBUTE_UNUSED)
-{
-  if (GET_CODE (*x) == SYMBOL_REF)
-    return SYMBOL_REF_TLS_MODEL (*x) != 0;
-
-  /* Don't recurse into UNSPEC_TLS looking for TLS symbols; these are
-     TLS offsets, not real symbol references.  */
-  if (GET_CODE (*x) == UNSPEC && XINT (*x, 1) == UNSPEC_TLS)
-    return -1;
-
-  return 0;
-}
-
 /* Return TRUE if X contains any TLS symbol references.  */
 
 bool
@@ -465,8 +452,18 @@  microblaze_tls_referenced_p (rtx x)
 {
   if (!TARGET_HAVE_TLS)
     return false;
-
-  return for_each_rtx (&x, microblaze_tls_operand_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;
+      /* Don't recurse into UNSPEC_TLS looking for TLS symbols; these are
+	 TLS offsets, not real symbol references.  */
+      if (GET_CODE (x) == UNSPEC && XINT (x, 1) == UNSPEC_TLS)
+	iter.skip_subrtxes ();
+    }
+  return false;
 }
 
 bool