From 800fee8a661cdc9c998a0919524272643ebe6258 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 9 Jan 2014 12:22:43 -0500
Subject: [PATCH 116/159] FIXME: basic_block_il_dependent.x.head_, BB_HEAD
 etc; create_basic_block_structure

---
 gcc/basic-block.h  |  7 ++++---
 gcc/cfgrtl.c       | 26 +++++++++++++-------------
 gcc/sel-sched-ir.c |  6 +++++-
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index b298908..b258797 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -185,7 +185,7 @@ struct GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb"))) basic_block_d
   union basic_block_il_dependent {
       struct gimple_bb_info GTY ((tag ("0"))) gimple;
       struct {
-        rtx head_;
+        rtx_base_insn head_;
         struct rtl_bb_info * rtl;
       } GTY ((tag ("1"))) x;
     } GTY ((desc ("((%1.flags & BB_RTL) != 0)"))) il;
@@ -210,7 +210,7 @@ struct GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb"))) basic_block_d
 public:
 
   /* TODO: these should accept rtx_base_insn rather than rtx.  */
-  void set_bb_head (rtx insn) { il.x.head_ = insn; }
+  void set_bb_head (rtx_base_insn insn) { il.x.head_ = insn; }
   void set_bb_header (rtx_base_insn insn) { il.x.rtl->header_ = insn; }
   void set_bb_footer (rtx_base_insn insn) { il.x.rtl->footer_ = insn; }
   void set_bb_end (rtx insn) { il.x.rtl->end_ = insn; }
@@ -434,7 +434,8 @@ extern void remove_edge_raw (edge);
 extern void redirect_edge_succ (edge, basic_block);
 extern edge redirect_edge_succ_nodup (edge, basic_block);
 extern void redirect_edge_pred (edge, basic_block);
-extern basic_block create_basic_block_structure (rtx, rtx, rtx_note, basic_block);
+extern basic_block create_basic_block_structure (rtx_base_insn, rtx_base_insn,
+						 rtx_note, basic_block);
 extern void clear_bb_flags (void);
 extern void dump_bb_info (FILE *, basic_block, int, int, bool, bool);
 extern void dump_edge_info (FILE *, edge, int, int);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index a97a395..0dbae46 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -137,7 +137,7 @@ delete_insn (rtx insn)
 	{
 	  const char *name = LABEL_NAME (insn);
 	  basic_block bb = BLOCK_FOR_INSN (insn);
-	  rtx bb_note = NEXT_INSN (insn);
+	  rtx_base_insn bb_note = NEXT_INSN (insn);
 
 	  really_delete = false;
 	  PUT_CODE (insn, NOTE);
@@ -272,7 +272,8 @@ delete_insn_chain (rtx start, rtx finish, bool clear_bb)
    AFTER is the basic block we should be put after.  */
 
 basic_block
-create_basic_block_structure (rtx head, rtx end, rtx_note bb_note, basic_block after)
+create_basic_block_structure (rtx_base_insn head, rtx_base_insn end,
+			      rtx_note bb_note, basic_block after)
 {
   basic_block bb;
 
@@ -351,7 +352,10 @@ create_basic_block_structure (rtx head, rtx end, rtx_note bb_note, basic_block a
 static basic_block
 rtl_create_basic_block (void *headp, void *endp, basic_block after)
 {
-  rtx head = (rtx) headp, end = (rtx) endp;
+  rtx head_rtx = (rtx) headp;
+  rtx end_rtx = (rtx) endp;
+  rtx_base_insn head = head_rtx ? head_rtx->as_an_rtx_base_insn () : NULL;
+  rtx_base_insn end = end_rtx ? end_rtx->as_an_rtx_base_insn () : NULL;
   basic_block bb;
 
   /* Grow the basic block array if needed.  */
@@ -811,9 +815,9 @@ emit_nop_for_unique_locus_between (basic_block a, basic_block b)
 static void
 rtl_merge_blocks (basic_block a, basic_block b)
 {
-  rtx b_head = BB_HEAD (b), b_end = BB_END (b), a_end = BB_END (a);
-  rtx del_first = NULL_RTX, del_last = NULL_RTX;
-  rtx b_debug_start = b_end, b_debug_end = b_end;
+  rtx_base_insn b_head = BB_HEAD (b), b_end = BB_END (b), a_end = BB_END (a);
+  rtx_base_insn del_first = NULL_RTX_BASE_INSN, del_last = NULL_RTX_BASE_INSN;
+  rtx_base_insn b_debug_start = b_end, b_debug_end = b_end;
   bool forwarder_p = (b->flags & BB_FORWARDER_BLOCK) != 0;
   int b_empty = 0;
 
@@ -884,7 +888,7 @@ rtl_merge_blocks (basic_block a, basic_block b)
   /* Delete everything marked above as well as crap that might be
      hanging out between the two blocks.  */
   a->set_bb_end (a_end);
-  b->set_bb_head (b_empty ? NULL_RTX : b_head);
+  b->set_bb_head (b_empty ? NULL_RTX_BASE_INSN : b_head);
   delete_insn_chain (del_first, del_last, true);
 
   /* When not optimizing CFG and the edge is the only place in RTL which holds
@@ -901,7 +905,7 @@ rtl_merge_blocks (basic_block a, basic_block b)
       update_bb_for_insn_chain (a_end, b_debug_end, a);
 
       a->set_bb_end (b_debug_end);
-      b->set_bb_head (NULL_RTX);
+      b->set_bb_head (NULL_RTX_BASE_INSN);
     }
   else if (b_end != b_debug_end)
     {
@@ -5126,11 +5130,7 @@ struct cfg_hooks cfg_layout_rtl_cfg_hooks = {
 
 rtx_base_insn BB_HEAD (const_basic_block bb)
 {
-  rtx tmp = bb->il.x.head_;
-  if (tmp)
-    return tmp->as_an_rtx_base_insn ();
-  else
-    return NULL;
+  return bb->il.x.head_;
 }
 
 rtx_base_insn BB_END (const_basic_block bb)
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index a9905ad..7b3f1e7 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -5340,7 +5340,11 @@ sel_create_basic_block (void *headp, void *endp, basic_block after)
     new_bb = orig_cfg_hooks.create_basic_block (headp, endp, after);
   else
     {
-      new_bb = create_basic_block_structure ((rtx) headp, (rtx) endp,
+      rtx head_rtx = (rtx) headp;
+      rtx end_rtx = (rtx) endp;
+      rtx_base_insn head = head_rtx ? head_rtx->as_an_rtx_base_insn () : NULL;
+      rtx_base_insn end = end_rtx ? end_rtx->as_an_rtx_base_insn () : NULL;
+      new_bb = create_basic_block_structure (head, end,
 					     new_bb_note, after);
       new_bb->aux = NULL;
     }
-- 
1.7.11.7

