diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2014-10-26 10:40:15 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2014-10-26 10:40:15 +0000 |
commit | 5dabe5a94ef83a96f437f9f3425caf0f5280f08d (patch) | |
tree | 6ba9d4ba81a5e022c7bec20213ef7e639b35421d | |
parent | a57841528cd3cb916985b4b650759f30eb37eaaa (diff) | |
download | gcc-5dabe5a94ef83a96f437f9f3425caf0f5280f08d.zip gcc-5dabe5a94ef83a96f437f9f3425caf0f5280f08d.tar.gz gcc-5dabe5a94ef83a96f437f9f3425caf0f5280f08d.tar.bz2 |
sh-protos.h (shmedia_cleanup_truncate): Take an rtx as argument and return the number of changes.
gcc/
* 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.
From-SVN: r216701
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/config/sh/sh-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/sh/sh.c | 36 | ||||
-rw-r--r-- | gcc/config/sh/sh.md | 5 |
4 files changed, 32 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cf177bd..c33e0e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index 77c9ae4..a170c11 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -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); diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 3daa375..2d1a927 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -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, diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index b48be10..e0c0940 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -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; }) |