From 83ffa96b0940ee4aabe54204c0012126c5473b26 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 18 Jun 2014 15:15:05 -0400
Subject: [PATCH 086/133] get_ebb_head_tail works with rtx_insn

gcc/
	* sched-int.h (get_ebb_head_tail): Strengthen params "headp" and
	"tailp" from rtx * to rtx_insn **.

	* ddg.c (build_intra_loop_deps): Strengthen locals head", "tail"
	from rtx to rtx_insn *.
	* haifa-sched.c (get_ebb_head_tail): Strengthen params "headp" and
	"tailp" from rtx * to rtx_insn **.  Strengthen locals "beg_head",
	"beg_tail", "end_head", "end_tail", "note", "next", "prev" from
	rtx to rtx_insn *.
	* modulo-sched.c (const_iteration_count): Strengthen return type
	and locals "insn", "head", "tail" from rtx to rtx_insn *.  Replace
	use of NULL_RTX with NULL when working with insns.
	(loop_single_full_bb_p): Strengthen locals "head", "tail" from rtx
	to rtx_insn *.
	(sms_schedule): Likewise.
	* sched-rgn.c (init_ready_list): Likewise, also for locals
	"src_head" and "src_next_tail".
	(compute_block_dependences): Likewise.
	(free_block_dependencies): Likewise.
	(debug_rgn_dependencies): Likewise.
	(free_rgn_deps): Likewise.
	(compute_priorities): Likewise.
	(schedule_region): Likewise.
	* sel-sched.c (find_ebb_boundaries): Likewise.

	* config/sh/sh.c (find_insn_regmode_weight): Strengthen locals
	"insn", "next_tail", "head", "tail" from rtx to rtx_insn *.
---
 gcc/config/sh/sh.c |  2 +-
 gcc/ddg.c          |  2 +-
 gcc/haifa-sched.c  | 15 ++++++++-------
 gcc/modulo-sched.c | 20 ++++++++++----------
 gcc/sched-int.h    |  3 ++-
 gcc/sched-rgn.c    | 22 +++++++++++-----------
 gcc/sel-sched.c    |  2 +-
 7 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index df6a5bb..a1374e0 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -11067,7 +11067,7 @@ 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 *insn, *next_tail, *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 1da2836..6baca86 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_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 fd46977..4e8a772 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -4686,12 +4686,13 @@ 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_insn **headp, rtx_insn **tailp)
 {
-  rtx beg_head = BB_HEAD (beg);
-  rtx beg_tail = BB_END (beg);
-  rtx end_head = BB_HEAD (end);
-  rtx end_tail = BB_END (end);
+  rtx_insn *beg_head = BB_HEAD (beg);
+  rtx_insn * beg_tail = BB_END (beg);
+  rtx_insn * end_head = BB_HEAD (end);
+  rtx_insn * end_tail = BB_END (end);
 
   /* Don't include any notes or labels at the beginning of the BEG
      basic block, or notes at the end of the END basic blocks.  */
@@ -4704,7 +4705,7 @@ get_ebb_head_tail (basic_block beg, basic_block end, rtx *headp, rtx *tailp)
       beg_head = NEXT_INSN (beg_head);
     else if (DEBUG_INSN_P (beg_head))
       {
-	rtx note, next;
+	rtx_insn * note, *next;
 
 	for (note = NEXT_INSN (beg_head);
 	     note != beg_tail;
@@ -4742,7 +4743,7 @@ get_ebb_head_tail (basic_block beg, basic_block end, rtx *headp, rtx *tailp)
       end_tail = PREV_INSN (end_tail);
     else if (DEBUG_INSN_P (end_tail))
       {
-	rtx note, prev;
+	rtx_insn * note, *prev;
 
 	for (note = PREV_INSN (end_tail);
 	     note != end_head;
diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c
index 16caa8f..328026a 100644
--- a/gcc/modulo-sched.c
+++ b/gcc/modulo-sched.c
@@ -392,17 +392,17 @@ doloop_register_get (rtx head ATTRIBUTE_UNUSED, rtx tail ATTRIBUTE_UNUSED)
 
 /* Check if COUNT_REG is set to a constant in the PRE_HEADER block, so
    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
+   return the rtx_insn that sets COUNT_REG to a constant, and set COUNT to
    this constant.  Otherwise return 0.  */
-static rtx
+static rtx_insn *
 const_iteration_count (rtx count_reg, basic_block pre_header,
 		       int64_t * count)
 {
-  rtx insn;
-  rtx head, tail;
+  rtx_insn *insn;
+  rtx_insn *head, *tail;
 
   if (! pre_header)
-    return NULL_RTX;
+    return NULL;
 
   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;
       }
 
-  return NULL_RTX;
+  return NULL;
 }
 
 /* A very simple resource-based lower bound on the initiation interval.
@@ -1211,7 +1211,7 @@ loop_single_full_bb_p (struct loop *loop)
 
   for (i = 0; i < loop->num_nodes ; i++)
     {
-      rtx head, tail;
+      rtx_insn *head, *tail;
       bool empty_bb = true;
 
       if (bbs[i] == loop->header)
@@ -1399,7 +1399,7 @@ sms_schedule (void)
      indexed by the loop index.  */
   FOR_EACH_LOOP (loop, 0)
     {
-      rtx head, tail;
+      rtx_insn *head, *tail;
       rtx count_reg;
 
       /* For debugging.  */
@@ -1537,7 +1537,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_insn *head, *tail;
       rtx count_reg, count_init;
       int mii, rec_mii, stage_count, min_cycle;
       int64_t loop_count = 0;
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index 7f236a1..df7795d 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -1342,7 +1342,8 @@ extern void finish_live_range_shrinkage (void);
 extern void sched_init_region_reg_pressure_info (void);
 extern void free_global_sched_pressure_data (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_insn **, rtx_insn **);
 extern int no_real_insns_p (const_rtx, const_rtx);
 
 extern int insn_cost (rtx);
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 53ba0a4..f8660f8 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -2140,9 +2140,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_insn *src_head;
+	rtx_insn *src_next_tail;
+	rtx_insn *tail, *head;
 
 	get_ebb_head_tail (EBB_FIRST_BB (bb_src), EBB_LAST_BB (bb_src),
 			   &head, &tail);
@@ -2721,7 +2721,7 @@ propagate_deps (int bb, struct deps_desc *pred_deps)
 static void
 compute_block_dependences (int bb)
 {
-  rtx head, tail;
+  rtx_insn *head, *tail;
   struct deps_desc tmp_deps;
 
   tmp_deps = bb_deps[bb];
@@ -2750,8 +2750,8 @@ compute_block_dependences (int bb)
 static void
 free_block_dependencies (int bb)
 {
-  rtx head;
-  rtx tail;
+  rtx_insn *head;
+  rtx_insn *tail;
 
   get_ebb_head_tail (EBB_FIRST_BB (bb), EBB_LAST_BB (bb), &head, &tail);
 
@@ -2793,7 +2793,7 @@ debug_rgn_dependencies (int from_bb)
 
   for (bb = from_bb; bb < current_nr_blocks; bb++)
     {
-      rtx head, tail;
+      rtx_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",
@@ -2894,7 +2894,7 @@ free_rgn_deps (void)
 
   for (bb = 0; bb < current_nr_blocks; bb++)
     {
-      rtx head, tail;
+      rtx_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);
@@ -2914,7 +2914,7 @@ compute_priorities (void)
   current_sched_info->sched_max_insns_priority = 0;
   for (bb = 0; bb < current_nr_blocks; bb++)
     {
-      rtx head, tail;
+      rtx_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);
@@ -3025,7 +3025,7 @@ schedule_region (int rgn)
       for (bb = 0; bb < current_nr_blocks; bb++)
 	{
 	  basic_block first_bb, last_bb;
-	  rtx head, tail;
+	  rtx_insn *head, *tail;
 
 	  first_bb = EBB_FIRST_BB (bb);
 	  last_bb = EBB_LAST_BB (bb);
@@ -3045,7 +3045,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_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 8181ec2..d697b95 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -7031,7 +7031,7 @@ simplify_changed_insns (void)
 static void
 find_ebb_boundaries (basic_block bb, bitmap scheduled_blocks)
 {
-  insn_t head, tail;
+  rtx_insn *head, *tail;
   basic_block bb1 = bb;
   if (sched_verbose >= 2)
     sel_print ("Finishing schedule in bbs: ");
-- 
1.8.5.3

