From f13434f2bf535dc842de5e64ad4bea4d518fa258 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 20 Jun 2014 12:06:57 -0400
Subject: [PATCH 76/77] FIXME: cfgrtl.c: More rtx_insn conversion

gcc/
	* cfgrtl.c (update_bb_for_insn_chain): Strengthen params "begin",
	"end" from rtx to rtx_insn *.  Remove redundant cast to rtx_insn.
	FIXME: do we need to reformat the loop?
	(try_redirect_by_replacing_jump): Likewise for local "barrier".
	(print_rtl_with_bb): Likewise for local "x".
	(rtl_verify_bb_insn_chain): Likewise for locals "last_head",
	"head", "end".
	(rtl_verify_fallthru): Likewise for local "insn".
	(rtl_verify_bb_layout): Likewise for locals "x" and "rtx_first".
	(purge_dead_edges): Likewise for local "insn".
	(cfg_layout_merge_blocks): Likewise for local "last".
	(rtl_split_block_before_cond_jump): Likewise for locals "insn",
	"split_point", "last".
	(rtl_block_ends_with_call_p): Likewise for local "insn".
	(need_fake_edge_p): Strengthen param "insn" from const_rtx to
	const rtx_insn *.
	(rtl_flow_call_edges_add): Strengthen locals "insn", "prev_insn",
	"split_at_insn" from rtx to rtx_insn *.
	(rtl_lv_add_condition_to_bb): Likewise for locals "seq", "jump".
	(rtl_can_remove_branch_p): Strengthen local "insn" from const_rtx
	to const rtx_insn *.
---
 gcc/cfgrtl.c | 54 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 28668c9..546f023 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -526,12 +526,12 @@ emit_insn_at_entry (rtx insn)
    (i.e. both BEGIN and END will be updated. */
 
 static void
-update_bb_for_insn_chain (rtx begin, rtx end, basic_block bb)
+update_bb_for_insn_chain (rtx_insn *begin, rtx_insn *end, basic_block bb)
 {
   rtx_insn *insn;
 
   end = NEXT_INSN (end);
-  for (insn = begin ? as_a <rtx_insn *> (begin) : NULL;
+  for (insn = begin;
        insn != end;
        insn = NEXT_INSN (insn))
     if (!BARRIER_P (insn))
@@ -1103,7 +1103,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
   else
     {
       rtx target_label = block_label (target);
-      rtx barrier, label;
+      rtx_insn *barrier;
+      rtx label;
       rtx_jump_table_data *table;
 
       emit_jump_insn_after_noloc (gen_jump (target_label), insn);
@@ -2159,7 +2160,7 @@ print_rtl_with_bb (FILE *outf, const_rtx rtx_first, int flags)
 	{
 	  FOR_EACH_BB_REVERSE_FN (bb, cfun)
 	    {
-	      rtx x;
+	      rtx_insn *x;
 
 	      start[INSN_UID (BB_HEAD (bb))] = bb;
 	      end[INSN_UID (BB_END (bb))] = bb;
@@ -2738,7 +2739,7 @@ rtl_verify_bb_insn_chain (void)
   basic_block bb;
   int err = 0;
   rtx x;
-  rtx last_head = get_last_insn ();
+  rtx_insn *last_head = get_last_insn ();
   basic_block *bb_info;
   const int max_uid = get_max_uid ();
 
@@ -2746,8 +2747,8 @@ rtl_verify_bb_insn_chain (void)
 
   FOR_EACH_BB_REVERSE_FN (bb, cfun)
     {
-      rtx head = BB_HEAD (bb);
-      rtx end = BB_END (bb);
+      rtx_insn *head = BB_HEAD (bb);
+      rtx_insn *end = BB_END (bb);
 
       for (x = last_head; x != NULL_RTX; x = PREV_INSN (x))
 	{
@@ -2833,7 +2834,7 @@ rtl_verify_fallthru (void)
       e = find_fallthru_edge (bb->succs);
       if (!e)
 	{
-	  rtx insn;
+	  rtx_insn *insn;
 
 	  /* Ensure existence of barrier in BB with no fallthru edges.  */
 	  for (insn = NEXT_INSN (BB_END (bb)); ; insn = NEXT_INSN (insn))
@@ -2851,7 +2852,7 @@ rtl_verify_fallthru (void)
       else if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun)
 	       && e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
 	{
-	  rtx insn;
+	  rtx_insn *insn;
 
 	  if (e->src->next_bb != e->dest)
 	    {
@@ -2885,9 +2886,9 @@ rtl_verify_bb_layout (void)
 {
   basic_block bb;
   int err = 0;
-  rtx x;
+  rtx_insn *x;
   int num_bb_notes;
-  const rtx rtx_first = get_insns ();
+  rtx_insn * const rtx_first = get_insns ();
   basic_block last_bb_seen = ENTRY_BLOCK_PTR_FOR_FN (cfun), curr_bb = NULL;
 
   num_bb_notes = 0;
@@ -2984,7 +2985,8 @@ bool
 purge_dead_edges (basic_block bb)
 {
   edge e;
-  rtx insn = BB_END (bb), note;
+  rtx_insn *insn = BB_END (bb);
+  rtx note;
   bool purged = false;
   bool found;
   edge_iterator ei;
@@ -4584,7 +4586,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
 	SET_BB_FOOTER (a) = SET_BB_FOOTER (b);
       else
 	{
-	  rtx last = BB_FOOTER (a);
+	  rtx_insn *last = BB_FOOTER (a);
 
 	  while (NEXT_INSN (last))
 	    last = NEXT_INSN (last);
@@ -4603,7 +4605,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
 	SET_BB_FOOTER (a) = BB_HEADER (b);
       else
 	{
-	  rtx last = BB_HEADER (b);
+	  rtx_insn *last = BB_HEADER (b);
  
 	  while (NEXT_INSN (last))
 	    last = NEXT_INSN (last);
@@ -4702,9 +4704,9 @@ rtl_block_empty_p (basic_block bb)
 static basic_block
 rtl_split_block_before_cond_jump (basic_block bb)
 {
-  rtx insn;
-  rtx split_point = NULL;
-  rtx last = NULL;
+  rtx_insn *insn;
+  rtx_insn *split_point = NULL;
+  rtx_insn *last = NULL;
   bool found_code = false;
 
   FOR_BB_INSNS (bb, insn)
@@ -4729,7 +4731,7 @@ rtl_split_block_before_cond_jump (basic_block bb)
 static bool
 rtl_block_ends_with_call_p (basic_block bb)
 {
-  rtx insn = BB_END (bb);
+  rtx_insn *insn = BB_END (bb);
 
   while (!CALL_P (insn)
 	 && insn != BB_HEAD (bb)
@@ -4752,7 +4754,7 @@ rtl_block_ends_with_condjump_p (const_basic_block bb)
    Helper function for rtl_flow_call_edges_add.  */
 
 static bool
-need_fake_edge_p (const_rtx insn)
+need_fake_edge_p (const rtx_insn *insn)
 {
   if (!INSN_P (insn))
     return false;
@@ -4811,7 +4813,7 @@ rtl_flow_call_edges_add (sbitmap blocks)
   if (check_last_block)
     {
       basic_block bb = EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb;
-      rtx insn = BB_END (bb);
+      rtx_insn *insn = BB_END (bb);
 
       /* Back up past insns that must be kept in the same block as a call.  */
       while (insn != BB_HEAD (bb)
@@ -4838,8 +4840,8 @@ rtl_flow_call_edges_add (sbitmap blocks)
   for (i = NUM_FIXED_BLOCKS; i < last_bb; i++)
     {
       basic_block bb = BASIC_BLOCK_FOR_FN (cfun, i);
-      rtx insn;
-      rtx prev_insn;
+      rtx_insn *insn;
+      rtx_insn *prev_insn;
 
       if (!bb)
 	continue;
@@ -4853,7 +4855,7 @@ rtl_flow_call_edges_add (sbitmap blocks)
 	  if (need_fake_edge_p (insn))
 	    {
 	      edge e;
-	      rtx split_at_insn = insn;
+	      rtx_insn *split_at_insn = insn;
 
 	      /* Don't split the block between a call and an insn that should
 		 remain in the same block as the call.  */
@@ -4908,7 +4910,8 @@ rtl_lv_add_condition_to_bb (basic_block first_head ,
 			    basic_block second_head ATTRIBUTE_UNUSED,
 			    basic_block cond_bb, void *comp_rtx)
 {
-  rtx label, seq, jump;
+  rtx label;
+  rtx_insn *seq, *jump;
   rtx op0 = XEXP ((rtx)comp_rtx, 0);
   rtx op1 = XEXP ((rtx)comp_rtx, 1);
   enum rtx_code comp = GET_CODE ((rtx)comp_rtx);
@@ -4973,7 +4976,8 @@ rtl_can_remove_branch_p (const_edge e)
 {
   const_basic_block src = e->src;
   const_basic_block target = EDGE_SUCC (src, EDGE_SUCC (src, 0) == e)->dest;
-  const_rtx insn = BB_END (src), set;
+  const rtx_insn *insn = BB_END (src);
+  rtx set;
 
   /* The conditions are taken from try_redirect_by_replacing_jump.  */
   if (target == EXIT_BLOCK_PTR_FOR_FN (cfun))
-- 
1.8.5.3

