gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 26 Oct 2014 10:40:15 +0000 (10:40 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 26 Oct 2014 10:40:15 +0000 (10:40 +0000)
* config/sh/sh-protos.h (shmedia_cleanup_truncate): Take an
rtx as argument and return the number of changes.
* config/sh/sh.c: Include rtl-iter.h.
(shmedia_cleanup_truncate): Take an rtx as argument and iterate
over all subrtxes.  Return the number of changes made.
* config/sh/sh.md: Update caller accordingly.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216701 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/sh/sh-protos.h
gcc/config/sh/sh.c
gcc/config/sh/sh.md

index cf177bd..c33e0e5 100644 (file)
@@ -1,5 +1,14 @@
 2014-10-26  Richard Sandiford  <richard.sandiford@arm.com>
 
+       * config/sh/sh-protos.h (shmedia_cleanup_truncate): Take an
+       rtx as argument and return the number of changes.
+       * config/sh/sh.c: Include rtl-iter.h.
+       (shmedia_cleanup_truncate): Take an rtx as argument and iterate
+       over all subrtxes.  Return the number of changes made.
+       * config/sh/sh.md: Update caller accordingly.
+
+2014-10-26  Richard Sandiford  <richard.sandiford@arm.com>
+
        * config/m68k/m68k.c (m68k_tls_reference_p_1): Delete.
        (m68k_tls_reference_p): Use FOR_EACH_SUBRTX_VAR.
 
index 77c9ae4..a170c11 100644 (file)
@@ -215,7 +215,7 @@ extern void sh_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree,
 extern rtx sh_dwarf_register_span (rtx);
 
 extern rtx replace_n_hard_rtx (rtx, rtx *, int , int);
-extern int shmedia_cleanup_truncate (rtx *, void *);
+extern int shmedia_cleanup_truncate (rtx);
 
 extern bool sh_contains_memref_p (rtx);
 extern bool sh_loads_bankedreg_p (rtx);
index 3daa375..2d1a927 100644 (file)
@@ -78,6 +78,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "pass_manager.h"
 #include "context.h"
 #include "builtins.h"
+#include "rtl-iter.h"
 
 int code_for_indirect_jump_scratch = CODE_FOR_indirect_jump_scratch;
 
@@ -12940,25 +12941,30 @@ sh_gen_truncate (enum machine_mode mode, rtx x, int need_sign_ext)
   return gen_rtx_fmt_e (code, mode, x);
 }
 
-/* Called via for_each_rtx after reload, to clean up truncates of
-   registers that span multiple actual hard registers.  */
+/* Look through X cleaning up truncates of registers that span multiple
+   actual hard registers.  Return the number of changes made.  */
 int
-shmedia_cleanup_truncate (rtx *p, void *n_changes)
+shmedia_cleanup_truncate (rtx x)
 {
-  rtx x = *p, reg;
-
-  if (GET_CODE (x) != TRUNCATE)
-    return 0;
-  reg = XEXP (x, 0);
-  if (GET_MODE_SIZE (GET_MODE (reg)) > 8 && REG_P (reg))
+  int n_changes = 0;
+  subrtx_var_iterator::array_type array;
+  FOR_EACH_SUBRTX_VAR (iter, array, x, NONCONST)
     {
-      enum machine_mode reg_mode = GET_MODE (reg);
-      XEXP (x, 0) = simplify_subreg (DImode, reg, reg_mode,
-                                    subreg_lowpart_offset (DImode, reg_mode));
-      *(int*) n_changes += 1;
-      return -1;
+      rtx x = *iter;
+      if (GET_CODE (x) == TRUNCATE)
+       {
+         rtx reg = XEXP (x, 0);
+         enum machine_mode reg_mode = GET_MODE (reg);
+         if (REG_P (reg) && GET_MODE_SIZE (reg_mode) > 8)
+           {
+             int offset = subreg_lowpart_offset (DImode, reg_mode);
+             XEXP (x, 0) = simplify_subreg (DImode, reg, reg_mode, offset);
+             n_changes += 1;
+             iter.skip_subrtxes ();
+           }
+       }
     }
-  return 0;
+  return n_changes;
 }
 
 /* Load and store depend on the highpart of the address.  However,
index b48be10..e0c0940 100644 (file)
@@ -15803,10 +15803,7 @@ label:
   "TARGET_SHMEDIA && reload_completed"
   [(set (match_dup 0) (match_dup 1))]
 {
-  int n_changes = 0;
-
-  for_each_rtx (&operands[1], shmedia_cleanup_truncate, &n_changes);
-  if (!n_changes)
+  if (!shmedia_cleanup_truncate (operands[1]))
     FAIL;
 })