From a2c0bcbf5ec27db6a4256d18d771fa7c49a148d3 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 1 Aug 2014 13:58:46 -0400
Subject: [PATCH 232/236] Use rtx_insn in various places in resource.[ch]

After fixing reorg.c's update_block and reorg_redirect_jump, all
in-tree users of the given resource.h functions now are rtx_insn *, so we
can update the API itself.

gcc/
	* resource.h (clear_hashed_info_for_insn): Strengthen param from
	rtx to rtx_insn *.
	(incr_ticks_for_insn): Likewise.
	(init_resource_info): Likewise.

	* resource.c (init_resource_info): Likewise.
	(clear_hashed_info_for_insn): Likewise.
	(incr_ticks_for_insn): Likewise.

	* reorg.c (delete_scheduled_jump): Strengthen param "insn" from
	rtx to rtx_insn *.
	(steal_delay_list_from_target): Use methods of "seq".
	(try_merge_delay_insns): Use methods of "merged_insns".
	(update_block): Strengthen param "insn" from rtx to rtx_insn *.
	(reorg_redirect_jump): Likewise for param "jump".
---
 gcc/reorg.c    | 22 +++++++++++-----------
 gcc/resource.c |  6 +++---
 gcc/resource.h |  6 +++---
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/gcc/reorg.c b/gcc/reorg.c
index 4681e02..68779e4 100644
--- a/gcc/reorg.c
+++ b/gcc/reorg.c
@@ -210,7 +210,7 @@ static rtx_code_label *find_end_label (rtx);
 static rtx_insn *emit_delay_sequence (rtx_insn *, rtx_insn_list *, int);
 static rtx_insn_list *add_to_delay_list (rtx_insn *, rtx_insn_list *);
 static rtx_insn *delete_from_delay_slot (rtx_insn *);
-static void delete_scheduled_jump (rtx);
+static void delete_scheduled_jump (rtx_insn *);
 static void note_delay_statistics (int, int);
 #if defined(ANNUL_IFFALSE_SLOTS) || defined(ANNUL_IFTRUE_SLOTS)
 static rtx_insn_list *optimize_skip (rtx_insn *);
@@ -240,8 +240,8 @@ static rtx_insn_list *steal_delay_list_from_fallthrough (rtx_insn *, rtx,
 static void try_merge_delay_insns (rtx, rtx_insn *);
 static rtx redundant_insn (rtx, rtx_insn *, rtx);
 static int own_thread_p (rtx_insn *, rtx, int);
-static void update_block (rtx, rtx);
-static int reorg_redirect_jump (rtx, rtx);
+static void update_block (rtx_insn *, rtx);
+static int reorg_redirect_jump (rtx_insn *, rtx);
 static void update_reg_dead_notes (rtx, rtx);
 static void fix_reg_dead_note (rtx, rtx);
 static void update_reg_unused_notes (rtx, rtx);
@@ -666,7 +666,7 @@ delete_from_delay_slot (rtx_insn *insn)
    the insn that sets CC0 for it and delete it too.  */
 
 static void
-delete_scheduled_jump (rtx insn)
+delete_scheduled_jump (rtx_insn *insn)
 {
   /* Delete the insn that sets cc0 for us.  On machines without cc0, we could
      delete the insn that sets the condition code, but it is hard to find it.
@@ -1197,9 +1197,9 @@ steal_delay_list_from_target (rtx_insn *insn, rtx condition, rtx_sequence *seq,
 
   /* Record the effect of the instructions that were redundant and which
      we therefore decided not to copy.  */
-  for (i = 1; i < XVECLEN (seq, 0); i++)
+  for (i = 1; i < seq->len (); i++)
     if (redundant[i])
-      update_block (XVECEXP (seq, 0, i), insn);
+      update_block (seq->insn (i), insn);
 
   /* Show the place to which we will be branching.  */
   *pnew_thread = first_active_target_insn (JUMP_LABEL_AS_INSN (seq->insn (0)));
@@ -1460,15 +1460,15 @@ try_merge_delay_insns (rtx insn, rtx_insn *thread)
 	    {
 	      rtx_insn *new_rtx;
 
-	      update_block (XEXP (merged_insns, 0), thread);
+	      update_block (merged_insns->insn (), thread);
 	      new_rtx = delete_from_delay_slot (merged_insns->insn ());
 	      if (INSN_DELETED_P (thread))
 		thread = new_rtx;
 	    }
 	  else
 	    {
-	      update_block (XEXP (merged_insns, 0), thread);
-	      delete_related_insns (XEXP (merged_insns, 0));
+	      update_block (merged_insns->insn (), thread);
+	      delete_related_insns (merged_insns->insn ());
 	    }
 	}
 
@@ -1759,7 +1759,7 @@ own_thread_p (rtx_insn *thread, rtx label, int allow_fallthrough)
    BARRIER in relax_delay_slots.  */
 
 static void
-update_block (rtx insn, rtx where)
+update_block (rtx_insn *insn, rtx where)
 {
   /* Ignore if this was in a delay slot and it came from the target of
      a branch.  */
@@ -1778,7 +1778,7 @@ update_block (rtx insn, rtx where)
    the basic block containing the jump.  */
 
 static int
-reorg_redirect_jump (rtx jump, rtx nlabel)
+reorg_redirect_jump (rtx_insn *jump, rtx nlabel)
 {
   incr_ticks_for_insn (jump);
   return redirect_jump (jump, nlabel, 1);
diff --git a/gcc/resource.c b/gcc/resource.c
index eb5374e..607baa0 100644
--- a/gcc/resource.c
+++ b/gcc/resource.c
@@ -1155,7 +1155,7 @@ mark_target_live_regs (rtx_insn *insns, rtx_insn *target, struct resources *res)
    This should be invoked before the first call to mark_target_live_regs.  */
 
 void
-init_resource_info (rtx epilogue_insn)
+init_resource_info (rtx_insn *epilogue_insn)
 {
   int i;
   basic_block bb;
@@ -1275,7 +1275,7 @@ free_resource_info (void)
 /* Clear any hashed information that we have stored for INSN.  */
 
 void
-clear_hashed_info_for_insn (rtx insn)
+clear_hashed_info_for_insn (rtx_insn *insn)
 {
   struct target_info *tinfo;
 
@@ -1294,7 +1294,7 @@ clear_hashed_info_for_insn (rtx insn)
 /* Increment the tick count for the basic block that contains INSN.  */
 
 void
-incr_ticks_for_insn (rtx insn)
+incr_ticks_for_insn (rtx_insn *insn)
 {
   int b = find_basic_block (insn, MAX_DELAY_SLOT_LIVE_SEARCH);
 
diff --git a/gcc/resource.h b/gcc/resource.h
index 633d1ab..5bc30fd 100644
--- a/gcc/resource.h
+++ b/gcc/resource.h
@@ -48,10 +48,10 @@ extern void mark_target_live_regs (rtx_insn *, rtx_insn *, struct resources *);
 extern void mark_set_resources (rtx, struct resources *, int,
 				enum mark_resource_type);
 extern void mark_referenced_resources (rtx, struct resources *, bool);
-extern void clear_hashed_info_for_insn (rtx);
-extern void incr_ticks_for_insn (rtx);
+extern void clear_hashed_info_for_insn (rtx_insn *);
+extern void incr_ticks_for_insn (rtx_insn *);
 extern void mark_end_of_function_resources (rtx, bool);
-extern void init_resource_info (rtx);
+extern void init_resource_info (rtx_insn *);
 extern void free_resource_info (void);
 
 #endif /* GCC_RESOURCE_H */
-- 
1.8.5.3

