From 144e4e51894b1c51d11b63fe4310dc40f76749cd Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 9 Jan 2014 16:34:36 -0500
Subject: [PATCH 133/159] FIXME: get_ebb_head_tail and others

---
 gcc/config/sh/sh.c |  3 ++-
 gcc/ddg.c          |  2 +-
 gcc/haifa-sched.c  | 10 +++++-----
 gcc/modulo-sched.c | 18 +++++++++---------
 gcc/sched-ebb.c    |  4 ++--
 gcc/sched-int.h    |  9 +++++----
 gcc/sched-rgn.c    | 28 ++++++++++++++--------------
 gcc/sel-sched.c    |  2 +-
 8 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index de0251a..9591f5a 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -10987,7 +10987,8 @@ find_insn_regmode_weight (rtx insn, enum machine_mode mode)
 static void
 find_regmode_weight (basic_block b, enum machine_mode mode)
 {
-  rtx insn, next_tail, head, tail;
+  rtx insn, next_tail;
+  rtx_base_insn head, tail;
 
   get_ebb_head_tail (b, b, &head, &tail);
   next_tail = NEXT_INSN (tail);
diff --git a/gcc/ddg.c b/gcc/ddg.c
index 1518b55..c5cbeb2 100644
--- a/gcc/ddg.c
+++ b/gcc/ddg.c
@@ -507,7 +507,7 @@ build_intra_loop_deps (ddg_ptr g)
   int i;
   /* Hold the dependency analysis state during dependency calculations.  */
   struct deps_desc tmp_deps;
-  rtx head, tail;
+  rtx_base_insn head, tail;
 
   /* Build the dependence information, using the sched_analyze function.  */
   init_deps_global ();
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 95dcff5..5a37f30 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -3978,7 +3978,7 @@ concat_note_lists (rtx_base_insn from_end, rtx_base_insn *to_endp)
 /* Delete notes between HEAD and TAIL and put them in the chain
    of notes ended by NOTE_LIST.  */
 void
-remove_notes (rtx head, rtx tail)
+remove_notes (rtx_base_insn head, rtx tail)
 {
   rtx_base_insn next_tail, insn, next;
 
@@ -3987,8 +3987,7 @@ remove_notes (rtx head, rtx tail)
     return;
 
   next_tail = NEXT_INSN (tail);
-  /* TODO: remove the cast from the next line.  */
-  for (insn = head->as_an_rtx_base_insn (); insn != next_tail; insn = next)
+  for (insn = head; insn != next_tail; insn = next)
     {
       next = NEXT_INSN (insn);
       if (!NOTE_P (insn))
@@ -4682,7 +4681,8 @@ resolve_dependencies (rtx insn)
 /* Return the head and tail pointers of ebb starting at BEG and ending
    at END.  */
 void
-get_ebb_head_tail (basic_block beg, basic_block end, rtx *headp, rtx *tailp)
+get_ebb_head_tail (basic_block beg, basic_block end,
+		   rtx_base_insn *headp, rtx_base_insn *tailp)
 {
   rtx_base_insn beg_head = BB_HEAD (beg);
   rtx_base_insn beg_tail = BB_END (beg);
@@ -6509,7 +6509,7 @@ schedule_block (basic_block *target_bb, state_t init_state)
 /* Set_priorities: compute priority of each insn in the block.  */
 
 int
-set_priorities (rtx head, rtx tail)
+set_priorities (rtx_base_insn head, rtx_base_insn tail)
 {
   rtx insn;
   int n_insn;
diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c
index b78e6bd..e94db47 100644
--- a/gcc/modulo-sched.c
+++ b/gcc/modulo-sched.c
@@ -394,15 +394,15 @@ doloop_register_get (rtx head ATTRIBUTE_UNUSED, rtx tail ATTRIBUTE_UNUSED)
    that the number of iterations is a compile-time constant.  If so,
    return the rtx that sets COUNT_REG to a constant, and set COUNT to
    this constant.  Otherwise return 0.  */
-static rtx
+static rtx_base_insn
 const_iteration_count (rtx count_reg, basic_block pre_header,
 		       HOST_WIDEST_INT * count)
 {
-  rtx insn;
-  rtx head, tail;
+  rtx_base_insn insn;
+  rtx_base_insn head, tail;
 
   if (! pre_header)
-    return NULL_RTX;
+    return NULL_RTX_BASE_INSN;
 
   get_ebb_head_tail (pre_header, pre_header, &head, &tail);
 
@@ -418,10 +418,10 @@ const_iteration_count (rtx count_reg, basic_block pre_header,
 	    return insn;
 	  }
 
-	return NULL_RTX;
+	return NULL_RTX_BASE_INSN;
       }
 
-  return NULL_RTX;
+  return NULL_RTX_BASE_INSN;
 }
 
 /* A very simple resource-based lower bound on the initiation interval.
@@ -1208,7 +1208,7 @@ loop_single_full_bb_p (struct loop *loop)
 
   for (i = 0; i < loop->num_nodes ; i++)
     {
-      rtx head, tail;
+      rtx_base_insn head, tail;
       bool empty_bb = true;
 
       if (bbs[i] == loop->header)
@@ -1396,7 +1396,7 @@ sms_schedule (void)
      indexed by the loop index.  */
   FOR_EACH_LOOP (loop, 0)
     {
-      rtx head, tail;
+      rtx_base_insn head, tail;
       rtx count_reg;
 
       /* For debugging.  */
@@ -1534,7 +1534,7 @@ sms_schedule (void)
   /* We don't want to perform SMS on new loops - created by versioning.  */
   FOR_EACH_LOOP (loop, 0)
     {
-      rtx head, tail;
+      rtx_base_insn head, tail;
       rtx count_reg, count_init;
       int mii, rec_mii, stage_count, min_cycle;
       HOST_WIDEST_INT loop_count = 0;
diff --git a/gcc/sched-ebb.c b/gcc/sched-ebb.c
index 87997a4..19bbdbc 100644
--- a/gcc/sched-ebb.c
+++ b/gcc/sched-ebb.c
@@ -62,7 +62,7 @@ static int rank (rtx, rtx);
 static int ebb_contributes_to_priority (rtx, rtx);
 static basic_block earliest_block_with_similiar_load (basic_block, rtx);
 static void add_deps_for_risky_insns (rtx_base_insn, rtx_base_insn);
-static void debug_ebb_dependencies (rtx, rtx);
+static void debug_ebb_dependencies (rtx_base_insn, rtx_base_insn);
 
 static void ebb_add_remove_insn (rtx, int);
 static void ebb_add_block (basic_block, basic_block);
@@ -98,7 +98,7 @@ schedule_more_p (void)
 
 /* Print dependency information about ebb between HEAD and TAIL.  */
 static void
-debug_ebb_dependencies (rtx head, rtx tail)
+debug_ebb_dependencies (rtx_base_insn head, rtx_base_insn tail)
 {
   fprintf (sched_dump,
 	   ";;   --------------- forward dependences: ------------ \n");
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index 83138ca..85e42a1 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -127,7 +127,7 @@ extern int insn_luid (rtx);
    finished.  */
 extern rtx_base_insn note_list;
 
-extern void remove_notes (rtx, rtx);
+extern void remove_notes (rtx_base_insn, rtx);
 extern rtx restore_other_notes (rtx, basic_block);
 extern void sched_insns_init (rtx);
 extern void sched_insns_finish (void);
@@ -1338,13 +1338,14 @@ extern void initialize_live_range_shrinkage (void);
 extern void finish_live_range_shrinkage (void);
 extern void sched_init_region_reg_pressure_info (void);
 extern int haifa_classify_insn (const_rtx);
-extern void get_ebb_head_tail (basic_block, basic_block, rtx *, rtx *);
+extern void get_ebb_head_tail (basic_block, basic_block,
+			       rtx_base_insn *, rtx_base_insn *);
 extern int no_real_insns_p (const_rtx, const_rtx);
 
 extern int insn_cost (rtx);
 extern int dep_cost_1 (dep_t, dw_t);
 extern int dep_cost (dep_t);
-extern int set_priorities (rtx, rtx);
+extern int set_priorities (rtx_base_insn, rtx_base_insn);
 
 extern void sched_setup_bb_reg_pressure_info (basic_block, rtx);
 extern bool schedule_block (basic_block *, state_t);
@@ -1445,7 +1446,7 @@ extern void rgn_make_new_region_out_of_new_block (basic_block);
 extern void compute_priorities (void);
 extern void increase_insn_priority (rtx, int);
 extern void debug_rgn_dependencies (int);
-extern void debug_dependencies (rtx, rtx);
+extern void debug_dependencies (rtx_base_insn, rtx_base_insn);
 extern void free_rgn_deps (void);
 extern int contributes_to_priority (rtx, rtx);
 extern void extend_rgns (int *, int *, sbitmap, int *);
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 0e4e35a..2191c05 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -2128,9 +2128,9 @@ init_ready_list (void)
   for (bb_src = target_bb + 1; bb_src < current_nr_blocks; bb_src++)
     if (IS_VALID (bb_src))
       {
-	rtx src_head;
-	rtx src_next_tail;
-	rtx tail, head;
+	rtx_base_insn src_head;
+	rtx_base_insn src_next_tail;
+	rtx_base_insn tail, head;
 
 	get_ebb_head_tail (EBB_FIRST_BB (bb_src), EBB_LAST_BB (bb_src),
 			   &head, &tail);
@@ -2709,7 +2709,7 @@ propagate_deps (int bb, struct deps_desc *pred_deps)
 static void
 compute_block_dependences (int bb)
 {
-  rtx head, tail;
+  rtx_base_insn head, tail;
   struct deps_desc tmp_deps;
 
   tmp_deps = bb_deps[bb];
@@ -2738,8 +2738,8 @@ compute_block_dependences (int bb)
 static void
 free_block_dependencies (int bb)
 {
-  rtx head;
-  rtx tail;
+  rtx_base_insn head;
+  rtx_base_insn tail;
 
   get_ebb_head_tail (EBB_FIRST_BB (bb), EBB_LAST_BB (bb), &head, &tail);
 
@@ -2781,7 +2781,7 @@ debug_rgn_dependencies (int from_bb)
 
   for (bb = from_bb; bb < current_nr_blocks; bb++)
     {
-      rtx head, tail;
+      rtx_base_insn head, tail;
 
       get_ebb_head_tail (EBB_FIRST_BB (bb), EBB_LAST_BB (bb), &head, &tail);
       fprintf (sched_dump, "\n;;   --- Region Dependences --- b %d bb %d \n",
@@ -2793,10 +2793,10 @@ debug_rgn_dependencies (int from_bb)
 
 /* Print dependencies information for instructions between HEAD and TAIL.
    ??? This function would probably fit best in haifa-sched.c.  */
-void debug_dependencies (rtx head, rtx tail)
+void debug_dependencies (rtx_base_insn head, rtx_base_insn tail)
 {
-  rtx insn;
-  rtx next_tail = NEXT_INSN (tail);
+  rtx_base_insn insn;
+  rtx_base_insn next_tail = NEXT_INSN (tail);
 
   fprintf (sched_dump, ";;   %7s%6s%6s%6s%6s%6s%14s\n",
 	   "insn", "code", "bb", "dep", "prio", "cost",
@@ -2881,7 +2881,7 @@ free_rgn_deps (void)
 
   for (bb = 0; bb < current_nr_blocks; bb++)
     {
-      rtx head, tail;
+      rtx_base_insn head, tail;
 
       gcc_assert (EBB_FIRST_BB (bb) == EBB_LAST_BB (bb));
       get_ebb_head_tail (EBB_FIRST_BB (bb), EBB_LAST_BB (bb), &head, &tail);
@@ -2901,7 +2901,7 @@ compute_priorities (void)
   current_sched_info->sched_max_insns_priority = 0;
   for (bb = 0; bb < current_nr_blocks; bb++)
     {
-      rtx head, tail;
+      rtx_base_insn head, tail;
 
       gcc_assert (EBB_FIRST_BB (bb) == EBB_LAST_BB (bb));
       get_ebb_head_tail (EBB_FIRST_BB (bb), EBB_LAST_BB (bb), &head, &tail);
@@ -3003,7 +3003,7 @@ schedule_region (int rgn)
       for (bb = 0; bb < current_nr_blocks; bb++)
 	{
 	  basic_block first_bb, last_bb;
-	  rtx head, tail;
+	  rtx_base_insn head, tail;
 
 	  first_bb = EBB_FIRST_BB (bb);
 	  last_bb = EBB_LAST_BB (bb);
@@ -3023,7 +3023,7 @@ schedule_region (int rgn)
   for (bb = 0; bb < current_nr_blocks; bb++)
     {
       basic_block first_bb, last_bb, curr_bb;
-      rtx head, tail;
+      rtx_base_insn head, tail;
 
       first_bb = EBB_FIRST_BB (bb);
       last_bb = EBB_LAST_BB (bb);
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 4f293e4..7cd16eb 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -7051,7 +7051,7 @@ simplify_changed_insns (void)
 static void
 find_ebb_boundaries (basic_block bb, bitmap scheduled_blocks)
 {
-  insn_t head, tail;
+  rtx_base_insn head, tail;
   basic_block bb1 = bb;
   if (sched_verbose >= 2)
     sel_print ("Finishing schedule in bbs: ");
-- 
1.7.11.7

