[PATCH 1/5] struct ira_reg_equiv_s's "init_insns" is an rtx_insn_list

David Malcolm dmalcolm@redhat.com
Mon Sep 8 21:24:00 GMT 2014


gcc/
	* ira.c (ira_update_equiv_info_by_shuffle_insn): Use NULL rather
	than NULL_RTX.
	(no_equiv): Likewise.
	(update_equiv_regs): Likewise.
	(setup_reg_equiv): Likewise.  Strengthen locals "elem",
	"prev_elem", "next_elem" from rtx to rtx_insn_list *, and "insn"
	from rtx to rtx_insn *.  Use methods of "elem" for typesafety and
	clarity.
	* ira.h (struct ira_reg_equiv_s): Strengthen field "init_insns"
	from rtx to rtx_insn_list *.
	* lra-assigns.c (spill_for): Strengthen local "x" from rtx to
	rtx_insn_list * and use methods for clarity and typesafety.
	* lra-constraints.c (contains_deleted_insn_p): Likewise for param
	"list".
	(init_insn_rhs_dead_pseudo_p): Likewise for local "insns".  Remove
	redundant check on INSN_P (insns): this cannot hold, as "insns" is
	an INSN_LIST, not an insn.
	(reverse_equiv_p): Strengthen local "insns" from rtx to
	rtx_insn_list * and use methods for clarity and typesafety.
	(contains_reloaded_insn_p): Likewise for local "list".
---
 gcc/ira.c             | 18 ++++++++++--------
 gcc/ira.h             |  2 +-
 gcc/lra-assigns.c     |  6 +++---
 gcc/lra-constraints.c | 33 ++++++++++++++++-----------------
 4 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/gcc/ira.c b/gcc/ira.c
index a48368c..61f8b90 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -2604,7 +2604,7 @@ ira_update_equiv_info_by_shuffle_insn (int to_regno, int from_regno, rtx_insn *i
       ira_reg_equiv[to_regno].memory
 	= ira_reg_equiv[to_regno].constant
 	= ira_reg_equiv[to_regno].invariant
-	= ira_reg_equiv[to_regno].init_insns = NULL_RTX;
+	= ira_reg_equiv[to_regno].init_insns = NULL;
       if (internal_flag_ira_verbose > 3 && ira_dump_file != NULL)
 	fprintf (ira_dump_file,
 		 "      Invalidating equiv info for reg %d\n", to_regno);
@@ -3258,7 +3258,7 @@ no_equiv (rtx reg, const_rtx store ATTRIBUTE_UNUSED,
   if (reg_equiv[regno].is_arg_equivalence)
     return;
   ira_reg_equiv[regno].defined_p = false;
-  ira_reg_equiv[regno].init_insns = NULL_RTX;
+  ira_reg_equiv[regno].init_insns = NULL;
   for (; list; list =  XEXP (list, 1))
     {
       rtx insn = XEXP (list, 0);
@@ -3731,7 +3731,7 @@ update_equiv_regs (void)
 		      reg_equiv[regno].init_insns
 			= XEXP (reg_equiv[regno].init_insns, 1);
 
-		      ira_reg_equiv[regno].init_insns = NULL_RTX;
+		      ira_reg_equiv[regno].init_insns = NULL;
 		      bitmap_set_bit (cleared_regs, regno);
 		    }
 		  /* Move the initialization of the register to just before
@@ -3819,15 +3819,17 @@ static void
 setup_reg_equiv (void)
 {
   int i;
-  rtx elem, prev_elem, next_elem, insn, set, x;
+  rtx_insn_list *elem, *prev_elem, *next_elem;
+  rtx_insn *insn;
+  rtx set, x;
 
   for (i = FIRST_PSEUDO_REGISTER; i < ira_reg_equiv_len; i++)
     for (prev_elem = NULL, elem = ira_reg_equiv[i].init_insns;
 	 elem;
 	 prev_elem = elem, elem = next_elem)
       {
-	next_elem = XEXP (elem, 1);
-	insn = XEXP (elem, 0);
+	next_elem = elem->next ();
+	insn = elem->insn ();
 	set = single_set (insn);
 	
 	/* Init insns can set up equivalence when the reg is a destination or
@@ -3896,7 +3898,7 @@ setup_reg_equiv (void)
 			if (ira_reg_equiv[i].memory == NULL_RTX)
 			  {
 			    ira_reg_equiv[i].defined_p = false;
-			    ira_reg_equiv[i].init_insns = NULL_RTX;
+			    ira_reg_equiv[i].init_insns = NULL;
 			    break;
 			  }
 		      }
@@ -3906,7 +3908,7 @@ setup_reg_equiv (void)
 	      }
 	  }
 	ira_reg_equiv[i].defined_p = false;
-	ira_reg_equiv[i].init_insns = NULL_RTX;
+	ira_reg_equiv[i].init_insns = NULL;
 	break;
       }
 }
diff --git a/gcc/ira.h b/gcc/ira.h
index 138b763..66030d6 100644
--- a/gcc/ira.h
+++ b/gcc/ira.h
@@ -166,7 +166,7 @@ struct ira_reg_equiv_s
   rtx constant;
   rtx invariant;
   /* Always NULL_RTX if defined_p is false.  */
-  rtx init_insns;
+  rtx_insn_list *init_insns;
 };
 
 /* The length of the following array.  */
diff --git a/gcc/lra-assigns.c b/gcc/lra-assigns.c
index 88e0b1d..c7164cd 100644
--- a/gcc/lra-assigns.c
+++ b/gcc/lra-assigns.c
@@ -951,15 +951,15 @@ spill_for (int regno, bitmap spilled_pseudo_bitmap, bool first_p)
 	    }
 	  EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi)
 	    {
-	      rtx x;
+	      rtx_insn_list *x;
 
 	      cost += lra_reg_info[spill_regno].freq;
 	      if (ira_reg_equiv[spill_regno].memory != NULL
 		  || ira_reg_equiv[spill_regno].constant != NULL)
 		for (x = ira_reg_equiv[spill_regno].init_insns;
 		     x != NULL;
-		     x = XEXP (x, 1))
-		  cost -= REG_FREQ_FROM_BB (BLOCK_FOR_INSN (XEXP (x, 0)));
+		     x = x->next ())
+		  cost -= REG_FREQ_FROM_BB (BLOCK_FOR_INSN (x->insn ()));
 	    }
 	  if (best_insn_pseudos_num > insn_pseudos_num
 	      || (best_insn_pseudos_num == insn_pseudos_num
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index b038527..d5287d1 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -3897,11 +3897,11 @@ multi_block_pseudo_p (int regno)
 
 /* Return true if LIST contains a deleted insn.  */
 static bool
-contains_deleted_insn_p (rtx list)
+contains_deleted_insn_p (rtx_insn_list *list)
 {
-  for (; list != NULL_RTX; list = XEXP (list, 1))
-    if (NOTE_P (XEXP (list, 0))
-	&& NOTE_KIND (XEXP (list, 0)) == NOTE_INSN_DELETED)
+  for (; list != NULL_RTX; list = list->next ())
+    if (NOTE_P (list->insn ())
+	&& NOTE_KIND (list->insn ()) == NOTE_INSN_DELETED)
       return true;
   return false;
 }
@@ -3952,14 +3952,12 @@ insn_rhs_dead_pseudo_p (rtx insn)
 static bool
 init_insn_rhs_dead_pseudo_p (int regno)
 {
-  rtx insns = ira_reg_equiv[regno].init_insns;
+  rtx_insn_list *insns = ira_reg_equiv[regno].init_insns;
 
   if (insns == NULL)
     return false;
-  if (INSN_P (insns))
-    return insn_rhs_dead_pseudo_p (insns);
-  for (; insns != NULL_RTX; insns = XEXP (insns, 1))
-    if (insn_rhs_dead_pseudo_p (XEXP (insns, 0)))
+  for (; insns != NULL_RTX; insns = insns->next ())
+    if (insn_rhs_dead_pseudo_p (insns->insn ()))
       return true;
   return false;
 }
@@ -3970,14 +3968,15 @@ init_insn_rhs_dead_pseudo_p (int regno)
 static bool
 reverse_equiv_p (int regno)
 {
-  rtx insns, set;
+  rtx_insn_list *insns = ira_reg_equiv[regno].init_insns;
+  rtx set;
 
-  if ((insns = ira_reg_equiv[regno].init_insns) == NULL_RTX)
+  if (insns == NULL)
     return false;
-  if (! INSN_P (XEXP (insns, 0))
-      || XEXP (insns, 1) != NULL_RTX)
+  if (! INSN_P (insns->insn ())
+      || insns->next () != NULL)
     return false;
-  if ((set = single_set (XEXP (insns, 0))) == NULL_RTX)
+  if ((set = single_set (insns->insn ())) == NULL_RTX)
     return false;
   return REG_P (SET_SRC (set)) && (int) REGNO (SET_SRC (set)) == regno;
 }
@@ -3988,10 +3987,10 @@ static bool
 contains_reloaded_insn_p (int regno)
 {
   rtx set;
-  rtx list = ira_reg_equiv[regno].init_insns;
+  rtx_insn_list *list = ira_reg_equiv[regno].init_insns;
 
-  for (; list != NULL_RTX; list = XEXP (list, 1))
-    if ((set = single_set (XEXP (list, 0))) == NULL_RTX
+  for (; list != NULL; list = list->next ())
+    if ((set = single_set (list->insn ())) == NULL_RTX
 	|| ! REG_P (SET_DEST (set))
 	|| (int) REGNO (SET_DEST (set)) != regno)
       return true;
-- 
1.8.5.3



More information about the Gcc-patches mailing list