Commit cda4bd43 by Kazu Hirata Committed by Jeff Law

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

        * h8300.c (function_prologue): Rearrange code for conciseness.
        (function_epilogue): Likewise.
        * hh8300.h (OK_FOR_U): Fix formatting.

From-SVN: r35474
parent 024a650b
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
2000-08-04 Kazu Hirata <kazu@hxi.com> 2000-08-04 Kazu Hirata <kazu@hxi.com>
* h8300.c (function_prologue): Rearrange code for conciseness.
(function_epilogue): Likewise.
* h8300.h (OK_FOR_U): Fix formatting.
* cse.c: Fix a comment typo. Fix formatting. * cse.c: Fix a comment typo. Fix formatting.
2000-08-03 Richard Henderson <rth@cygnus.com> 2000-08-03 Richard Henderson <rth@cygnus.com>
......
...@@ -239,6 +239,8 @@ function_prologue (file, size) ...@@ -239,6 +239,8 @@ function_prologue (file, size)
{ {
int fsize = (size + STACK_BOUNDARY / 8 - 1) & -STACK_BOUNDARY / 8; int fsize = (size + STACK_BOUNDARY / 8 - 1) & -STACK_BOUNDARY / 8;
int idx; int idx;
int push_regs[FIRST_PSEUDO_REGISTER];
int n_regs;
/* Note a function with the interrupt attribute and set interrupt_handler /* Note a function with the interrupt attribute and set interrupt_handler
accordingly. */ accordingly. */
...@@ -292,7 +294,7 @@ function_prologue (file, size) ...@@ -292,7 +294,7 @@ function_prologue (file, size)
/* Leave room for locals. */ /* Leave room for locals. */
dosize (file, "sub", fsize); dosize (file, "sub", fsize);
/* Push the rest of the registers. */ /* Compute which registers to push. */
for (idx = 0; idx < FIRST_PSEUDO_REGISTER; idx++) for (idx = 0; idx < FIRST_PSEUDO_REGISTER; idx++)
{ {
int regno = push_order[idx]; int regno = push_order[idx];
...@@ -300,75 +302,44 @@ function_prologue (file, size) ...@@ -300,75 +302,44 @@ function_prologue (file, size)
if (regno >= 0 if (regno >= 0
&& WORD_REG_USED (regno) && WORD_REG_USED (regno)
&& (!frame_pointer_needed || regno != FRAME_POINTER_REGNUM)) && (!frame_pointer_needed || regno != FRAME_POINTER_REGNUM))
push_regs[idx] = regno;
else
push_regs[idx] = -1;
}
/* Push the rest of the registers. */
for (idx = 0; idx < FIRST_PSEUDO_REGISTER; idx += n_regs)
{
int regno = push_regs[idx];
n_regs = 1;
if (regno >= 0)
{ {
if (TARGET_H8300S) if (TARGET_H8300S)
{ {
/* Try to push multiple registers. */ /* See how many registers we can push at the same time. */
if (regno == 0 || regno == 4) if ((regno == 0 || regno == 4)
{ && push_regs[idx + 1] >= 0
int second_regno = push_order[idx + 1]; && push_regs[idx + 2] >= 0
int third_regno = push_order[idx + 2]; && push_regs[idx + 3] >= 0)
int fourth_regno = push_order[idx + 3]; n_regs = 4;
if (fourth_regno >= 0 else if ((regno == 0 || regno == 4)
&& WORD_REG_USED (fourth_regno) && push_regs[idx + 1] >= 0
&& (!frame_pointer_needed && push_regs[idx + 2] >= 0)
|| fourth_regno != FRAME_POINTER_REGNUM) n_regs = 3;
&& third_regno >= 0
&& WORD_REG_USED (third_regno) else if ((regno == 0 || regno == 2 || regno == 4 || regno == 6)
&& (!frame_pointer_needed && push_regs[idx + 1] >= 0)
|| third_regno != FRAME_POINTER_REGNUM) n_regs = 2;
&& second_regno >= 0
&& WORD_REG_USED (second_regno)
&& (!frame_pointer_needed
|| second_regno != FRAME_POINTER_REGNUM))
{
fprintf (file, "\tstm.l %s-%s,@-sp\n",
h8_reg_names[regno],
h8_reg_names[fourth_regno]);
idx += 3;
continue;
}
}
if (regno == 0 || regno == 4)
{
int second_regno = push_order[idx + 1];
int third_regno = push_order[idx + 2];
if (third_regno >= 0
&& WORD_REG_USED (third_regno)
&& (!frame_pointer_needed
|| third_regno != FRAME_POINTER_REGNUM)
&& second_regno >= 0
&& WORD_REG_USED (second_regno)
&& (!frame_pointer_needed
|| second_regno != FRAME_POINTER_REGNUM))
{
fprintf (file, "\tstm.l %s-%s,@-sp\n",
h8_reg_names[regno],
h8_reg_names[third_regno]);
idx += 2;
continue;
}
}
if (regno == 0 || regno == 2 || regno == 4 || regno == 6)
{
int second_regno = push_order[idx + 1];
if (second_regno >= 0
&& WORD_REG_USED (second_regno)
&& (!frame_pointer_needed
|| second_regno != FRAME_POINTER_REGNUM))
{
fprintf (file, "\tstm.l %s-%s,@-sp\n",
h8_reg_names[regno],
h8_reg_names[second_regno]);
idx += 1;
continue;
}
}
} }
fprintf (file, "\t%s\t%s\n", h8_push_op, h8_reg_names[regno]);
if (n_regs == 1)
fprintf (file, "\t%s\t%s\n", h8_push_op, h8_reg_names[regno]);
else
fprintf (file, "\tstm.l\t%s-%s,@-sp\n",
h8_reg_names[regno],
h8_reg_names[regno + (n_regs - 1)]);
} }
} }
} }
...@@ -383,6 +354,8 @@ function_epilogue (file, size) ...@@ -383,6 +354,8 @@ function_epilogue (file, size)
int fsize = (size + STACK_BOUNDARY / 8 - 1) & -STACK_BOUNDARY / 8; int fsize = (size + STACK_BOUNDARY / 8 - 1) & -STACK_BOUNDARY / 8;
int idx; int idx;
rtx insn = get_last_insn (); rtx insn = get_last_insn ();
int pop_regs[FIRST_PSEUDO_REGISTER];
int n_regs;
if (os_task) if (os_task)
{ {
...@@ -404,7 +377,7 @@ function_epilogue (file, size) ...@@ -404,7 +377,7 @@ function_epilogue (file, size)
if (insn && GET_CODE (insn) == BARRIER) if (insn && GET_CODE (insn) == BARRIER)
goto out; goto out;
/* Pop the saved registers. */ /* Compute which registers to pop. */
for (idx = 0; idx < FIRST_PSEUDO_REGISTER; idx++) for (idx = 0; idx < FIRST_PSEUDO_REGISTER; idx++)
{ {
int regno = pop_order[idx]; int regno = pop_order[idx];
...@@ -412,75 +385,44 @@ function_epilogue (file, size) ...@@ -412,75 +385,44 @@ function_epilogue (file, size)
if (regno >= 0 if (regno >= 0
&& WORD_REG_USED (regno) && WORD_REG_USED (regno)
&& (!frame_pointer_needed || regno != FRAME_POINTER_REGNUM)) && (!frame_pointer_needed || regno != FRAME_POINTER_REGNUM))
pop_regs[idx] = regno;
else
pop_regs[idx] = -1;
}
/* Pop the saved registers. */
for (idx = 0; idx < FIRST_PSEUDO_REGISTER; idx += n_regs)
{
int regno = pop_regs[idx];
n_regs = 1;
if (regno >= 0)
{ {
if (TARGET_H8300S) if (TARGET_H8300S)
{ {
/* Try to pop multiple registers. */ /* See how many registers we can pop at the same time. */
if (regno == 7 || regno == 3) if ((regno == 7 || regno == 3)
{ && pop_regs[idx + 1] >= 0
int second_regno = pop_order[idx + 1]; && pop_regs[idx + 2] >= 0
int third_regno = pop_order[idx + 2]; && pop_regs[idx + 3] >= 0)
int fourth_regno = pop_order[idx + 3]; n_regs = 4;
if (fourth_regno >= 0 else if ((regno == 6 || regno == 2)
&& WORD_REG_USED (fourth_regno) && pop_regs[idx + 1] >= 0
&& (!frame_pointer_needed && pop_regs[idx + 2] >= 0)
|| fourth_regno != FRAME_POINTER_REGNUM) n_regs = 3;
&& third_regno >= 0
&& WORD_REG_USED (third_regno) else if ((regno == 7 || regno == 5 || regno == 3 || regno == 1)
&& (!frame_pointer_needed && pop_regs[idx + 1] >= 0)
|| third_regno != FRAME_POINTER_REGNUM) n_regs = 2;
&& second_regno >= 0
&& WORD_REG_USED (second_regno)
&& (!frame_pointer_needed
|| second_regno != FRAME_POINTER_REGNUM))
{
fprintf (file, "\tldm.l @sp+,%s-%s\n",
h8_reg_names[fourth_regno],
h8_reg_names[regno]);
idx += 3;
continue;
}
}
if (regno == 6 || regno == 2)
{
int second_regno = pop_order[idx + 1];
int third_regno = pop_order[idx + 2];
if (third_regno >= 0
&& WORD_REG_USED (third_regno)
&& (!frame_pointer_needed
|| third_regno != FRAME_POINTER_REGNUM)
&& second_regno >= 0
&& WORD_REG_USED (second_regno)
&& (!frame_pointer_needed
|| second_regno != FRAME_POINTER_REGNUM))
{
fprintf (file, "\tldm.l @sp+,%s-%s\n",
h8_reg_names[third_regno],
h8_reg_names[regno]);
idx += 2;
continue;
}
}
if (regno == 7 || regno == 5 || regno == 3 || regno == 1)
{
int second_regno = pop_order[idx + 1];
if (second_regno >= 0
&& WORD_REG_USED (second_regno)
&& (!frame_pointer_needed
|| second_regno != FRAME_POINTER_REGNUM))
{
fprintf (file, "\tldm.l @sp+,%s-%s\n",
h8_reg_names[second_regno],
h8_reg_names[regno]);
idx += 1;
continue;
}
}
} }
fprintf (file, "\t%s\t%s\n", h8_pop_op, h8_reg_names[regno]);
if (n_regs == 1)
fprintf (file, "\t%s\t%s\n", h8_pop_op, h8_reg_names[regno]);
else
fprintf (file, "\tldm.l\t@sp+,%s-%s\n",
h8_reg_names[regno - (n_regs - 1)],
h8_reg_names[regno]);
} }
} }
......
...@@ -854,20 +854,20 @@ struct cum_arg ...@@ -854,20 +854,20 @@ struct cum_arg
(a SYMBOL_REF with an SYMBOL_REF_FLAG set). (a SYMBOL_REF with an SYMBOL_REF_FLAG set).
On the H8/S 'U' can also be a 16bit or 32bit absolute. */ On the H8/S 'U' can also be a 16bit or 32bit absolute. */
#define OK_FOR_U(OP) \ #define OK_FOR_U(OP) \
((GET_CODE (OP) == REG && REG_OK_FOR_BASE_P (OP)) \ ((GET_CODE (OP) == REG && REG_OK_FOR_BASE_P (OP)) \
|| (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \ || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG \
&& REG_OK_FOR_BASE_P (XEXP (OP, 0))) \ && REG_OK_FOR_BASE_P (XEXP (OP, 0))) \
|| (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF \ || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF \
&& (TARGET_H8300S || SYMBOL_REF_FLAG (XEXP (OP, 0)))) \ && (TARGET_H8300S || SYMBOL_REF_FLAG (XEXP (OP, 0)))) \
|| ((GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == CONST \ || ((GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == CONST \
&& GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS \ && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS \
&& GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == SYMBOL_REF \ && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == SYMBOL_REF \
&& GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT) \ && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT) \
&& (TARGET_H8300S || SYMBOL_REF_FLAG (XEXP (XEXP (OP, 0), 0)))) \ && (TARGET_H8300S || SYMBOL_REF_FLAG (XEXP (XEXP (OP, 0), 0)))) \
|| (GET_CODE (OP) == MEM \ || (GET_CODE (OP) == MEM \
&& EIGHTBIT_CONSTANT_ADDRESS_P (XEXP (OP, 0))) \ && EIGHTBIT_CONSTANT_ADDRESS_P (XEXP (OP, 0))) \
|| (GET_CODE (OP) == MEM && TARGET_H8300S \ || (GET_CODE (OP) == MEM && TARGET_H8300S \
&& GET_CODE (XEXP (OP, 0)) == CONST_INT)) && GET_CODE (XEXP (OP, 0)) == CONST_INT))
#define EXTRA_CONSTRAINT(OP, C) \ #define EXTRA_CONSTRAINT(OP, C) \
......
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