Commit 7b3d4613 by Kazu Hirata Committed by Jeff Law

h8300.c (dosize): Rearrange code for conciseness.

        * h8300.c (dosize): Rearrange code for conciseness.
        (split_adds_subs): Likewise.

From-SVN: r35527
parent e6fcb60d
2000-08-06 Kazu Hirata <kazu@hxi.com> 2000-08-06 Kazu Hirata <kazu@hxi.com>
* h8300.c (dosize): Rearrange code for conciseness.
(split_adds_subs): Likewise.
* loop.c: Fix formatting. * loop.c: Fix formatting.
* dwarf2out.c: Fix formatting. * dwarf2out.c: Fix formatting.
......
...@@ -148,63 +148,35 @@ dosize (file, op, size) ...@@ -148,63 +148,35 @@ dosize (file, op, size)
const char *op; const char *op;
unsigned int size; unsigned int size;
{ {
/* On the h8300h and h8300s, for sizes <= 8 bytes it is as good or /* On the H8/300H and H8/S, for sizes <= 8 bytes, it is as good or
better to use adds/subs insns rather than add.l/sub.l better to use adds/subs insns rather than add.l/sub.l with an
with an immediate value. */ immediate value.
if (size > 4 && size <= 8 && (TARGET_H8300H || TARGET_H8300S))
Also, on the H8/300, if we don't have a temporary to hold the
size of the frame in the prologue, we simply emit a sequence of
subs since this shouldn't happen often. */
if ((TARGET_H8300 && size <= 4)
|| ((TARGET_H8300H || TARGET_H8300S) && size <= 8)
|| (TARGET_H8300 && current_function_needs_context
&& strcmp (op, "sub")))
{ {
/* Crank the size down to <= 4. */ HOST_WIDE_INT amount;
fprintf (file, "\t%ss\t#%d,sp\n", op, 4);
size -= 4;
}
switch (size) /* Try different amounts in descending order. */
{ for (amount = (TARGET_H8300H || TARGET_H8300S) ? 4 : 2;
case 4: amount > 0;
if (TARGET_H8300H || TARGET_H8300S) amount /= 2)
{
fprintf (file, "\t%ss\t#%d,sp\n", op, 4);
size = 0;
break;
}
case 3:
fprintf (file, "\t%ss\t#%d,sp\n", op, 2);
size -= 2;
/* Fall through... */
case 2:
case 1:
fprintf (file, "\t%ss\t#%d,sp\n", op, size);
size = 0;
break;
case 0:
break;
default:
if (TARGET_H8300)
{
if (current_function_needs_context
&& strcmp (op, "sub") == 0)
{
/* Egad. We don't have a temporary to hold the
size of the frame in the prologue! Just inline
the bastard since this shouldn't happen often. */
while (size >= 2)
{ {
fprintf (file, "\tsubs\t#2,sp\n"); for(; size >= amount; size -= amount)
size -= 2; fprintf (file, "\t%ss\t#%d,sp\n", op, amount);
} }
if (size)
fprintf (file, "\tsubs\t#1,sp\n");
size = 0;
} }
else else
{
if (TARGET_H8300)
fprintf (file, "\tmov.w\t#%d,r3\n\t%s.w\tr3,sp\n", size, op); fprintf (file, "\tmov.w\t#%d,r3\n\t%s.w\tr3,sp\n", size, op);
}
else else
fprintf (file, "\t%s\t#%d,sp\n", op, size); fprintf (file, "\t%s.l\t#%d,sp\n", op, size);
size = 0;
break;
} }
} }
...@@ -640,11 +612,10 @@ split_adds_subs (mode, operands) ...@@ -640,11 +612,10 @@ split_adds_subs (mode, operands)
amount > 0; amount > 0;
amount /= 2) amount /= 2)
{ {
while (val >= amount) for(; val >= amount; val -= amount)
{ {
rtx tmp = gen_rtx_PLUS (mode, reg, GEN_INT (sign * amount)); rtx tmp = gen_rtx_PLUS (mode, reg, GEN_INT (sign * amount));
emit_insn (gen_rtx_SET (VOIDmode, reg, tmp)); emit_insn (gen_rtx_SET (VOIDmode, reg, tmp));
val -= amount;
} }
} }
......
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