From d792520c3cb11f780e98fc985da69715e0e8ca3a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 9 Jan 2014 11:54:17 -0500
Subject: [PATCH 113/159] FIXME: unlink_insn_chain, ret of
 duplicate_insn_chain, and rtl_bb_info.header_

---
 gcc/basic-block.h |  4 ++--
 gcc/cfgrtl.c      | 39 +++++++++++++++++++--------------------
 gcc/rtl.h         |  4 ++--
 3 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 93196a0..8850625 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -126,7 +126,7 @@ struct GTY(()) rtl_bb_info {
 
   /* In CFGlayout mode points to insn notes/jumptables to be placed just before
      and after the block.   */
-  rtx header_;
+  rtx_base_insn header_;
   rtx footer_;
 };
 
@@ -211,7 +211,7 @@ public:
 
   /* TODO: these should accept rtx_base_insn rather than rtx.  */
   void set_bb_head (rtx insn) { il.x.head_ = insn; }
-  void set_bb_header (rtx insn) { il.x.rtl->header_ = insn; }
+  void set_bb_header (rtx_base_insn insn) { il.x.rtl->header_ = insn; }
   void set_bb_footer (rtx insn) { il.x.rtl->footer_ = insn; }
   void set_bb_end (rtx insn) { il.x.rtl->end_ = insn; }
 
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index ec8b278..d91eb08 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -64,10 +64,10 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Holds the interesting leading and trailing notes for the function.
    Only applicable if the CFG is in cfglayout mode.  */
-static GTY(()) rtx cfg_layout_function_footer;
+static GTY(()) rtx_base_insn cfg_layout_function_footer;
 static GTY(()) rtx cfg_layout_function_header;
 
-static rtx skip_insns_after_block (basic_block);
+static rtx_base_insn skip_insns_after_block (basic_block);
 static void record_effective_endpoints (void);
 static rtx label_for_bb (basic_block);
 static void fixup_reorder_chain (void);
@@ -1450,7 +1450,7 @@ rtl_redirect_edge_and_branch (edge e, basic_block target)
 void
 emit_barrier_after_bb (basic_block bb)
 {
-  rtx barrier = emit_barrier_after (BB_END (bb));
+  rtx_base_insn barrier = emit_barrier_after (BB_END (bb));
   gcc_assert (current_ir_type () == IR_RTL_CFGRTL
               || current_ir_type () == IR_RTL_CFGLAYOUT);
   if (current_ir_type () == IR_RTL_CFGLAYOUT)
@@ -3313,8 +3313,8 @@ fixup_abnormal_edges (void)
 
 /* Cut the insns from FIRST to LAST out of the insns stream.  */
 
-rtx
-unlink_insn_chain (rtx first, rtx last)
+rtx_base_insn
+unlink_insn_chain (rtx_base_insn first, rtx_base_insn last)
 {
   rtx_base_insn prevfirst = PREV_INSN (first);
   rtx_base_insn nextlast = NEXT_INSN (last);
@@ -3336,12 +3336,12 @@ unlink_insn_chain (rtx first, rtx last)
    associated with BB (e.g., barriers). If there are any such insns,
    we return the last one. Otherwise, we return the end of BB.  */
 
-static rtx
+static rtx_base_insn
 skip_insns_after_block (basic_block bb)
 {
-  rtx insn, last_insn, next_head, prev;
+  rtx_base_insn insn, last_insn, next_head, prev;
 
-  next_head = NULL_RTX;
+  next_head = NULL_RTX_BASE_INSN;
   if (bb->next_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
     next_head = BB_HEAD (bb->next_bb);
 
@@ -3440,7 +3440,7 @@ label_for_bb (basic_block bb)
 static void
 record_effective_endpoints (void)
 {
-  rtx next_insn;
+  rtx_base_insn next_insn;
   basic_block bb;
   rtx_base_insn insn;
 
@@ -3462,7 +3462,7 @@ record_effective_endpoints (void)
   next_insn = get_insns ();
   FOR_EACH_BB (bb)
     {
-      rtx end;
+      rtx_base_insn end;
 
       if (PREV_INSN (BB_HEAD (bb)) && next_insn != BB_HEAD (bb))
 	bb->set_bb_header (unlink_insn_chain (next_insn,
@@ -4099,10 +4099,10 @@ cfg_layout_can_duplicate_bb_p (const_basic_block bb)
   return true;
 }
 
-rtx
+rtx_base_insn
 duplicate_insn_chain (rtx from, rtx to)
 {
-  rtx insn, next, copy;
+  rtx_base_insn insn, next, copy;
   rtx_note last;
 
   /* Avoid updating of boundaries of previous basic block.  The
@@ -4111,7 +4111,10 @@ duplicate_insn_chain (rtx from, rtx to)
 
   /* Create copy at the end of INSN chain.  The chain will
      be reordered later.  */
-  for (insn = from; insn != NEXT_INSN (to); insn = NEXT_INSN (insn))
+  /* TODO: remove the cast below.  */
+  for (insn = from->as_an_rtx_base_insn ();
+       insn != NEXT_INSN (to);
+       insn = NEXT_INSN (insn))
     {
       switch (GET_CODE (insn))
 	{
@@ -4193,7 +4196,7 @@ duplicate_insn_chain (rtx from, rtx to)
 static basic_block
 cfg_layout_duplicate_bb (basic_block bb)
 {
-  rtx insn;
+  rtx_base_insn insn;
   basic_block new_bb;
 
   insn = duplicate_insn_chain (BB_HEAD (bb), BB_END (bb));
@@ -4431,7 +4434,7 @@ cfg_layout_redirect_edge_and_branch_force (edge e, basic_block dest)
 static void
 cfg_layout_delete_block (basic_block bb)
 {
-  rtx insn, next, prev = PREV_INSN (BB_HEAD (bb)), *to, remaints;
+  rtx_base_insn insn, next, prev = PREV_INSN (BB_HEAD (bb)), *to, remaints;
 
   if (BB_HEADER (bb))
     {
@@ -5141,11 +5144,7 @@ rtx_base_insn BB_END (const_basic_block bb)
 
 rtx_base_insn BB_HEADER (const_basic_block bb)
 {
-  rtx tmp = bb->il.x.rtl->header_;
-  if (tmp)
-    return tmp->as_an_rtx_base_insn ();
-  else
-    return NULL;
+  return bb->il.x.rtl->header_;
 }
 
 rtx_base_insn BB_FOOTER (const_basic_block bb)
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 7fcd2e9..a8add45 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -3025,7 +3025,7 @@ extern void delete_insn (rtx);
 extern rtx_base_insn entry_of_function (void);
 extern void emit_insn_at_entry (rtx);
 extern void delete_insn_chain (rtx, rtx, bool);
-extern rtx unlink_insn_chain (rtx, rtx);
+extern rtx_base_insn unlink_insn_chain (rtx_base_insn, rtx_base_insn);
 extern void delete_insn_and_edges (rtx);
 extern rtx gen_lowpart_SUBREG (enum machine_mode, rtx);
 extern rtx gen_const_mem (enum machine_mode, rtx);
@@ -3101,7 +3101,7 @@ extern int fixup_args_size_notes (rtx, rtx, int);
 
 /* In cfgrtl.c */
 extern void print_rtl_with_bb (FILE *, const_rtx, int);
-extern rtx duplicate_insn_chain (rtx, rtx);
+extern rtx_base_insn duplicate_insn_chain (rtx, rtx);
 
 /* In expmed.c */
 extern void init_expmed (void);
-- 
1.7.11.7

