From 019d4636e659005fc65c0d14b2680d3449465d30 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 9 Jan 2014 14:29:58 -0500
Subject: [PATCH 121/159] FIXME: reorder_insns

---
 gcc/cfgcleanup.c | 12 ++++++------
 gcc/emit-rtl.c   |  2 +-
 gcc/function.c   | 12 ++++++------
 gcc/ifcvt.c      |  8 ++++----
 gcc/rtl.h        |  2 +-
 gcc/sel-sched.c  | 16 +++++++++++-----
 gcc/stmt.c       |  4 ++--
 7 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 1ea4c3d..b9b3250 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2288,7 +2288,7 @@ try_head_merge_bb (basic_block bb)
   basic_block final_dest_bb = NULL;
   int max_match = INT_MAX;
   edge e0;
-  rtx *headptr, *currptr, *nextptr;
+  rtx_base_insn *headptr, *currptr, *nextptr;
   bool changed, moveall;
   unsigned ix;
   rtx e0_last_head, cond;
@@ -2427,9 +2427,9 @@ try_head_merge_bb (basic_block bb)
   live = BITMAP_ALLOC (NULL);
   live_union = BITMAP_ALLOC (NULL);
 
-  currptr = XNEWVEC (rtx, nedges);
-  headptr = XNEWVEC (rtx, nedges);
-  nextptr = XNEWVEC (rtx, nedges);
+  currptr = XNEWVEC (rtx_base_insn, nedges);
+  headptr = XNEWVEC (rtx_base_insn, nedges);
+  nextptr = XNEWVEC (rtx_base_insn, nedges);
 
   for (ix = 0; ix < nedges; ix++)
     {
@@ -2525,7 +2525,7 @@ try_head_merge_bb (basic_block bb)
 	    break;
 	  for (ix = 0; ix < nedges; ix++)
 	    {
-	      rtx curr = currptr[ix];
+	      rtx_base_insn curr = currptr[ix];
 	      do
 		curr = NEXT_INSN (curr);
 	      while (!NONDEBUG_INSN_P (curr));
@@ -2538,7 +2538,7 @@ try_head_merge_bb (basic_block bb)
       if (!moveall)
 	for (ix = 0; ix < nedges; ix++)
 	  {
-	    rtx curr = currptr[ix];
+	    rtx_base_insn curr = currptr[ix];
 	    do
 	      curr = NEXT_INSN (curr);
 	    while (!NONDEBUG_INSN_P (curr));
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index a035051..5013b36 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -4156,7 +4156,7 @@ reorder_insns_nobb (rtx from, rtx to, rtx after)
 
 /* Same as function above, but take care to update BB boundaries.  */
 void
-reorder_insns (rtx from, rtx to, rtx after)
+reorder_insns (rtx_base_insn from, rtx_base_insn to, rtx_base_insn after)
 {
   rtx_base_insn prev = PREV_INSN (from);
   basic_block bb, bb2;
diff --git a/gcc/function.c b/gcc/function.c
index 3b395c9..9fb229e 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5892,9 +5892,9 @@ thread_prologue_and_epilogue_insns (void)
   bitmap_head bb_flags;
   unsigned max_grow_size;
 #endif
-  rtx returnjump;
+  rtx_base_insn returnjump;
   rtx seq ATTRIBUTE_UNUSED;
-  rtx epilogue_end ATTRIBUTE_UNUSED;
+  rtx_base_insn epilogue_end ATTRIBUTE_UNUSED;
   rtx prologue_seq ATTRIBUTE_UNUSED, split_prologue_seq ATTRIBUTE_UNUSED;
   edge e, entry_edge, orig_entry_edge, exit_fallthru_edge;
   edge_iterator ei;
@@ -5906,7 +5906,7 @@ thread_prologue_and_epilogue_insns (void)
   inserted = false;
   seq = NULL_RTX;
   epilogue_end = NULL_RTX_NOTE;
-  returnjump = NULL_RTX;
+  returnjump = NULL_RTX_BASE_INSN;
 
   /* Can't deal with multiple successors of the entry block at the
      moment.  Function should always have at least one entry
@@ -6667,7 +6667,7 @@ epilogue_done:
 #ifdef HAVE_epilogue
   if (epilogue_end)
     {
-      rtx insn, next;
+      rtx_base_insn insn, next;
 
       /* Similarly, move any line notes that appear after the epilogue.
          There is no need, however, to be quite so anal about the existence
@@ -6707,7 +6707,7 @@ reposition_prologue_and_epilogue_notes (void)
   if (prologue_insn_hash != NULL)
     {
       size_t len = htab_elements (prologue_insn_hash);
-      rtx insn, last = NULL, note = NULL;
+      rtx_base_insn insn, last = NULL, note = NULL;
 
       /* Scan from the beginning until we reach the last prologue insn.  */
       /* ??? While we do have the CFG intact, there are two problems:
@@ -6759,7 +6759,7 @@ reposition_prologue_and_epilogue_notes (void)
       FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
 	{
 	  rtx_base_insn insn;
-	  rtx first = NULL, note = NULL;
+	  rtx_base_insn first = NULL, note = NULL;
 	  basic_block bb = e->src;
 
 	  /* Scan from the beginning until we reach the first epilogue insn. */
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index cd6afc9..c6cc50a 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -2473,7 +2473,7 @@ noce_process_if_block (struct noce_if_info *if_info)
   basic_block join_bb = if_info->join_bb;	/* JOIN */
   rtx jump = if_info->jump;
   rtx cond = if_info->cond;
-  rtx insn_a, insn_b;
+  rtx_base_insn insn_a, insn_b;
   rtx set_a, set_b;
   rtx orig_x, x, a, b;
 
@@ -2540,7 +2540,7 @@ noce_process_if_block (struct noce_if_info *if_info)
 	  || reg_overlap_mentioned_p (x, cond)
 	  || reg_overlap_mentioned_p (x, a)
 	  || modified_between_p (x, insn_b, jump))
-	insn_b = set_b = NULL_RTX;
+	set_b = insn_b = NULL_RTX_BASE_INSN;
     }
 
   /* If x has side effects then only the if-then-else form is safe to
@@ -2609,7 +2609,7 @@ noce_process_if_block (struct noce_if_info *if_info)
 	  if ((note = find_reg_note (insn_b, REG_EQUAL, NULL_RTX)) != 0)
 	    remove_note (insn_b, note);
 
-	  insn_b = NULL_RTX;
+	  insn_b = NULL_RTX_BASE_INSN;
 	}
       /* If we have "x = b; if (...) x = a;", and x has side-effects, then
 	 x must be executed twice.  */
@@ -2676,7 +2676,7 @@ noce_process_if_block (struct noce_if_info *if_info)
 
   if (!else_bb && set_b)
     {
-      insn_b = set_b = NULL_RTX;
+      set_b = insn_b = NULL_RTX_BASE_INSN;
       b = orig_x;
       goto retry;
     }
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 223266a..8ade70f 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -3003,7 +3003,7 @@ extern void mark_reg_pointer (rtx, int);
 extern void mark_user_reg (rtx);
 extern void reset_used_flags (rtx);
 extern void set_used_flags (rtx);
-extern void reorder_insns (rtx, rtx, rtx);
+extern void reorder_insns (rtx_base_insn, rtx_base_insn, rtx_base_insn);
 extern void reorder_insns_nobb (rtx, rtx, rtx);
 extern int get_max_insn_count (void);
 extern int in_sequence_p (void);
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index f68c9d5..4f293e4 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4950,11 +4950,14 @@ move_cond_jump (rtx insn, bnd_t bnd)
 {
   edge ft_edge;
   basic_block block_from, block_next, block_new, block_bnd, bb;
-  rtx next, prev, link, head;
+  rtx_base_insn next, prev;
+  rtx head, prev_rtx;
 
   block_from = BLOCK_FOR_INSN (insn);
   block_bnd = BLOCK_FOR_INSN (BND_TO (bnd));
-  prev = BND_TO (bnd);
+  prev_rtx = BND_TO (bnd);
+  prev = prev_rtx ? prev_rtx->as_an_rtx_base_insn () : NULL;
+  /* TODO: remove prev_rtx and the cast in the line above.  */
 
 #ifdef ENABLE_CHECKING
   /* Moving of jump should not cross any other jumps or beginnings of new
@@ -4963,7 +4966,7 @@ move_cond_jump (rtx insn, bnd_t bnd)
   if (block_from != block_bnd)
     {
       bb = block_from;
-      for (link = PREV_INSN (insn); link != PREV_INSN (prev);
+      for (rtx_base_insn link = PREV_INSN (insn); link != PREV_INSN (prev);
            link = PREV_INSN (link))
         {
           if (INSN_P (link))
@@ -5005,9 +5008,12 @@ move_cond_jump (rtx insn, bnd_t bnd)
          In this case we don't have to move anything in this block.  */
       if (NEXT_INSN (to) != from)
         {
-          reorder_insns (from, to, head);
+          reorder_insns (from ? from->as_an_rtx_base_insn () : NULL,
+			 to ? to->as_an_rtx_base_insn () : NULL,
+			 head ? head->as_an_rtx_base_insn () : NULL);
+	  /* TODO: remove the casting above.  */
 
-          for (link = to; link != head; link = PREV_INSN (link))
+          for (rtx link = to; link != head; link = PREV_INSN (link))
             EXPR_ORIG_BB_INDEX (INSN_EXPR (link)) = block_new->index;
           head = to;
         }
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 5305de8..c9a25b0 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1269,7 +1269,7 @@ expand_case (gimple stmt)
      type, so we should never get a zero here.  */
   gcc_assert (count > 0);
 
-  rtx before_case = get_last_insn ();
+  rtx_base_insn before_case = get_last_insn ();
 
   /* Decide how to expand this switch.
      The two options at this point are a dispatch table (casesi or
@@ -1313,7 +1313,7 @@ expand_sjlj_dispatch_table (rtx dispatch_index,
   int ncases = dispatch_table.length ();
 
   do_pending_stack_adjust ();
-  rtx before_case = get_last_insn ();
+  rtx_base_insn before_case = get_last_insn ();
 
   /* Expand as a decrement-chain if there are 5 or fewer dispatch
      labels.  This covers more than 98% of the cases in libjava,
-- 
1.7.11.7

