diff options
| -rw-r--r-- | gcc/ChangeLog | 8 | ||||
| -rw-r--r-- | gcc/config/rl78/rl78-protos.h | 1 | ||||
| -rw-r--r-- | gcc/config/rl78/rl78.c | 30 | ||||
| -rw-r--r-- | gcc/config/rl78/rl78.md | 5 |
4 files changed, 40 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3457af8..bbee98a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-07-28 Nick Clifton <nickc@redhat.com> + + * config/rl78/rl78.c (rl78_addsi3_internal): New function. + Optimizes the case where -mes0 is active and a constant symbolic + address is used. + * config/rl78/rl78-protos.h: Prototype the new function. + * config/rl78/rl78.md (addsi3_internal_real): Call new function. + 2015-07-28 Tom de Vries <tom@codesourcery.com> * tree-parloops.c (reduc_stmt_res): New function. diff --git a/gcc/config/rl78/rl78-protos.h b/gcc/config/rl78/rl78-protos.h index 0e77b8d..614bf63 100644 --- a/gcc/config/rl78/rl78-protos.h +++ b/gcc/config/rl78/rl78-protos.h @@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ +const char * rl78_addsi3_internal (rtx *, unsigned int); void rl78_emit_eh_epilogue (rtx); void rl78_expand_compare (rtx *); void rl78_expand_movsi (rtx *); diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c index 2bbfb2e..7069530 100644 --- a/gcc/config/rl78/rl78.c +++ b/gcc/config/rl78/rl78.c @@ -357,6 +357,9 @@ rl78_option_override (void) if (TARGET_ES0 && strcmp (lang_hooks.name, "GNU C") + && strcmp (lang_hooks.name, "GNU C11") + && strcmp (lang_hooks.name, "GNU C89") + && strcmp (lang_hooks.name, "GNU C99") /* Compiling with -flto results in a language of GNU GIMPLE being used... */ && strcmp (lang_hooks.name, "GNU GIMPLE")) /* Address spaces are currently only supported by C. */ @@ -4638,6 +4641,33 @@ rl78_flags_already_set (rtx op, rtx operand) return res; } + +const char * +rl78_addsi3_internal (rtx * operands, unsigned int alternative) +{ + /* If we are adding in a constant symbolic address when -mes0 + is active then we know that the address must be <64K and + that it is invalid to access anything above 64K relative to + this address. So we can skip adding in the high bytes. */ + if (TARGET_ES0 + && GET_CODE (operands[2]) == SYMBOL_REF + && TREE_CODE (SYMBOL_REF_DECL (operands[2])) == VAR_DECL + && TREE_READONLY (SYMBOL_REF_DECL (operands[2])) + && ! TREE_SIDE_EFFECTS (SYMBOL_REF_DECL (operands[2]))) + return "movw ax, %h1\n\taddw ax, %h2\n\tmovw %h0, ax"; + + switch (alternative) + { + case 0: + case 1: + return "movw ax, %h1\n\taddw ax, %h2\n\tmovw %h0, ax\n\tmovw ax, %H1\n\tsknc\n\tincw ax\n\taddw ax, %H2\n\tmovw %H0, ax"; + case 2: + return "movw ax, %h1\n\taddw ax,%h2\n\tmovw bc, ax\n\tmovw ax, %H1\n\tsknc\n\tincw ax\n\taddw ax, %H2\n\tmovw %H0, ax\n\tmovw ax, bc\n\tmovw %h0, ax"; + default: + gcc_unreachable (); + } +} + #undef TARGET_PREFERRED_RELOAD_CLASS #define TARGET_PREFERRED_RELOAD_CLASS rl78_preferred_reload_class diff --git a/gcc/config/rl78/rl78.md b/gcc/config/rl78/rl78.md index 2ea788e..735c19f 100644 --- a/gcc/config/rl78/rl78.md +++ b/gcc/config/rl78/rl78.md @@ -243,10 +243,7 @@ (clobber (reg:HI BC_REG)) ] "rl78_real_insns_ok ()" - "@ - movw ax,%h1 \;addw ax,%h2 \;movw %h0, ax \;movw ax,%H1 \;sknc \;incw ax \;addw ax,%H2 \;movw %H0,ax - movw ax,%h1 \;addw ax,%h2 \;movw %h0, ax \;movw ax,%H1 \;sknc \;incw ax \;addw ax,%H2 \;movw %H0,ax - movw ax,%h1 \;addw ax,%h2 \;movw bc, ax \;movw ax,%H1 \;sknc \;incw ax \;addw ax,%H2 \;movw %H0,ax \;movw ax,bc \;movw %h0, ax" + { return rl78_addsi3_internal (operands, which_alternative); } [(set_attr "valloc" "macax")] ) |
