From fad95a5e0e0c210415533319a528a435ac5bd34a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 18 Jun 2014 15:37:47 -0400
Subject: [PATCH 59/77] modulo-sched.c: Use rtx_insn in various places

gcc/
	* modulo-sched.c (struct ps_reg_move_info): Strengthen field
	"insn" from rtx to rtx_insn *.
	(ps_rtl_insn): Likewise for return type.
	(doloop_register_get): Likewise for params "head", "tail" and
	locals "insn", "first_insn_not_to_check".
	(schedule_reg_move): Likewise for local "this_insn".
	(schedule_reg_moves): Add a checked cast to rtx_insn * to result
	of gen_move_insn for now.
	(reset_sched_times): Strengthen local "insn" from rtx to
	rtx_insn *.
	(permute_partial_schedule): Likewise.
	(duplicate_insns_of_cycles): Likewise for local "u_insn".
	(dump_insn_location): Likewise for param "insn".
	(loop_canon_p): Likewise for local "insn".
	(sms_schedule): Likewise.
	(print_partial_schedule): Likewise.
	(ps_has_conflicts): Likewise.
---
 gcc/modulo-sched.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c
index 328026a..911ef6b 100644
--- a/gcc/modulo-sched.c
+++ b/gcc/modulo-sched.c
@@ -155,7 +155,7 @@ struct ps_reg_move_info
   /* An instruction that sets NEW_REG to the correct value.  The first
      move associated with DEF will have an rhs of OLD_REG; later moves
      use the result of the previous move.  */
-  rtx insn;
+  rtx_insn *insn;
 };
 
 typedef struct ps_reg_move_info ps_reg_move_info;
@@ -305,7 +305,7 @@ ps_reg_move (partial_schedule_ptr ps, int id)
 
 /* Return the rtl instruction that is being scheduled by partial schedule
    instruction ID, which belongs to schedule PS.  */
-static rtx
+static rtx_insn *
 ps_rtl_insn (partial_schedule_ptr ps, int id)
 {
   if (id < ps->g->num_nodes)
@@ -342,10 +342,11 @@ ps_num_consecutive_stages (partial_schedule_ptr ps, int id)
    more than one occurrence in the loop besides the control part or the
    do-loop pattern is not of the form we expect.  */
 static rtx
-doloop_register_get (rtx head ATTRIBUTE_UNUSED, rtx tail ATTRIBUTE_UNUSED)
+doloop_register_get (rtx_insn *head ATTRIBUTE_UNUSED, rtx_insn *tail ATTRIBUTE_UNUSED)
 {
 #ifdef HAVE_doloop_end
-  rtx reg, condition, insn, first_insn_not_to_check;
+  rtx reg, condition;
+  rtx_insn *insn, *first_insn_not_to_check;
 
   if (!JUMP_P (tail))
     return NULL_RTX;
@@ -552,7 +553,7 @@ schedule_reg_move (partial_schedule_ptr ps, int i_reg_move,
   int start, end, c, ii;
   sbitmap_iterator sbi;
   ps_reg_move_info *move;
-  rtx this_insn;
+  rtx_insn *this_insn;
   ps_insn_ptr psi;
 
   move = ps_reg_move (ps, i_reg_move);
@@ -758,7 +759,8 @@ schedule_reg_moves (partial_schedule_ptr ps)
 	  move->old_reg = old_reg;
 	  move->new_reg = gen_reg_rtx (GET_MODE (prev_reg));
 	  move->num_consecutive_stages = distances[0] && distances[1] ? 2 : 1;
-	  move->insn = gen_move_insn (move->new_reg, copy_rtx (prev_reg));
+	  move->insn = as_a <rtx_insn *> (gen_move_insn (move->new_reg,
+							 copy_rtx (prev_reg)));
 	  bitmap_clear (move->uses);
 
 	  prev_reg = move->new_reg;
@@ -852,7 +854,7 @@ reset_sched_times (partial_schedule_ptr ps, int amount)
         if (dump_file)
           {
             /* Print the scheduling times after the rotation.  */
-	    rtx insn = ps_rtl_insn (ps, u);
+	    rtx_insn *insn = ps_rtl_insn (ps, u);
 
             fprintf (dump_file, "crr_insn->node=%d (insn id %d), "
                      "crr_insn->cycle=%d, min_cycle=%d", u,
@@ -883,7 +885,7 @@ permute_partial_schedule (partial_schedule_ptr ps, rtx last)
   for (row = 0; row < ii ; row++)
     for (ps_ij = ps->rows[row]; ps_ij; ps_ij = ps_ij->next_in_row)
       {
-	rtx insn = ps_rtl_insn (ps, ps_ij->id);
+	rtx_insn *insn = ps_rtl_insn (ps, ps_ij->id);
 
 	if (PREV_INSN (last) != insn)
 	  {
@@ -1105,7 +1107,7 @@ duplicate_insns_of_cycles (partial_schedule_ptr ps, int from_stage,
       {
 	int u = ps_ij->id;
 	int first_u, last_u;
-	rtx u_insn;
+	rtx_insn *u_insn;
 
         /* Do not duplicate any insn which refers to count_reg as it
            belongs to the control part.
@@ -1242,7 +1244,7 @@ loop_single_full_bb_p (struct loop *loop)
 /* Dump file:line from INSN's location info to dump_file.  */
 
 static void
-dump_insn_location (rtx insn)
+dump_insn_location (rtx_insn *insn)
 {
   if (dump_file && INSN_LOCATION (insn))
     {
@@ -1275,7 +1277,7 @@ loop_canon_p (struct loop *loop)
     {
       if (dump_file)
 	{
-	  rtx insn = BB_END (loop->header);
+	  rtx_insn *insn = BB_END (loop->header);
 
 	  fprintf (dump_file, "SMS loop many exits");
 	  dump_insn_location (insn);
@@ -1288,7 +1290,7 @@ loop_canon_p (struct loop *loop)
     {
       if (dump_file)
 	{
-	  rtx insn = BB_END (loop->header);
+	  rtx_insn *insn = BB_END (loop->header);
 
 	  fprintf (dump_file, "SMS loop many BBs.");
 	  dump_insn_location (insn);
@@ -1350,7 +1352,7 @@ setup_sched_infos (void)
 static void
 sms_schedule (void)
 {
-  rtx insn;
+  rtx_insn *insn;
   ddg_ptr *g_arr, g;
   int * node_order;
   int maxii, max_asap;
@@ -1413,7 +1415,7 @@ sms_schedule (void)
 
       if (dump_file)
 	{
-	  rtx insn = BB_END (loop->header);
+	  rtx_insn *insn = BB_END (loop->header);
 
 	  fprintf (dump_file, "SMS loop num: %d", loop->num);
 	  dump_insn_location (insn);
@@ -1548,7 +1550,7 @@ sms_schedule (void)
 
       if (dump_file)
 	{
-	  rtx insn = BB_END (loop->header);
+	  rtx_insn *insn = BB_END (loop->header);
 
 	  fprintf (dump_file, "SMS loop num: %d", loop->num);
 	  dump_insn_location (insn);
@@ -2931,7 +2933,7 @@ print_partial_schedule (partial_schedule_ptr ps, FILE *dump)
       fprintf (dump, "\n[ROW %d ]: ", i);
       while (ps_i)
 	{
-	  rtx insn = ps_rtl_insn (ps, ps_i->id);
+	  rtx_insn *insn = ps_rtl_insn (ps, ps_i->id);
 
 	  if (JUMP_P (insn))
 	    fprintf (dump, "%d (branch), ", INSN_UID (insn));
@@ -3193,7 +3195,7 @@ ps_has_conflicts (partial_schedule_ptr ps, int from, int to)
 	   crr_insn;
 	   crr_insn = crr_insn->next_in_row)
 	{
-	  rtx insn = ps_rtl_insn (ps, crr_insn->id);
+	  rtx_insn *insn = ps_rtl_insn (ps, crr_insn->id);
 
 	  if (!NONDEBUG_INSN_P (insn))
 	    continue;
-- 
1.8.5.3

