diff options
author | Jim Wilson <wilson@gcc.gnu.org> | 1997-04-09 15:44:46 -0700 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 1997-04-09 15:44:46 -0700 |
commit | f3cd53755be56e7d6a05687789916f072ba8e9ab (patch) | |
tree | 7bf85020896380ca67e9bc4f4bb99350727a926a | |
parent | 20ec31d3056be8424863e84d4261d5d5d7945cc7 (diff) | |
download | gcc-f3cd53755be56e7d6a05687789916f072ba8e9ab.zip gcc-f3cd53755be56e7d6a05687789916f072ba8e9ab.tar.gz gcc-f3cd53755be56e7d6a05687789916f072ba8e9ab.tar.bz2 |
(output_stack_adjust): Reorganize code for readability.
If size is negative, negate and subtract it instead of adding it.
From-SVN: r13847
-rw-r--r-- | gcc/config/sh/sh.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 12a49ca..dd540b7 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -2485,38 +2485,42 @@ output_stack_adjust (size, reg, temp) { if (size) { - rtx val = GEN_INT (size); - rtx insn; - - if (! CONST_OK_FOR_I (size)) + if (CONST_OK_FOR_I (size)) + emit_insn (gen_addsi3 (reg, reg, GEN_INT (size))); + /* Try to do it with two partial adjustments; however, we must make + sure that the stack is properly aligned at all times, in case + an interrupt occurs between the two partial adjustments. */ + else if (CONST_OK_FOR_I (size / 2 & -4) + && CONST_OK_FOR_I (size - (size / 2 & -4))) + { + emit_insn (gen_addsi3 (reg, reg, GEN_INT (size / 2 & -4))); + emit_insn (gen_addsi3 (reg, reg, GEN_INT (size - (size / 2 & -4)))); + } + else { - /* Try to do it with two partial adjustments; however, must make - sure that the stack is properly aligned at all times, in case - an interrupt occurs between the two partial adjustments. */ - if (CONST_OK_FOR_I (size / 2 & -4) - && CONST_OK_FOR_I (size - (size / 2 & -4))) + rtx const_reg; + + /* If TEMP is invalid, we could temporarily save a general + register to MACL. However, there is currently no need + to handle this case, so just abort when we see it. */ + if (temp < 0) + abort (); + const_reg = gen_rtx (REG, SImode, temp); + + /* If SIZE is negative, subtract the positive value. + This sometimes allows a constant pool entry to be shared + between prologue and epilogue code. */ + if (size < 0) { - val = GEN_INT (size / 2 & -4); - emit_insn (gen_addsi3 (reg, reg, val)); - val = GEN_INT (size - (size / 2 & -4)); + emit_insn (gen_movsi (const_reg, GEN_INT (-size))); + emit_insn (gen_subsi3 (reg, reg, const_reg)); } else { - rtx reg; - - /* If TEMP is invalid, we could temporarily save a general - register to MACL. However, there is currently no need - to handle this case, so just abort when we see it. */ - if (temp < 0) - abort (); - reg = gen_rtx (REG, SImode, temp); - emit_insn (gen_movsi (reg, val)); - val = reg; + emit_insn (gen_movsi (const_reg, GEN_INT (size))); + emit_insn (gen_addsi3 (reg, reg, const_reg)); } } - - insn = gen_addsi3 (reg, reg, val); - emit_insn (insn); } } |