(output_return_instruction): Do not writeback the stack pointer when it is being...
authorNick Clifton <nickc@redhat.com>
Tue, 17 Sep 2002 19:29:12 +0000 (19:29 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Tue, 17 Sep 2002 19:29:12 +0000 (19:29 +0000)
(output_return_instruction): Do not writeback the stack pointer when it is
being loaded.  (arm_output_epilogue): Likewise.

From-SVN: r57256

gcc/ChangeLog
gcc/config/arm/arm.c

index 34852fe2cc39707ce6028387ad89b08278b63b69..78348154a2dfd5c56c224616df9c22cd8c918b72 100644 (file)
@@ -1,3 +1,9 @@
+2002-09-17  Nick Clifton  <nickc@redhat.com>
+
+       * config/arm/arm.c (output_return_instruction): Do not
+       writeback the stack pointer when it is being loaded.
+       (arm_output_epilogue): Likewise.
+
 2002-09-17  Kazu Hirata  <kazu@cs.umass.edu>
 
        * optabs.c (prepare_cmp_insn): Let emit_library_call_value
index acdce8ebaf54375a40a90f357d1d24f2dc45ec8f..41eb93a9c47f8b9b872fc5852abdc7cf0ff3643b 100644 (file)
@@ -7325,6 +7325,8 @@ output_return_instruction (operand, really_return, reverse)
          /* Generate the load multiple instruction to restore the registers.  */
          if (frame_pointer_needed)
            sprintf (instr, "ldm%sea\t%%|fp, {", conditional);
+         else if (live_regs_mask & (1 << SP_REGNUM))
+           sprintf (instr, "ldm%sfd\t%%|sp, {", conditional);
          else
            sprintf (instr, "ldm%sfd\t%%|sp!, {", conditional);
 
@@ -7736,7 +7738,16 @@ arm_output_epilogue (really_return)
            asm_fprintf (f, "\tldr\t%r, [%r], #4\n", LR_REGNUM, SP_REGNUM);
        }
       else if (saved_regs_mask)
-       print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
+       {
+         if (saved_regs_mask & (1 << SP_REGNUM))
+           /* Note - write back to the stack register is not enabled
+              (ie "ldmfd sp!...").  We know that the stack pointer is
+              in the list of registers and if we add writeback the
+              instruction becomes UNPREDICTABLE.  */
+           print_multi_reg (f, "ldmfd\t%r", SP_REGNUM, saved_regs_mask);
+         else
+           print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
+       }
 
       if (current_function_pretend_args_size)
        {