From 17fdfe309fcf95751b93723eb664d941161fe25a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Sun, 22 Jun 2014 23:31:18 -0400
Subject: [PATCH 124/133] config/sh/sh.c: Use rtx_insn and rtx_code_label

gcc/
	* config/sh/sh.c (struct label_ref_list_d): Strengthen field
	"label" from rtx to rtx_code_label *.
	(pool_node): Likewise.
	(pool_window_label): Likewise for this global.
	(add_constant): Likewise for return type and locals "lab", "new_rtx".
	(dump_table): Replace use of NULL_RTX with NULL when referring to
	a label.
	(broken_move): Strengthen param "insn" from rtx to rtx_insn *.
	(untangle_mova): Likewise for params "first_mova" and "new_mova".
	Strengthen param "first_mova" from rtx * to rtx_insn **.
	(find_barrier): Likewise for return type, params "mova" and
	"from", and locals "barrier_before_mova", "found_barrier",
	"good_barrier", "last_symoff", "next".  Strengthen local "label"
	from rtx to rtx_code_label *.
	(sh_loop_align): Strengthen locals "first", "insn", "mova" from
	rtx to rtx_insn *.
	(sh_reorg): Likewise for locals "link", "scan", "barrier".
	(fpscr_set_from_mem): Likewise for locals "prev", "next".
	(sh_can_redirect_branch): Likewise for local "insn".
	(find_r0_life_regions): Likewise for locals "end", "insn".
---
 gcc/config/sh/sh.c | 55 +++++++++++++++++++++++++++---------------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index a1374e0..bd0f310 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -185,11 +185,11 @@ static bool shmedia_space_reserved_for_target_registers;
 static void split_branches (rtx);
 static int branch_dest (rtx);
 static void print_slot (rtx);
-static rtx add_constant (rtx, enum machine_mode, rtx);
+static rtx_code_label *add_constant (rtx, enum machine_mode, rtx);
 static void dump_table (rtx, rtx);
-static bool broken_move (rtx);
+static bool broken_move (rtx_insn *);
 static bool mova_p (rtx);
-static rtx find_barrier (int, rtx, rtx);
+static rtx_insn *find_barrier (int, rtx_insn *, rtx_insn *);
 static bool noncall_uses_reg (rtx, rtx, rtx *);
 static rtx gen_block_redirect (rtx, int, int);
 static void sh_reorg (void);
@@ -4505,7 +4505,7 @@ static alloc_pool label_ref_list_pool;
 
 typedef struct label_ref_list_d
 {
-  rtx label;
+  rtx_code_label *label;
   struct label_ref_list_d *next;
 } *label_ref_list_t;
 
@@ -4565,7 +4565,7 @@ typedef struct label_ref_list_d
 typedef struct
 {
   rtx value;			/* Value in table.  */
-  rtx label;			/* Label of value.  */
+  rtx_code_label *label;	/* Label of value.  */
   label_ref_list_t wend;	/* End of window.  */
   enum machine_mode mode;	/* Mode of value.  */
 
@@ -4581,7 +4581,7 @@ typedef struct
 #define MAX_POOL_SIZE 372
 static pool_node pool_vector[MAX_POOL_SIZE];
 static int pool_size;
-static rtx pool_window_label;
+static rtx_code_label *pool_window_label;
 static int pool_window_last;
 
 static int max_labelno_before_reorg;
@@ -4597,11 +4597,11 @@ static int max_labelno_before_reorg;
    necessary.  */
 
 /* Add a constant to the pool and return its label.  */
-static rtx
+static rtx_code_label *
 add_constant (rtx x, enum machine_mode mode, rtx last_value)
 {
   int i;
-  rtx lab, new_rtx;
+  rtx_code_label *lab, *new_rtx;
   label_ref_list_t ref, newref;
 
   /* First see if we've already got it.  */
@@ -4853,7 +4853,7 @@ dump_table (rtx start, rtx barrier)
   scan = emit_insn_after (gen_consttable_end (), scan);
   scan = emit_barrier_after (scan);
   pool_size = 0;
-  pool_window_label = NULL_RTX;
+  pool_window_label = NULL;
   pool_window_last = 0;
 }
 
@@ -4865,7 +4865,7 @@ dump_table (rtx start, rtx barrier)
    CONST_DOUBLE input value is CONST_OK_FOR_I08.  For a SFmode move, we don't
    need to fix it if the input value is CONST_OK_FOR_I08.  */
 static bool
-broken_move (rtx insn)
+broken_move (rtx_insn *insn)
 {
   if (NONJUMP_INSN_P (insn))
     {
@@ -4968,7 +4968,7 @@ fixup_mova (rtx mova)
    return 0 if *first_mova was replaced, 1 if new_mova was replaced,
    2 if new_mova has been assigned to *first_mova, -1 otherwise..  */
 static int
-untangle_mova (int *num_mova, rtx *first_mova, rtx new_mova)
+untangle_mova (int *num_mova, rtx_insn **first_mova, rtx_insn *new_mova)
 {
   int n_addr = 0; /* Initialization to shut up spurious warning.  */
   int f_target, n_target = 0; /* Likewise.  */
@@ -5017,8 +5017,8 @@ untangle_mova (int *num_mova, rtx *first_mova, rtx new_mova)
 /* Find the last barrier from insn FROM which is close enough to hold the
    constant pool.  If we can't find one, then create one near the end of
    the range.  */
-static rtx
-find_barrier (int num_mova, rtx mova, rtx from)
+static rtx_insn *
+find_barrier (int num_mova, rtx_insn *mova, rtx_insn *from)
 {
   int count_si = 0;
   int count_hi = 0;
@@ -5028,14 +5028,14 @@ find_barrier (int num_mova, rtx mova, rtx from)
   int hi_align = 2;
   int si_align = 2;
   int leading_mova = num_mova;
-  rtx barrier_before_mova = NULL_RTX;
-  rtx found_barrier = NULL_RTX;
-  rtx good_barrier = NULL_RTX;
+  rtx_insn *barrier_before_mova = NULL;
+  rtx_insn *found_barrier = NULL;
+  rtx_insn *good_barrier = NULL;
   int si_limit;
   int hi_limit;
   rtx orig = from;
   rtx last_got = NULL_RTX;
-  rtx last_symoff = NULL_RTX;
+  rtx_insn *last_symoff = NULL;
 
   /* For HImode: range is 510, add 4 because pc counts from address of
      second instruction after this one, subtract 2 for the jump instruction
@@ -5095,7 +5095,7 @@ find_barrier (int num_mova, rtx mova, rtx from)
 
       if (BARRIER_P (from))
 	{
-	  rtx next;
+	  rtx_insn *next;
 
 	  found_barrier = from;
 
@@ -5290,7 +5290,7 @@ find_barrier (int num_mova, rtx mova, rtx from)
     {
       /* We didn't find a barrier in time to dump our stuff,
 	 so we'll make one.  */
-      rtx label = gen_label_rtx ();
+      rtx_code_label *label = gen_label_rtx ();
 
       /* Don't emit a constant table in the middle of insns for
 	 casesi_worker_2.  This is a bit overkill but is enough
@@ -5338,7 +5338,7 @@ find_barrier (int num_mova, rtx mova, rtx from)
 	 CALL_ARG_LOCATION note.  */
       if (CALL_P (from))
 	{
-	  rtx next = NEXT_INSN (from);
+	  rtx_insn *next = NEXT_INSN (from);
 	  if (next && NOTE_P (next)
 	      && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION)
 	    from = next;
@@ -5979,7 +5979,7 @@ sh_loop_align (rtx label)
 static void
 sh_reorg (void)
 {
-  rtx first, insn, mova = NULL_RTX;
+  rtx_insn *first, *insn, *mova = NULL;
   int num_mova;
   rtx r0_rtx = gen_rtx_REG (Pmode, 0);
   rtx r0_inc_rtx = gen_rtx_POST_INC (Pmode, r0_rtx);
@@ -6025,7 +6025,8 @@ sh_reorg (void)
 
       for (insn = first; insn; insn = NEXT_INSN (insn))
 	{
-	  rtx pattern, reg, link, set, scan, dies, label;
+	  rtx pattern, reg, set, dies, label;
+	  rtx_insn *link, *scan;
 	  int rescan = 0, foundinsn = 0;
 
 	  if (CALL_P (insn))
@@ -6265,10 +6266,10 @@ sh_reorg (void)
 	  || (NONJUMP_INSN_P (insn)
 	      && recog_memoized (insn) == CODE_FOR_casesi_worker_2))
 	{
-	  rtx scan;
+	  rtx_insn *scan;
 	  /* Scan ahead looking for a barrier to stick the constant table
 	     behind.  */
-	  rtx barrier = find_barrier (num_mova, mova, insn);
+	  rtx_insn *barrier = find_barrier (num_mova, mova, insn);
 	  rtx last_float_move = NULL_RTX, last_float = 0, *last_float_addr = NULL;
 	  int need_aligned_label = 0;
 
@@ -10141,7 +10142,7 @@ fpscr_set_from_mem (int mode, HARD_REG_SET regs_live)
 static bool
 sequence_insn_p (rtx insn)
 {
-  rtx prev, next;
+  rtx_insn *prev, *next;
 
   prev = PREV_INSN (insn);
   if (prev == NULL)
@@ -10703,7 +10704,7 @@ sh_can_redirect_branch (rtx branch1, rtx branch2)
   if (flag_expensive_optimizations && simplejump_p (branch2))
     {
       rtx dest = XEXP (SET_SRC (single_set (branch2)), 0);
-      rtx insn;
+      rtx_insn *insn;
       int distance;
 
       for (distance = 0, insn = NEXT_INSN (branch1);
@@ -11135,7 +11136,7 @@ ready_reorder (rtx *ready, int nready)
 static int
 find_r0_life_regions (basic_block b)
 {
-  rtx end, insn;
+  rtx_insn *end, *insn;
   rtx pset;
   rtx r0_reg;
   int live;
-- 
1.8.5.3

