From f87a37c6893dc51f4c3e6fbddfcf453bd83c9215 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 28 Jul 2015 08:09:09 +0000 Subject: [PATCH] rl78.c (rl78_addsi3_internal): New function. * 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. From-SVN: r226306 --- gcc/ChangeLog | 8 ++++++++ gcc/config/rl78/rl78-protos.h | 1 + gcc/config/rl78/rl78.c | 30 ++++++++++++++++++++++++++++++ gcc/config/rl78/rl78.md | 5 +---- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3457af82669..bbee98a0001 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-07-28 Nick Clifton + + * 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 * 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 0e77b8d51f1..614bf63b88d 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 . */ +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 2bbfb2ead38..70695302560 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 2ea788e5817..735c19f81ee 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")] ) -- 2.30.2