[SH] RFA: Use new rtl iterators in sh_contains_memref_p
diff mbox

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

Commit Message

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

Thanks,
Richard


gcc/
	* config/sh/sh.c (sh_contains_memref_p_1): Delete.
	(sh_contains_memref_p): Use FOR_EACH_SUBRTX.

Comments

Oleg Endo Oct. 25, 2014, 5:56 p.m. UTC | #1
On Oct 25, 2014, at 12:03 PM, 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 sh-elf.  OK to install?

OK with me.

Cheers,
Oleg



> gcc/
>    * config/sh/sh.c (sh_contains_memref_p_1): Delete.
>    (sh_contains_memref_p): Use FOR_EACH_SUBRTX.
> 
> Index: gcc/config/sh/sh.c
> ===================================================================
> --- gcc/config/sh/sh.c    2014-10-25 09:51:27.049897841 +0100
> +++ gcc/config/sh/sh.c    2014-10-25 09:51:27.492901789 +0100
> @@ -12972,18 +12972,15 @@ shmedia_cleanup_truncate (rtx x)
>    so we must look at the rtl ourselves to see if any of the feeding
>    registers is used in a memref.
> 
> -   Called by sh_contains_memref_p via for_each_rtx.  */
> -static int
> -sh_contains_memref_p_1 (rtx *loc, void *data ATTRIBUTE_UNUSED)
> -{
> -  return (MEM_P (*loc));
> -}
> -
> -/* Return true iff INSN contains a MEM.  */
> +   Return true iff INSN contains a MEM.  */
> bool
> sh_contains_memref_p (rtx insn)
> {
> -  return for_each_rtx (&PATTERN (insn), &sh_contains_memref_p_1, NULL);
> +  subrtx_iterator::array_type array;
> +  FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST)
> +    if (MEM_P (*iter))
> +      return true;
> +  return false;
> }
> 
> /* Return true iff INSN loads a banked register.  */

Patch
diff mbox

Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	2014-10-25 09:51:27.049897841 +0100
+++ gcc/config/sh/sh.c	2014-10-25 09:51:27.492901789 +0100
@@ -12972,18 +12972,15 @@  shmedia_cleanup_truncate (rtx x)
    so we must look at the rtl ourselves to see if any of the feeding
    registers is used in a memref.
 
-   Called by sh_contains_memref_p via for_each_rtx.  */
-static int
-sh_contains_memref_p_1 (rtx *loc, void *data ATTRIBUTE_UNUSED)
-{
-  return (MEM_P (*loc));
-}
-
-/* Return true iff INSN contains a MEM.  */
+   Return true iff INSN contains a MEM.  */
 bool
 sh_contains_memref_p (rtx insn)
 {
-  return for_each_rtx (&PATTERN (insn), &sh_contains_memref_p_1, NULL);
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST)
+    if (MEM_P (*iter))
+      return true;
+  return false;
 }
 
 /* Return true iff INSN loads a banked register.  */