From 05efec1fa48b6d135783355e0b5bfee79bbb6a5e Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 31 Dec 2013 12:55:16 -0500
Subject: [PATCH 045/159] FIXME: flow_find_ and ifcvt.c types

---
 gcc/basic-block.h |  6 ++--
 gcc/cfgcleanup.c  | 28 +++++++++---------
 gcc/ifcvt.c       | 85 ++++++++++++++++++++++++++++---------------------------
 3 files changed, 62 insertions(+), 57 deletions(-)

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 953525e..cf4566c 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -839,10 +839,12 @@ enum replace_direction { dir_none, dir_forward, dir_backward, dir_both };
 
 /* In cfgcleanup.c.  */
 extern bool cleanup_cfg (int);
-extern int flow_find_cross_jump (basic_block, basic_block, rtx *, rtx *,
+extern int flow_find_cross_jump (basic_block, basic_block,
+				 rtx_base_insn *, rtx_base_insn *,
                                  enum replace_direction*);
 extern int flow_find_head_matching_sequence (basic_block, basic_block,
-					     rtx *, rtx *, int);
+					     rtx_base_insn *, rtx_base_insn *,
+					     int);
 
 extern bool delete_unreachable_blocks (void);
 
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 9cd8117..6d87f3d 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -1247,8 +1247,8 @@ merge_notes (rtx i1, rtx i2)
     DID_FALLTHRU.  Otherwise, stops at the head of the bb.  */
 
 static void
-walk_to_nondebug_insn (rtx *i1, basic_block *bb1, bool follow_fallthru,
-                       bool *did_fallthru)
+walk_to_nondebug_insn (rtx_base_insn *i1, basic_block *bb1,
+		       bool follow_fallthru, bool *did_fallthru)
 {
   edge fallthru;
 
@@ -1290,10 +1290,11 @@ walk_to_nondebug_insn (rtx *i1, basic_block *bb1, bool follow_fallthru,
    store the head of the blocks in *F1 and *F2.  */
 
 int
-flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
+flow_find_cross_jump (basic_block bb1, basic_block bb2,
+		      rtx_base_insn *f1, rtx_base_insn *f2,
                       enum replace_direction *dir_p)
 {
-  rtx i1, i2, last1, last2, afterlast1, afterlast2;
+  rtx_base_insn i1, i2, last1, last2, afterlast1, afterlast2;
   int ninsns = 0;
   rtx p1;
   enum replace_direction dir, last_dir, afterlast_dir;
@@ -1310,7 +1311,7 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
      need to be compared for equivalence, which we'll do below.  */
 
   i1 = BB_END (bb1);
-  last1 = afterlast1 = last2 = afterlast2 = NULL_RTX;
+  last1 = afterlast1 = last2 = afterlast2 = NULL_RTX_BASE_INSN;
   if (onlyjump_p (i1)
       || (returnjump_p (i1) && !side_effects_p (PATTERN (i1))))
     {
@@ -1425,10 +1426,11 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
    instructions.  */
 
 int
-flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx *f1,
-				  rtx *f2, int stop_after)
+flow_find_head_matching_sequence (basic_block bb1, basic_block bb2,
+				  rtx_base_insn *f1, rtx_base_insn *f2,
+				  int stop_after)
 {
-  rtx i1, i2, last1, last2, beforelast1, beforelast2;
+  rtx_base_insn i1, i2, last1, last2, beforelast1, beforelast2;
   int ninsns = 0;
   edge e;
   edge_iterator ei;
@@ -1443,7 +1445,7 @@ flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx *f1,
 
   i1 = BB_HEAD (bb1);
   i2 = BB_HEAD (bb2);
-  last1 = beforelast1 = last2 = beforelast2 = NULL_RTX;
+  last1 = beforelast1 = last2 = beforelast2 = NULL_RTX_BASE_INSN;
 
   while (true)
     {
@@ -1880,11 +1882,11 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
   basic_block src1 = e1->src, src2 = e2->src;
   basic_block redirect_to, redirect_from, to_remove;
   basic_block osrc1, osrc2, redirect_edges_to, tmp;
-  rtx newpos1, newpos2;
+  rtx_base_insn newpos1, newpos2;
   edge s;
   edge_iterator ei;
 
-  newpos1 = newpos2 = NULL_RTX;
+  newpos1 = newpos2 = NULL_RTX_BASE_INSN;
 
   /* If we have partitioned hot/cold basic blocks, it is a bad idea
      to try this optimization.
@@ -1951,7 +1953,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2,
       SWAP (basic_block, osrc1, osrc2);
       SWAP (basic_block, src1, src2);
       SWAP (edge, e1, e2);
-      SWAP (rtx, newpos1, newpos2);
+      SWAP (rtx_base_insn, newpos1, newpos2);
 #undef SWAP
     }
 
@@ -2383,7 +2385,7 @@ try_head_merge_bb (basic_block bb)
   for (ix = 1; ix < nedges; ix++)
     {
       edge e = EDGE_SUCC (bb, ix);
-      rtx e0_last, e_last;
+      rtx_base_insn e0_last, e_last;
       int nmatch;
 
       nmatch = flow_find_head_matching_sequence (e0->dest, e->dest,
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 8d1cf97..5717b79 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -86,12 +86,12 @@ static int cond_exec_changed_p;
 /* Forward references.  */
 static int count_bb_insns (const_basic_block);
 static bool cheap_bb_rtx_cost_p (const_basic_block, int, int);
-static rtx first_active_insn (basic_block);
-static rtx last_active_insn (basic_block, int);
-static rtx find_active_insn_before (basic_block, rtx);
-static rtx find_active_insn_after (basic_block, rtx);
+static rtx_base_insn first_active_insn (basic_block);
+static rtx_base_insn last_active_insn (basic_block, int);
+static rtx_base_insn find_active_insn_before (basic_block, rtx_base_insn);
+static rtx_base_insn find_active_insn_after (basic_block, rtx_base_insn);
 static basic_block block_fallthru (basic_block);
-static int cond_exec_process_insns (ce_if_block_t *, rtx, rtx, rtx, int, int);
+static int cond_exec_process_insns (ce_if_block_t *, rtx_base_insn, rtx, rtx, int, int);
 static rtx cond_exec_get_condition (rtx);
 static rtx noce_get_condition (rtx, rtx *, bool);
 static int noce_operand_ok (const_rtx);
@@ -204,38 +204,38 @@ cheap_bb_rtx_cost_p (const_basic_block bb, int scale, int max_cost)
 
 /* Return the first non-jump active insn in the basic block.  */
 
-static rtx
+static rtx_base_insn
 first_active_insn (basic_block bb)
 {
-  rtx insn = BB_HEAD (bb);
+  rtx_base_insn insn = BB_HEAD (bb);
 
   if (LABEL_P (insn))
     {
       if (insn == BB_END (bb))
-	return NULL_RTX;
+	return NULL_RTX_BASE_INSN;
       insn = NEXT_INSN (insn);
     }
 
   while (NOTE_P (insn) || DEBUG_INSN_P (insn))
     {
       if (insn == BB_END (bb))
-	return NULL_RTX;
+	return NULL_RTX_BASE_INSN;
       insn = NEXT_INSN (insn);
     }
 
   if (JUMP_P (insn))
-    return NULL_RTX;
+    return NULL_RTX_BASE_INSN;
 
   return insn;
 }
 
 /* Return the last non-jump active (non-jump) insn in the basic block.  */
 
-static rtx
+static rtx_base_insn
 last_active_insn (basic_block bb, int skip_use_p)
 {
-  rtx insn = BB_END (bb);
-  rtx head = BB_HEAD (bb);
+  rtx_base_insn insn = BB_END (bb);
+  rtx_base_insn head = BB_HEAD (bb);
 
   while (NOTE_P (insn)
 	 || JUMP_P (insn)
@@ -245,23 +245,23 @@ last_active_insn (basic_block bb, int skip_use_p)
 	     && GET_CODE (PATTERN (insn)) == USE))
     {
       if (insn == head)
-	return NULL_RTX;
+	return NULL_RTX_BASE_INSN;
       insn = PREV_INSN (insn);
     }
 
   if (LABEL_P (insn))
-    return NULL_RTX;
+    return NULL_RTX_BASE_INSN;
 
   return insn;
 }
 
 /* Return the active insn before INSN inside basic block CURR_BB. */
 
-static rtx
-find_active_insn_before (basic_block curr_bb, rtx insn)
+static rtx_base_insn
+find_active_insn_before (basic_block curr_bb, rtx_base_insn insn)
 {
   if (!insn || insn == BB_HEAD (curr_bb))
-    return NULL_RTX;
+    return NULL_RTX_BASE_INSN;
 
   while ((insn = PREV_INSN (insn)) != NULL_RTX)
     {
@@ -270,7 +270,7 @@ find_active_insn_before (basic_block curr_bb, rtx insn)
 
       /* No other active insn all the way to the start of the basic block. */
       if (insn == BB_HEAD (curr_bb))
-        return NULL_RTX;
+        return NULL_RTX_BASE_INSN;
     }
 
   return insn;
@@ -278,11 +278,11 @@ find_active_insn_before (basic_block curr_bb, rtx insn)
 
 /* Return the active insn after INSN inside basic block CURR_BB. */
 
-static rtx
-find_active_insn_after (basic_block curr_bb, rtx insn)
+static rtx_base_insn
+find_active_insn_after (basic_block curr_bb, rtx_base_insn insn)
 {
   if (!insn || insn == BB_END (curr_bb))
-    return NULL_RTX;
+    return NULL_RTX_BASE_INSN;
 
   while ((insn = NEXT_INSN (insn)) != NULL_RTX)
     {
@@ -291,7 +291,7 @@ find_active_insn_after (basic_block curr_bb, rtx insn)
 
       /* No other active insn all the way to the end of the basic block. */
       if (insn == BB_END (curr_bb))
-        return NULL_RTX;
+        return NULL_RTX_BASE_INSN;
     }
 
   return insn;
@@ -313,14 +313,14 @@ block_fallthru (basic_block bb)
 
 static int
 cond_exec_process_insns (ce_if_block_t *ce_info ATTRIBUTE_UNUSED,
-			 /* if block information */rtx start,
+			 /* if block information */rtx_base_insn start,
 			 /* first insn to look at */rtx end,
 			 /* last insn to look at */rtx test,
 			 /* conditional execution test */int prob_val,
 			 /* probability of branch taken. */int mod_ok)
 {
   int must_be_last = FALSE;
-  rtx insn;
+  rtx_base_insn insn;
   rtx xtest;
   rtx pattern;
 
@@ -441,20 +441,20 @@ cond_exec_process_if_block (ce_if_block_t * ce_info,
   basic_block then_bb = ce_info->then_bb;	/* THEN */
   basic_block else_bb = ce_info->else_bb;	/* ELSE or NULL */
   rtx test_expr;		/* expression in IF_THEN_ELSE that is tested */
-  rtx then_start;		/* first insn in THEN block */
-  rtx then_end;			/* last insn + 1 in THEN block */
-  rtx else_start = NULL_RTX;	/* first insn in ELSE block or NULL */
-  rtx else_end = NULL_RTX;	/* last insn + 1 in ELSE block */
+  rtx_base_insn then_start;	/* first insn in THEN block */
+  rtx_base_insn then_end;	/* last insn + 1 in THEN block */
+  rtx_base_insn else_start = NULL_RTX_BASE_INSN; /* first insn in ELSE block or NULL */
+  rtx_base_insn else_end = NULL_RTX_BASE_INSN; /* last insn + 1 in ELSE block */
   int max;			/* max # of insns to convert.  */
   int then_mod_ok;		/* whether conditional mods are ok in THEN */
   rtx true_expr;		/* test for else block insns */
   rtx false_expr;		/* test for then block insns */
   int true_prob_val;		/* probability of else block */
   int false_prob_val;		/* probability of then block */
-  rtx then_last_head = NULL_RTX;	/* Last match at the head of THEN */
-  rtx else_last_head = NULL_RTX;	/* Last match at the head of ELSE */
-  rtx then_first_tail = NULL_RTX;	/* First match at the tail of THEN */
-  rtx else_first_tail = NULL_RTX;	/* First match at the tail of ELSE */
+  rtx_base_insn then_last_head = NULL;	/* Last match at the head of THEN */
+  rtx_base_insn else_last_head = NULL;	/* Last match at the head of ELSE */
+  rtx_base_insn then_first_tail = NULL; /* First match at the tail of THEN */
+  rtx_base_insn else_first_tail = NULL;	/* First match at the tail of ELSE */
   int then_n_insns, else_n_insns, n_insns;
   enum rtx_code false_code;
   rtx note;
@@ -509,9 +509,9 @@ cond_exec_process_if_block (ce_if_block_t * ce_info,
 					 &then_first_tail, &else_first_tail,
 					 NULL);
       if (then_first_tail == BB_HEAD (then_bb))
-	then_start = then_end = NULL_RTX;
+	then_start = then_end = NULL_RTX_BASE_INSN;
       if (else_first_tail == BB_HEAD (else_bb))
-	else_start = else_end = NULL_RTX;
+	else_start = else_end = NULL_RTX_BASE_INSN;
 
       if (n_matching > 0)
 	{
@@ -549,9 +549,9 @@ cond_exec_process_if_block (ce_if_block_t * ce_info,
 	    }
 
 	  if (then_last_head == then_end)
-	    then_start = then_end = NULL_RTX;
+	    then_start = then_end = NULL_RTX_BASE_INSN;
 	  if (else_last_head == else_end)
-	    else_start = else_end = NULL_RTX;
+	    else_start = else_end = NULL_RTX_BASE_INSN;
 
 	  if (n_matching > 0)
 	    {
@@ -613,7 +613,7 @@ cond_exec_process_if_block (ce_if_block_t * ce_info,
 
       do
 	{
-	  rtx start, end;
+	  rtx_base_insn start, end;
 	  rtx t, f;
 	  enum rtx_code f_code;
 
@@ -715,7 +715,7 @@ cond_exec_process_if_block (ce_if_block_t * ce_info,
      that the remaining one is executed first for both branches.  */
   if (then_first_tail)
     {
-      rtx from = then_first_tail;
+      rtx_base_insn from = then_first_tail;
       if (!INSN_P (from))
 	from = find_active_insn_after (then_bb, from);
       delete_insn_chain (from, BB_END (then_bb), false);
@@ -4060,7 +4060,8 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
 		    basic_block other_bb, edge dest_edge, int reversep)
 {
   basic_block new_dest = dest_edge->dest;
-  rtx head, end, jump, earliest = NULL_RTX, old_dest;
+  rtx_base_insn head, end, jump;
+  rtx earliest = NULL_RTX, old_dest;
   bitmap merge_set = NULL;
   /* Number of pending changes.  */
   int n_validated_changes = 0;
@@ -4090,7 +4091,7 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
     {
       if (head == end)
 	{
-	  head = end = NULL_RTX;
+	  head = end = NULL_RTX_BASE_INSN;
 	  goto no_body;
 	}
       head = NEXT_INSN (head);
@@ -4102,7 +4103,7 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
     {
       if (head == end)
 	{
-	  head = end = NULL_RTX;
+	  head = end = NULL_RTX_BASE_INSN;
 	  goto no_body;
 	}
       end = PREV_INSN (end);
-- 
1.7.11.7

