From 59707b3d0d1e97b6d09ed8f01410b25a3a7f5e1d Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 30 Dec 2013 16:26:05 -0500
Subject: [PATCH 018/159] Strengthen return types of various {next|prev}_*insn
 from rtx to rtx_base_insn.

These should all eventuall require an rtx_base_insn as an argument,
but we'll save that for a later patch.

gcc/
	* rtl.h (previous_insn): Strengthen return type from rtx to rtx_base_insn.
	(next_insn): Likewise.
	(prev_nonnote_insn): Likewise.
	(prev_nonnote_insn_bb): Likewise.
	(next_nonnote_insn): Likewise.
	(next_nonnote_insn_bb): Likewise.
	(prev_nondebug_insn): Likewise.
	(next_nondebug_insn): Likewise.
	(prev_nonnote_nondebug_insn): Likewise.
	(next_nonnote_nondebug_insn): Likewise.
	(prev_real_insn): Likewise.
	(next_real_insn): Likewise.
	(prev_active_insn): Likewise.
	(next_active_insn): Likewise.

	(last_call_insn): Strengthen return type from rtx to rtx_call_insn.

	* emit-rtl.c (next_insn): Strengthen return type from rtx to rtx_base_insn.
	(previous_insn): Likewise.
	(next_nonnote_insn): Likewise.
	(next_nonnote_insn_bb): Likewise.
	(prev_nonnote_insn): Likewise.
	(prev_nonnote_insn_bb): Likewise.
	(next_nondebug_insn): Likewise.
	(prev_nondebug_insn): Likewise.
	(next_nonnote_nondebug_insn): Likewise.
	(prev_nonnote_nondebug_insn): Likewise.
	(next_real_insn): Likewise.
	(prev_real_insn): Likewise.
	(next_active_insn): Likewise.
	(prev_active_insn): Likewise.

	(last_call_insn): Strengthen return type from rtx to rtx_call_insn.
---
 gcc/emit-rtl.c | 109 ++++++++++++++++++++++++++++++++++++++++-----------------
 gcc/rtl.h      |  30 ++++++++--------
 2 files changed, 92 insertions(+), 47 deletions(-)

diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 0015d60..1be6d6f 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3075,7 +3075,7 @@ get_max_insn_count (void)
 /* Return the next insn.  If it is a SEQUENCE, return the first insn
    of the sequence.  */
 
-rtx
+rtx_base_insn
 next_insn (rtx insn)
 {
   if (insn)
@@ -3086,13 +3086,16 @@ next_insn (rtx insn)
 	insn = XVECEXP (PATTERN (insn), 0, 0);
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the previous insn.  If it is a SEQUENCE, return the last insn
    of the sequence.  */
 
-rtx
+rtx_base_insn
 previous_insn (rtx insn)
 {
   if (insn)
@@ -3103,13 +3106,16 @@ previous_insn (rtx insn)
 	insn = XVECEXP (PATTERN (insn), 0, XVECLEN (PATTERN (insn), 0) - 1);
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the next insn after INSN that is not a NOTE.  This routine does not
    look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 next_nonnote_insn (rtx insn)
 {
   while (insn)
@@ -3119,14 +3125,17 @@ next_nonnote_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the next insn after INSN that is not a NOTE, but stop the
    search before we enter another basic block.  This routine does not
    look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 next_nonnote_insn_bb (rtx insn)
 {
   while (insn)
@@ -3135,16 +3144,19 @@ next_nonnote_insn_bb (rtx insn)
       if (insn == 0 || !NOTE_P (insn))
 	break;
       if (NOTE_INSN_BASIC_BLOCK_P (insn))
-	return NULL_RTX;
+	return NULL_RTX_BASE_INSN;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the previous insn before INSN that is not a NOTE.  This routine does
    not look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 prev_nonnote_insn (rtx insn)
 {
   while (insn)
@@ -3154,14 +3166,17 @@ prev_nonnote_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the previous insn before INSN that is not a NOTE, but stop
    the search before we enter another basic block.  This routine does
    not look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 prev_nonnote_insn_bb (rtx insn)
 {
   while (insn)
@@ -3170,16 +3185,19 @@ prev_nonnote_insn_bb (rtx insn)
       if (insn == 0 || !NOTE_P (insn))
 	break;
       if (NOTE_INSN_BASIC_BLOCK_P (insn))
-	return NULL_RTX;
+	return NULL_RTX_BASE_INSN;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the next insn after INSN that is not a DEBUG_INSN.  This
    routine does not look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 next_nondebug_insn (rtx insn)
 {
   while (insn)
@@ -3189,13 +3207,16 @@ next_nondebug_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the previous insn before INSN that is not a DEBUG_INSN.
    This routine does not look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 prev_nondebug_insn (rtx insn)
 {
   while (insn)
@@ -3205,13 +3226,16 @@ prev_nondebug_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the next insn after INSN that is not a NOTE nor DEBUG_INSN.
    This routine does not look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 next_nonnote_nondebug_insn (rtx insn)
 {
   while (insn)
@@ -3221,13 +3245,16 @@ next_nonnote_nondebug_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the previous insn before INSN that is not a NOTE nor DEBUG_INSN.
    This routine does not look inside SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 prev_nonnote_nondebug_insn (rtx insn)
 {
   while (insn)
@@ -3237,14 +3264,17 @@ prev_nonnote_nondebug_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the next INSN, CALL_INSN or JUMP_INSN after INSN;
    or 0, if there is none.  This routine does not look inside
    SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 next_real_insn (rtx insn)
 {
   while (insn)
@@ -3254,14 +3284,17 @@ next_real_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the last INSN, CALL_INSN or JUMP_INSN before INSN;
    or 0, if there is none.  This routine does not look inside
    SEQUENCEs.  */
 
-rtx
+rtx_base_insn
 prev_real_insn (rtx insn)
 {
   while (insn)
@@ -3271,13 +3304,16 @@ prev_real_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Return the last CALL_INSN in the current list, or 0 if there is none.
    This routine does not look inside SEQUENCEs.  */
 
-rtx
+rtx_call_insn
 last_call_insn (void)
 {
   rtx insn;
@@ -3287,7 +3323,10 @@ last_call_insn (void)
        insn = PREV_INSN (insn))
     ;
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_call_insn ();
+  else
+    return NULL;
 }
 
 /* Find the next insn after INSN that really does something.  This routine
@@ -3305,7 +3344,7 @@ active_insn_p (const_rtx insn)
 		      && GET_CODE (PATTERN (insn)) != CLOBBER))));
 }
 
-rtx
+rtx_base_insn
 next_active_insn (rtx insn)
 {
   while (insn)
@@ -3315,14 +3354,17 @@ next_active_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 /* Find the last insn before INSN that really does something.  This routine
    does not look inside SEQUENCEs.  After reload this also skips over
    standalone USE and CLOBBER insn.  */
 
-rtx
+rtx_base_insn
 prev_active_insn (rtx insn)
 {
   while (insn)
@@ -3332,7 +3374,10 @@ prev_active_insn (rtx insn)
 	break;
     }
 
-  return insn;
+  if (insn)
+    return insn->as_an_rtx_base_insn ();
+  else
+    return NULL;
 }
 
 #ifdef HAVE_cc0
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 26a7cc3..ccc6faa 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2164,21 +2164,21 @@ extern rtx gen_use (rtx);
 extern rtx emit_use (rtx);
 extern rtx_base_insn make_insn_raw (rtx);
 extern void add_function_usage_to (rtx, rtx);
-extern rtx last_call_insn (void);
-extern rtx previous_insn (rtx);
-extern rtx next_insn (rtx);
-extern rtx prev_nonnote_insn (rtx);
-extern rtx prev_nonnote_insn_bb (rtx);
-extern rtx next_nonnote_insn (rtx);
-extern rtx next_nonnote_insn_bb (rtx);
-extern rtx prev_nondebug_insn (rtx);
-extern rtx next_nondebug_insn (rtx);
-extern rtx prev_nonnote_nondebug_insn (rtx);
-extern rtx next_nonnote_nondebug_insn (rtx);
-extern rtx prev_real_insn (rtx);
-extern rtx next_real_insn (rtx);
-extern rtx prev_active_insn (rtx);
-extern rtx next_active_insn (rtx);
+extern rtx_call_insn last_call_insn (void);
+extern rtx_base_insn previous_insn (rtx);
+extern rtx_base_insn next_insn (rtx);
+extern rtx_base_insn prev_nonnote_insn (rtx);
+extern rtx_base_insn prev_nonnote_insn_bb (rtx);
+extern rtx_base_insn next_nonnote_insn (rtx);
+extern rtx_base_insn next_nonnote_insn_bb (rtx);
+extern rtx_base_insn prev_nondebug_insn (rtx);
+extern rtx_base_insn next_nondebug_insn (rtx);
+extern rtx_base_insn prev_nonnote_nondebug_insn (rtx);
+extern rtx_base_insn next_nonnote_nondebug_insn (rtx);
+extern rtx_base_insn prev_real_insn (rtx);
+extern rtx_base_insn next_real_insn (rtx);
+extern rtx_base_insn prev_active_insn (rtx);
+extern rtx_base_insn next_active_insn (rtx);
 extern int active_insn_p (const_rtx);
 extern rtx next_cc0_user (rtx);
 extern rtx prev_cc0_setter (rtx);
-- 
1.7.11.7

