[39/50] rtlanal.c:record_hard_reg_uses
diff mbox

Message ID 87a97l7in1.fsf@googlemail.com
State New
Headers show

Commit Message

Richard Sandiford Aug. 3, 2014, 2:27 p.m. UTC
find_all_hard_regs seems like a useful function so I split it out of
the note_uses callback and exposed it in rtl.h.  I have (or had)
other patches that make use of it.


gcc/
	* rtl.h (find_all_hard_regs): Declare.
	* rtlanal.c (find_all_hard_regs): New function.
	(record_hard_reg_uses_1): Delete.
	(record_hard_reg_uses): Use find_all_hard_regs.

Comments

Jeff Law Aug. 5, 2014, 9:19 p.m. UTC | #1
On 08/03/14 08:27, Richard Sandiford wrote:
> find_all_hard_regs seems like a useful function so I split it out of
> the note_uses callback and exposed it in rtl.h.  I have (or had)
> other patches that make use of it.
>
>
> gcc/
> 	* rtl.h (find_all_hard_regs): Declare.
> 	* rtlanal.c (find_all_hard_regs): New function.
> 	(record_hard_reg_uses_1): Delete.
> 	(record_hard_reg_uses): Use find_all_hard_regs.
OK.
Jeff

Patch
diff mbox

Index: gcc/rtl.h
===================================================================
--- gcc/rtl.h	2014-08-03 11:25:30.745160142 +0100
+++ gcc/rtl.h	2014-08-03 11:25:31.042163078 +0100
@@ -2245,6 +2245,7 @@  extern const_rtx set_of (const_rtx, cons
 extern void record_hard_reg_sets (rtx, const_rtx, void *);
 extern void record_hard_reg_uses (rtx *, void *);
 #ifdef HARD_CONST
+extern void find_all_hard_regs (const_rtx, HARD_REG_SET *);
 extern void find_all_hard_reg_sets (const_rtx, HARD_REG_SET *, bool);
 #endif
 extern void note_stores (const_rtx, void (*) (rtx, const_rtx, void *), void *);
Index: gcc/rtlanal.c
===================================================================
--- gcc/rtlanal.c	2014-08-03 11:25:30.746160151 +0100
+++ gcc/rtlanal.c	2014-08-03 11:25:31.043163088 +0100
@@ -1122,6 +1122,19 @@  set_of (const_rtx pat, const_rtx insn)
   return data.found;
 }
 
+/* Add all hard register in X to *PSET.  */
+void
+find_all_hard_regs (const_rtx x, HARD_REG_SET *pset)
+{
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, x, NONCONST)
+    {
+      const_rtx x = *iter;
+      if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER)
+	add_to_hard_reg_set (pset, GET_MODE (x), REGNO (x));
+    }
+}
+
 /* This function, called through note_stores, collects sets and
    clobbers of hard registers in a HARD_REG_SET, which is pointed to
    by DATA.  */
@@ -1155,27 +1168,11 @@  find_all_hard_reg_sets (const_rtx insn,
       record_hard_reg_sets (XEXP (link, 0), NULL, pset);
 }
 
-/* A for_each_rtx subroutine of record_hard_reg_uses.  */
-static int
-record_hard_reg_uses_1 (rtx *px, void *data)
-{
-  rtx x = *px;
-  HARD_REG_SET *pused = (HARD_REG_SET *)data;
-
-  if (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER)
-    {
-      int nregs = hard_regno_nregs[REGNO (x)][GET_MODE (x)];
-      while (nregs-- > 0)
-	SET_HARD_REG_BIT (*pused, REGNO (x) + nregs);
-    }
-  return 0;
-}
-
 /* Like record_hard_reg_sets, but called through note_uses.  */
 void
 record_hard_reg_uses (rtx *px, void *data)
 {
-  for_each_rtx (px, record_hard_reg_uses_1, data);
+  find_all_hard_regs (*px, (HARD_REG_SET *) data);
 }
 
 /* Given an INSN, return a SET expression if this insn has only a single SET.