From f9d7e5cd9ecc1a22a4765dee9dbdd695b42c9c3a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sat, 17 Apr 1999 12:03:04 -0700 Subject: [PATCH] alpha.c (alpha_expand_prologue): Use gen_adddi3 instead of emit_move_insn+plus_constant. * alpha.c (alpha_expand_prologue): Use gen_adddi3 instead of emit_move_insn+plus_constant. For NT, don't use the stack probe loop pointer to allocate stack space. * alpha.md (adddi3): Always use lda to set the stack pointer. From-SVN: r26524 --- gcc/ChangeLog | 7 ++++++ gcc/config/alpha/alpha.c | 52 +++++++++++++++++++++++++++------------ gcc/config/alpha/alpha.md | 33 +++++++++++++++++++++---- 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2499ba6572b..5d81e68b222 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +Mon Apr 19 08:12:30 1999 Richard Henderson + + * alpha.c (alpha_expand_prologue): Use gen_adddi3 instead of + emit_move_insn+plus_constant. For NT, don't use the stack probe + loop pointer to allocate stack space. + * alpha.md (adddi3): Always use lda to set the stack pointer. + 1999-04-17 20:11 -0400 Zack Weinberg * c-aux-info.c, emit-rtl.c, explow.c, expmed.c, gcse.c, diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index e2a4dffde7b..c910278a00c 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -3405,8 +3405,8 @@ alpha_expand_prologue () if (frame_size != 0) { - FRP (emit_move_insn (stack_pointer_rtx, - plus_constant (stack_pointer_rtx, -frame_size))); + FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx, + GEN_INT (-frame_size)))); } } else @@ -3423,7 +3423,7 @@ alpha_expand_prologue () rtx count = gen_rtx_REG (DImode, 23); emit_move_insn (count, GEN_INT (blocks)); - emit_move_insn (ptr, plus_constant (stack_pointer_rtx, 4096)); + emit_insn (gen_adddi3 (ptr, stack_pointer_rtx, GEN_INT (4096))); /* Because of the difficulty in emitting a new basic block this late in the compilation, generate the loop as a single insn. */ @@ -3436,18 +3436,38 @@ alpha_expand_prologue () emit_move_insn (last, const0_rtx); } - ptr = emit_move_insn (stack_pointer_rtx, plus_constant (ptr, -leftover)); - - /* This alternative is special, because the DWARF code cannot possibly - intuit through the loop above. So we invent this note it looks at - instead. */ - RTX_FRAME_RELATED_P (ptr) = 1; - REG_NOTES (ptr) - = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR, - gen_rtx_SET (VOIDmode, stack_pointer_rtx, - gen_rtx_PLUS (Pmode, stack_pointer_rtx, - GEN_INT (-frame_size))), - REG_NOTES (ptr)); + if (TARGET_WINDOWS_NT) + { + /* For NT stack unwind (done by 'reverse execution'), it's + not OK to take the result of a loop, even though the value + is already in ptr, so we reload it via a single operation + and add it to sp. */ + + HOST_WIDE_INT lo, hi; + lo = ((-frame_size & 0xffff) ^ 0x8000) - 0x8000; + hi = -frame_size - lo; + + FRP (emit_insn (gen_adddi3 (ptr, stack_pointer_rtx, GEN_INT (hi)))); + FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, ptr, GEN_INT (lo)))); + } + else + { + rtx seq; + + seq = emit_insn (gen_adddi3 (stack_pointer_rtx, ptr, + GEN_INT (-leftover))); + + /* This alternative is special, because the DWARF code cannot + possibly intuit through the loop above. So we invent this + note it looks at instead. */ + RTX_FRAME_RELATED_P (seq) = 1; + REG_NOTES (seq) + = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR, + gen_rtx_SET (VOIDmode, stack_pointer_rtx, + gen_rtx_PLUS (Pmode, stack_pointer_rtx, + GEN_INT (-frame_size))), + REG_NOTES (seq)); + } } /* Cope with very large offsets to the register save area. */ @@ -3463,7 +3483,7 @@ alpha_expand_prologue () bias = reg_offset, reg_offset = 0; sa_reg = gen_rtx_REG (DImode, 24); - FRP (emit_move_insn (sa_reg, plus_constant (stack_pointer_rtx, bias))); + FRP (emit_insn (gen_adddi3 (sa_reg, stack_pointer_rtx, GEN_INT (bias)))); } /* Save regs in stack order. Beginning with VMS PV. */ diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md index f4943a29635..ab569510ad5 100644 --- a/gcc/config/alpha/alpha.md +++ b/gcc/config/alpha/alpha.md @@ -534,11 +534,34 @@ (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ,rJ,rJ,rJ") (match_operand:DI 2 "add_operand" "rI,O,K,L")))] "" - "@ - addq %r1,%2,%0 - subq %r1,%n2,%0 - lda %0,%2(%r1) - ldah %0,%h2(%r1)") + "* +{ + const char * const pattern[4] = { + \"addq %r1,%2,%0\", + \"subq %r1,%n2,%0\", + \"lda %0,%2(%r1)\", + \"ldah %0,%h2(%r1)\" + }; + + /* The NT stack unwind code can't handle a subq to adjust the stack + (that's a bug, but not one we can do anything about). As of NT4.0 SP3, + the exception handling code will loop if a subq is used and an + exception occurs. + + The 19980616 change to emit prologues as RTL also confused some + versions of GDB, which also interprets prologues. This has been + fixed as of GDB 4.18, but it does not harm to unconditionally + use lda here. */ + + int which = which_alternative; + + if (operands[0] == stack_pointer_rtx + && GET_CODE (operands[2]) == CONST_INT + && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')) + which = 2; + + return pattern[which]; +}") ;; Don't do this if we are adjusting SP since we don't want to do ;; it in two steps. -- 2.30.2