From 9a23b2e0411a3671285dbf98efa4365f1774d598 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 27 Dec 2013 19:57:41 -0500
Subject: [PATCH 004/159] FIXME: introduce rtx_jump_insn

---
 gcc/coretypes.h |  3 +++
 gcc/emit-rtl.c  | 37 +++++++++++++++++++++----------------
 gcc/rtl.h       | 35 +++++++++++++++++++++++++++++------
 3 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index f5c70d1..53a501d 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -59,6 +59,9 @@ struct rtvec_def;
 typedef struct rtvec_def *rtvec;
 typedef const struct rtvec_def *const_rtvec;
 
+struct rtx_jump_insn_def;
+typedef struct rtx_jump_insn_def *rtx_jump_insn;
+
 struct rtx_code_label_def;
 typedef struct rtx_code_label_def *rtx_code_label;
 
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index c0dd47d..6ae143c 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3700,9 +3700,9 @@ make_debug_insn_raw (rtx pattern)
 static rtx
 make_jump_insn_raw (rtx pattern)
 {
-  rtx insn;
+  rtx_jump_insn insn;
 
-  insn = rtx_alloc (JUMP_INSN);
+  insn = rtx_alloc (JUMP_INSN)->as_an_rtx_jump_insn ();
   INSN_UID (insn) = cur_insn_uid++;
 
   PATTERN (insn) = pattern;
@@ -4210,11 +4210,12 @@ emit_insn_before_noloc (rtx x, rtx before, basic_block bb)
 /* Make an instruction with body X and code JUMP_INSN
    and output it before the instruction BEFORE.  */
 
-rtx
+rtx_jump_insn
 emit_jump_insn_before_noloc (rtx x, rtx before)
 {
-  return emit_pattern_before_noloc (x, before, NULL_RTX, NULL,
-				    make_jump_insn_raw);
+  return emit_pattern_before_noloc (
+	   x, before, NULL_RTX, NULL,
+	   make_jump_insn_raw)->as_an_rtx_jump_insn ();
 }
 
 /* Make an instruction with body X and code CALL_INSN
@@ -4359,10 +4360,11 @@ emit_insn_after_noloc (rtx x, rtx after, basic_block bb)
 /* Make an insn of code JUMP_INSN with body X
    and output it after the insn AFTER.  */
 
-rtx
+rtx_jump_insn
 emit_jump_insn_after_noloc (rtx x, rtx after)
 {
-  return emit_pattern_after_noloc (x, after, NULL, make_jump_insn_raw);
+  return emit_pattern_after_noloc (x, after, NULL,
+				   make_jump_insn_raw)->as_an_rtx_jump_insn ();
 }
 
 /* Make an instruction with body X and code CALL_INSN
@@ -4532,17 +4534,19 @@ emit_insn_after (rtx pattern, rtx after)
 }
 
 /* Like emit_jump_insn_after_noloc, but set INSN_LOCATION according to LOC.  */
-rtx
+rtx_jump_insn
 emit_jump_insn_after_setloc (rtx pattern, rtx after, int loc)
 {
-  return emit_pattern_after_setloc (pattern, after, loc, make_jump_insn_raw);
+  return emit_pattern_after_setloc (pattern, after, loc,
+				    make_jump_insn_raw)->as_an_rtx_jump_insn ();
 }
 
 /* Like emit_jump_insn_after_noloc, but set INSN_LOCATION according to AFTER.  */
-rtx
+rtx_jump_insn
 emit_jump_insn_after (rtx pattern, rtx after)
 {
-  return emit_pattern_after (pattern, after, true, make_jump_insn_raw);
+  return emit_pattern_after (pattern, after, true,
+			     make_jump_insn_raw)->as_an_rtx_jump_insn ();
 }
 
 /* Like emit_call_insn_after_noloc, but set INSN_LOCATION according to LOC.  */
@@ -4645,19 +4649,20 @@ emit_insn_before (rtx pattern, rtx before)
 }
 
 /* like emit_insn_before_noloc, but set INSN_LOCATION according to LOC.  */
-rtx
+rtx_jump_insn
 emit_jump_insn_before_setloc (rtx pattern, rtx before, int loc)
 {
-  return emit_pattern_before_setloc (pattern, before, loc, false,
-				     make_jump_insn_raw);
+  return emit_pattern_before_setloc (
+	   pattern, before, loc, false,
+	   make_jump_insn_raw)->as_an_rtx_jump_insn ();
 }
 
 /* Like emit_jump_insn_before_noloc, but set INSN_LOCATION according to BEFORE.  */
-rtx
+rtx_jump_insn
 emit_jump_insn_before (rtx pattern, rtx before)
 {
   return emit_pattern_before (pattern, before, true, false,
-			      make_jump_insn_raw);
+			      make_jump_insn_raw)->as_an_rtx_jump_insn ();
 }
 
 /* Like emit_insn_before_noloc, but set INSN_LOCATION according to LOC.  */
diff --git a/gcc/rtl.h b/gcc/rtl.h
index e84e7b7..fcd6436 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -371,6 +371,12 @@ public:
      Keep these in the same order as the corresponding DEF_RTL_EXPR within
      rtl.def.  */
 
+  inline rtx_jump_insn
+  as_an_rtx_jump_insn ()
+  {
+    return as_a <rtx_jump_insn_def> (this);
+  }
+
   inline rtx_code_label
   as_an_rtx_code_label ()
   {
@@ -406,6 +412,23 @@ struct GTY(()) rtx_base_insn_def : public rtx_def
 };
 
 /* An expression with the invariant that:
+     GET_CODE (X) == JUMP_INSN
+   i.e. a "jump_insn".  */
+
+struct GTY(()) rtx_jump_insn_def : public rtx_base_insn_def
+{
+  /* No extra fields, but adds invariant: (GET_CODE (X) == JUMP_INSN).  */
+};
+
+template <>
+template <>
+inline bool
+is_a_helper <rtx_jump_insn_def>::test (rtx rt)
+{
+  return rt->code == JUMP_INSN;
+}
+
+/* An expression with the invariant that:
      GET_CODE (X) == CODE_LABEL
    i.e. a "code_label".  */
 
@@ -1950,9 +1973,9 @@ extern rtx assign_temp (tree, int, int);
 extern rtx emit_insn_before (rtx, rtx);
 extern rtx emit_insn_before_noloc (rtx, rtx, basic_block);
 extern rtx emit_insn_before_setloc (rtx, rtx, int);
-extern rtx emit_jump_insn_before (rtx, rtx);
-extern rtx emit_jump_insn_before_noloc (rtx, rtx);
-extern rtx emit_jump_insn_before_setloc (rtx, rtx, int);
+extern rtx_jump_insn emit_jump_insn_before (rtx, rtx);
+extern rtx_jump_insn emit_jump_insn_before_noloc (rtx, rtx);
+extern rtx_jump_insn emit_jump_insn_before_setloc (rtx, rtx, int);
 extern rtx emit_call_insn_before (rtx, rtx);
 extern rtx emit_call_insn_before_noloc (rtx, rtx);
 extern rtx emit_call_insn_before_setloc (rtx, rtx, int);
@@ -1965,9 +1988,9 @@ extern rtx_note emit_note_before (enum insn_note, rtx);
 extern rtx emit_insn_after (rtx, rtx);
 extern rtx emit_insn_after_noloc (rtx, rtx, basic_block);
 extern rtx emit_insn_after_setloc (rtx, rtx, int);
-extern rtx emit_jump_insn_after (rtx, rtx);
-extern rtx emit_jump_insn_after_noloc (rtx, rtx);
-extern rtx emit_jump_insn_after_setloc (rtx, rtx, int);
+extern rtx_jump_insn emit_jump_insn_after (rtx, rtx);
+extern rtx_jump_insn emit_jump_insn_after_noloc (rtx, rtx);
+extern rtx_jump_insn emit_jump_insn_after_setloc (rtx, rtx, int);
 extern rtx emit_call_insn_after (rtx, rtx);
 extern rtx emit_call_insn_after_noloc (rtx, rtx);
 extern rtx emit_call_insn_after_setloc (rtx, rtx, int);
-- 
1.7.11.7

