From 664b3959759cfb5c0eedd188e8bdfb2bd69af8dc Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 11 Jul 2014 12:07:46 -0400
Subject: [PATCH 215/236] Use rtx_expr_list in various places

gcc/
	* rtl.h (free_EXPR_LIST_list): Strengthen param from rtx * to
	rtx_expr_list **.
	(alloc_EXPR_LIST): Strengthen return type from rtx to
	rtx_expr_list *.
	(remove_free_EXPR_LIST_node): Likewise for param.
	* reload.h (struct reg_equivs_t): Strengthen field "alt_mem_list"
	from rtx to rtx_expr_list *.
	* sched-int.h (struct deps_desc): Strengthen fields
	"pending_read_mems" and "pending_write_mems" from rtx to
	rtx_expr_list *.

	* dwarf2out.c (decl_piece_varloc_ptr): Strengthen return type from
	rtx to rtx_expr_list *.
	* lists.c (alloc_INSN_LIST): Likewise, also for local "r".
	(free_EXPR_LIST_list): Strengthen param "listp" from rtx * to
	rtx_expr_list **.
	(remove_free_EXPR_LIST_node): Likewise.  Strengthen local "node"
	from rtx to rtx_expr_list *.
	* loop-iv.c (simplify_using_initial_values): Strengthen local
	"cond_list" from rtx to rtx_expr_list *, and locals "pnode",
	"pnote_next" from rtx * to rtx_expr_list **.
	* sched-deps.c (remove_from_both_dependence_lists):  Strengthen
	param "exprp" from rtx * to rtx_expr_list **.
	(add_insn_mem_dependence): Strengthen local "mem_list" from
	rtx * to rtx_expr_list **.  Strengthen local "mem_node" from rtx
	to rtx_expr_list *.
	* sched-rgn.c (concat_insn_mem_list): Strengthen param "copy_mems"
	and local "new_mems" from rtx to rtx_expr_list *.  Strengthen
	param "old_mems_p" from rtx * to rtx_expr_list **.
	* var-tracking.c (struct adjust_mem_data): Strengthen field
	"side_effects" from rtx to rtx_expr_list *.
	(adjust_insn): Replace NULL_RTX with NULL when assigning to
	rtx_expr_list *.
	(prepare_call_arguments): Likewise.
---
 gcc/dwarf2out.c    |  2 +-
 gcc/lists.c        | 16 ++++++++--------
 gcc/loop-iv.c      | 13 +++++++------
 gcc/reload.h       |  2 +-
 gcc/rtl.h          |  6 +++---
 gcc/sched-deps.c   |  8 ++++----
 gcc/sched-int.h    |  4 ++--
 gcc/sched-rgn.c    | 15 ++++++++-------
 gcc/var-tracking.c |  6 +++---
 9 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 92f5c83..618b646 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5019,7 +5019,7 @@ decl_piece_varloc_ptr (rtx piece)
 /* Create an EXPR_LIST for location note LOC_NOTE covering BITSIZE bits.
    Next is the chain of following piece nodes.  */
 
-static rtx
+static rtx_expr_list *
 decl_piece_node (rtx loc_note, HOST_WIDE_INT bitsize, rtx next)
 {
   if (bitsize <= (int) MAX_MACHINE_MODE)
diff --git a/gcc/lists.c b/gcc/lists.c
index 5e07880..78556be 100644
--- a/gcc/lists.c
+++ b/gcc/lists.c
@@ -125,14 +125,14 @@ alloc_INSN_LIST (rtx val, rtx next)
 /* This call is used in place of a gen_rtx_EXPR_LIST. If there is a cached
    node available, we'll use it, otherwise a call to gen_rtx_EXPR_LIST
    is made.  */
-rtx
+rtx_expr_list *
 alloc_EXPR_LIST (int kind, rtx val, rtx next)
 {
-  rtx r;
+  rtx_expr_list *r;
 
   if (unused_expr_list)
     {
-      r = unused_expr_list;
+      r = as_a <rtx_expr_list *> (unused_expr_list);
       unused_expr_list = XEXP (r, 1);
       XEXP (r, 0) = val;
       XEXP (r, 1) = next;
@@ -146,11 +146,11 @@ alloc_EXPR_LIST (int kind, rtx val, rtx next)
 
 /* This function will free up an entire list of EXPR_LIST nodes.  */
 void
-free_EXPR_LIST_list (rtx *listp)
+free_EXPR_LIST_list (rtx_expr_list **listp)
 {
   if (*listp == 0)
     return;
-  free_list (listp, &unused_expr_list);
+  free_list ((rtx *)listp, &unused_expr_list);
 }
 
 /* This function will free up an entire list of INSN_LIST nodes.  */
@@ -233,12 +233,12 @@ remove_free_INSN_LIST_node (rtx_insn_list **listp)
 
 /* Remove and free the first node in the EXPR_LIST pointed to by LISTP.  */
 rtx
-remove_free_EXPR_LIST_node (rtx *listp)
+remove_free_EXPR_LIST_node (rtx_expr_list **listp)
 {
-  rtx node = *listp;
+  rtx_expr_list *node = *listp;
   rtx elem = XEXP (node, 0);
 
-  remove_list_node (listp);
+  remove_list_node ((rtx *)listp);
   free_EXPR_LIST_node (node);
 
   return elem;
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index 74e38e1..30dafd8 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -1872,7 +1872,8 @@ static void
 simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 {
   bool expression_valid;
-  rtx head, tail, cond_list, last_valid_expr;
+  rtx head, tail, last_valid_expr;
+  rtx_expr_list *cond_list;
   rtx_insn *insn;
   rtx neutral, aggr;
   regset altered, this_altered;
@@ -1950,7 +1951,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 
   expression_valid = true;
   last_valid_expr = *expr;
-  cond_list = NULL_RTX;
+  cond_list = NULL;
   while (1)
     {
       insn = BB_END (e->src);
@@ -2002,7 +2003,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 
 	  if (suitable_set_for_replacement (insn, &dest, &src))
 	    {
-	      rtx *pnote, *pnote_next;
+	      rtx_expr_list **pnote, **pnote_next;
 
 	      replace_in_expr (expr, dest, src);
 	      if (CONSTANT_P (*expr))
@@ -2013,7 +2014,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 		  rtx note = *pnote;
 		  rtx old_cond = XEXP (note, 0);
 
-		  pnote_next = &XEXP (note, 1);
+		  pnote_next = (rtx_expr_list **)&XEXP (note, 1);
 		  replace_in_expr (&XEXP (note, 0), dest, src);
 
 		  /* We can no longer use a condition that has been simplified
@@ -2033,7 +2034,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 	    }
 	  else
 	    {
-	      rtx *pnote, *pnote_next;
+	      rtx_expr_list **pnote, **pnote_next;
 
 	      /* If we did not use this insn to make a replacement, any overlap
 		 between stores in this insn and our expression will cause the
@@ -2047,7 +2048,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
 		  rtx note = *pnote;
 		  rtx old_cond = XEXP (note, 0);
 
-		  pnote_next = &XEXP (note, 1);
+		  pnote_next = (rtx_expr_list **)&XEXP (note, 1);
 		  if (for_each_rtx (&old_cond, altered_reg_used, this_altered))
 		    {
 		      *pnote = *pnote_next;
diff --git a/gcc/reload.h b/gcc/reload.h
index ea9081f..80ceae2 100644
--- a/gcc/reload.h
+++ b/gcc/reload.h
@@ -233,7 +233,7 @@ struct reg_equivs_t
 
   /* An EXPR_LIST of REG_EQUIVs containing MEMs with
      alternate representations of the location of pseudo reg N.  */
-  rtx alt_mem_list;
+  rtx_expr_list *alt_mem_list;
 
   /* The list of insns that initialized reg N from its equivalent
      constant or memory slot.  */
diff --git a/gcc/rtl.h b/gcc/rtl.h
index afdc466..1f1caaf 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2838,18 +2838,18 @@ extern void subreg_get_info (unsigned int, enum machine_mode,
 
 /* lists.c */
 
-extern void free_EXPR_LIST_list (rtx *);
+extern void free_EXPR_LIST_list (rtx_expr_list **);
 extern void free_INSN_LIST_list (rtx_insn_list **);
 extern void free_EXPR_LIST_node (rtx);
 extern void free_INSN_LIST_node (rtx);
 extern rtx_insn_list *alloc_INSN_LIST (rtx, rtx);
 extern rtx_insn_list *copy_INSN_LIST (rtx_insn_list *);
 extern rtx_insn_list *concat_INSN_LIST (rtx_insn_list *, rtx_insn_list *);
-extern rtx alloc_EXPR_LIST (int, rtx, rtx);
+extern rtx_expr_list *alloc_EXPR_LIST (int, rtx, rtx);
 extern void remove_free_INSN_LIST_elem (rtx_insn *, rtx_insn_list **);
 extern rtx remove_list_elem (rtx, rtx *);
 extern rtx_insn *remove_free_INSN_LIST_node (rtx_insn_list **);
-extern rtx remove_free_EXPR_LIST_node (rtx *);
+extern rtx remove_free_EXPR_LIST_node (rtx_expr_list **);
 
 
 /* reginfo.c */
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 7d4f6d3..41b9ca6 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -1622,7 +1622,7 @@ remove_from_dependence_list (rtx insn, rtx_insn_list **listp)
 static int
 remove_from_both_dependence_lists (rtx insn,
 				   rtx_insn_list **listp,
-				   rtx *exprp)
+				   rtx_expr_list **exprp)
 {
   int removed = 0;
 
@@ -1637,7 +1637,7 @@ remove_from_both_dependence_lists (rtx insn,
         }
 
       listp = (rtx_insn_list **)&XEXP (*listp, 1);
-      exprp = &XEXP (*exprp, 1);
+      exprp = (rtx_expr_list **)&XEXP (*exprp, 1);
     }
 
   return removed;
@@ -1719,8 +1719,8 @@ add_insn_mem_dependence (struct deps_desc *deps, bool read_p,
 {
   rtx_insn_list **insn_list;
   rtx_insn_list *insn_node;
-  rtx *mem_list;
-  rtx mem_node;
+  rtx_expr_list **mem_list;
+  rtx_expr_list *mem_node;
 
   gcc_assert (!deps->readonly);
   if (read_p)
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index f8e5e74..a19d776 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -474,13 +474,13 @@ struct deps_desc
   rtx_insn_list *pending_read_insns;
 
   /* An EXPR_LIST containing all MEM rtx's which are pending reads.  */
-  rtx pending_read_mems;
+  rtx_expr_list *pending_read_mems;
 
   /* An INSN_LIST containing all insns with pending write operations.  */
   rtx_insn_list *pending_write_insns;
 
   /* An EXPR_LIST containing all MEM rtx's which are pending writes.  */
-  rtx pending_write_mems;
+  rtx_expr_list *pending_write_mems;
 
   /* An INSN_LIST containing all jump insns.  */
   rtx_insn_list *pending_jump_insns;
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index f843c03..4f4c8d5 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -240,8 +240,8 @@ static void add_branch_dependences (rtx_insn *, rtx_insn *);
 static void compute_block_dependences (int);
 
 static void schedule_region (int);
-static void concat_insn_mem_list (rtx_insn_list *, rtx,
-				  rtx_insn_list **, rtx *);
+static void concat_insn_mem_list (rtx_insn_list *, rtx_expr_list *,
+				  rtx_insn_list **, rtx_expr_list **);
 static void propagate_deps (int, struct deps_desc *);
 static void free_pending_lists (void);
 
@@ -2585,19 +2585,20 @@ add_branch_dependences (rtx_insn *head, rtx_insn *tail)
 static struct deps_desc *bb_deps;
 
 static void
-concat_insn_mem_list (rtx_insn_list *copy_insns, rtx copy_mems,
+concat_insn_mem_list (rtx_insn_list *copy_insns,
+		      rtx_expr_list *copy_mems,
 		      rtx_insn_list **old_insns_p,
-		      rtx *old_mems_p)
+		      rtx_expr_list **old_mems_p)
 {
   rtx_insn_list *new_insns = *old_insns_p;
-  rtx new_mems = *old_mems_p;
+  rtx_expr_list *new_mems = *old_mems_p;
 
   while (copy_insns)
     {
       new_insns = alloc_INSN_LIST (copy_insns->insn (), new_insns);
-      new_mems = alloc_EXPR_LIST (VOIDmode, XEXP (copy_mems, 0), new_mems);
+      new_mems = alloc_EXPR_LIST (VOIDmode, copy_mems->element (), new_mems);
       copy_insns = copy_insns->next ();
-      copy_mems = XEXP (copy_mems, 1);
+      copy_mems = copy_mems->next ();
     }
 
   *old_insns_p = new_insns;
diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 8f04110..764df05 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -948,7 +948,7 @@ struct adjust_mem_data
   bool store;
   enum machine_mode mem_mode;
   HOST_WIDE_INT stack_adjust;
-  rtx side_effects;
+  rtx_expr_list *side_effects;
 };
 
 /* Helper for adjust_mems.  Return 1 if *loc is unsuitable for
@@ -1231,7 +1231,7 @@ adjust_insn (basic_block bb, rtx_insn *insn)
 
   amd.mem_mode = VOIDmode;
   amd.stack_adjust = -VTI (bb)->out.stack_adjust;
-  amd.side_effects = NULL_RTX;
+  amd.side_effects = NULL;
 
   amd.store = true;
   note_stores (PATTERN (insn), adjust_mem_stores, &amd);
@@ -6277,7 +6277,7 @@ prepare_call_arguments (basic_block bb, rtx_insn *insn)
 		struct adjust_mem_data amd;
 		amd.mem_mode = VOIDmode;
 		amd.stack_adjust = -VTI (bb)->out.stack_adjust;
-		amd.side_effects = NULL_RTX;
+		amd.side_effects = NULL;
 		amd.store = true;
 		mem = simplify_replace_fn_rtx (mem, NULL_RTX, adjust_mems,
 					       &amd);
-- 
1.8.5.3

