From 6bacc7b094be8ab0fff0a465298d14d298fc9d29 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@cambridge.redhat.com>
Date: Wed, 23 Jan 2002 11:04:56 +0000
Subject: [PATCH] Use an UNSPEC instead of a USE to prevent prologue/epilogue
 insns from being deleted.

From-SVN: r49130
---
 gcc/ChangeLog         | 11 +++++++++++
 gcc/config/arm/arm.c  | 10 +++++-----
 gcc/config/arm/arm.md | 14 ++++++++++++--
 3 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f12b7ab8ef93..5c5da99da5a8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2002-01-23  Nick Clifton  <nickc@cambridge.redhat.com>
+
+	* config/arm/arm.md (UNSPEC_PROLOGUE_USE): New unspec constant.
+	(prologue_use): New pattern.
+	* config/arm/arm.c (expand_prologue): Use gen_prologue_use in
+	preference to gen_rtx_USE.
+	(thumb_expand_prologue): Use gen_prologue_use in preference to
+	gen_rtx_USE.
+	(thumb_expand_epilogue): Use gen_prologue_use in preference to
+	gen_rtx_USE.
+
 2002-01-23  Hans-Peter Nilsson  <hp@bitrange.com>
 
 	* loop.c [!HAVE_prefetch] (CODE_FOR_prefetch): Define to 0.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 04f06ae997df..567daa373128 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -8331,7 +8331,7 @@ arm_expand_prologue ()
 
 	  emit_insn (gen_rtx_SET (SImode, ip_rtx, insn));
 	  /* Add a USE to stop propagate_one_insn() from barfing.  */
-	  emit_insn (gen_rtx_USE (VOIDmode, ip_rtx));
+	  emit_insn (gen_prologue_use (ip_rtx));
 	}
     }
 
@@ -8377,7 +8377,7 @@ arm_expand_prologue ()
      then make sure that it does not get reused by the ce2 pass.  */
   if ((live_regs_mask & (1 << LR_REGNUM)) == 0)
     {
-      emit_insn (gen_rtx_USE (VOIDmode, gen_rtx_REG (SImode, LR_REGNUM)));
+      emit_insn (gen_prologue_use (gen_rtx_REG (SImode, LR_REGNUM)));
       cfun->machine->lr_save_eliminated = 1;
     }
 }
@@ -10186,7 +10186,7 @@ thumb_expand_prologue ()
 	      /* Save it by copying it into a high, scratch register.  */
 	      emit_insn (gen_movsi (spare, reg));
 	      /* Add a USE to stop propagate_one_insn() from barfing.  */
-	      emit_insn (gen_rtx_USE (VOIDmode, spare));
+	      emit_insn (gen_prologue_use (spare));
 
 	      /* Decrement the stack.  */
 	      emit_insn (gen_movsi (reg, GEN_INT (- amount)));
@@ -10200,7 +10200,7 @@ thumb_expand_prologue ()
 		 analysis will not consider the restore redundant.  The
 		 register won't be used again in this function and isn't
 		 restored by the epilogue.  */
-	      emit_insn (gen_rtx_USE (VOIDmode, reg));
+	      emit_insn (gen_prologue_use (reg));
 	    }
 	  else
 	    {
@@ -10248,7 +10248,7 @@ thumb_expand_epilogue ()
       
   /* Emit a USE (stack_pointer_rtx), so that
      the stack adjustment will not be deleted.  */
-  emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
+  emit_insn (gen_prologue_use (stack_pointer_rtx));
 
   if (current_function_profile || TARGET_NO_SCHED_PRO)
     emit_insn (gen_blockage ());
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 5f508dd83873..3646fe5890f6 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -1,6 +1,6 @@
 ;;- Machine description for ARM for GNU compiler
-;;  Copyright 1991, 1993, 1994, 1995, 1996, 1996, 1997, 1998, 1999, 2000, 2001
-;;  Free Software Foundation, Inc.
+;;  Copyright 1991, 1993, 1994, 1995, 1996, 1996, 1997, 1998, 1999, 2000,
+;;  2001, 2002  Free Software Foundation, Inc.
 ;;  Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
 ;;  and Martin Simmons (@harleqn.co.uk).
 ;;  More major hacks by Richard Earnshaw (rearnsha@arm.com).
@@ -64,6 +64,11 @@
    (UNSPEC_CLZ	     5) ; `clz' instruction, count leading zeros (SImode):
 			;   operand 0 is the result,
 			;   operand 1 is the parameter.
+   (UNSPEC_PROLOGUE_USE 6) ; As USE insns are not meaningful after reload,
+   			; this unspec is used to prevent the deletion of
+   			; instructions setting registers for EH handling
+   			; and stack frame generation.  Operand 0 is the
+   			; register to "use".
   ]
 )
 
@@ -9187,3 +9192,8 @@
   ""
 )
 
+(define_insn "prologue_use"
+  [(unspec:SI [(match_operand:SI 0 "register_operand" "")] UNSPEC_PROLOGUE_USE)]
+  ""
+  "%@ %0 needed for prologue"
+)
-- 
GitLab