Commit f87a37c6 by Nick Clifton Committed by Nick Clifton

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
parent 12efb1d7
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> 2015-07-28 Tom de Vries <tom@codesourcery.com>
* tree-parloops.c (reduc_stmt_res): New function. * tree-parloops.c (reduc_stmt_res): New function.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
along with GCC; see the file COPYING3. If not see along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
const char * rl78_addsi3_internal (rtx *, unsigned int);
void rl78_emit_eh_epilogue (rtx); void rl78_emit_eh_epilogue (rtx);
void rl78_expand_compare (rtx *); void rl78_expand_compare (rtx *);
void rl78_expand_movsi (rtx *); void rl78_expand_movsi (rtx *);
......
...@@ -357,6 +357,9 @@ rl78_option_override (void) ...@@ -357,6 +357,9 @@ rl78_option_override (void)
if (TARGET_ES0 if (TARGET_ES0
&& strcmp (lang_hooks.name, "GNU C") && 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... */ /* Compiling with -flto results in a language of GNU GIMPLE being used... */
&& strcmp (lang_hooks.name, "GNU GIMPLE")) && strcmp (lang_hooks.name, "GNU GIMPLE"))
/* Address spaces are currently only supported by C. */ /* Address spaces are currently only supported by C. */
...@@ -4638,6 +4641,33 @@ rl78_flags_already_set (rtx op, rtx operand) ...@@ -4638,6 +4641,33 @@ rl78_flags_already_set (rtx op, rtx operand)
return res; 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 #undef TARGET_PREFERRED_RELOAD_CLASS
#define TARGET_PREFERRED_RELOAD_CLASS rl78_preferred_reload_class #define TARGET_PREFERRED_RELOAD_CLASS rl78_preferred_reload_class
......
...@@ -243,10 +243,7 @@ ...@@ -243,10 +243,7 @@
(clobber (reg:HI BC_REG)) (clobber (reg:HI BC_REG))
] ]
"rl78_real_insns_ok ()" "rl78_real_insns_ok ()"
"@ { return rl78_addsi3_internal (operands, which_alternative); }
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"
[(set_attr "valloc" "macax")] [(set_attr "valloc" "macax")]
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment