PATCH: regno_first_use_in

Stan Cox scox@cygnus.com
Wed Mar 1 10:04:00 GMT 2000


This proposed patch adds regno_first_use_in as a complement to
regno_use_in.  It searches X for the first reference to REGNO.  This
can be used when building a def/use chain to find the use of REGNO in
a SET_DEST if it also happens to appear in a SET_SRC.

2000-03-01  Stan Cox  <scox@cygnus.com>

	* rtl.h (regno_first_use_in): New function. 
	* rtlanal.c (regno_first_use_in): Define.

/equinox/one/devo/gcc ~/gcc/ia64/testsuite /equinox/two/bld-devo/ia64-elf/gcc /equinox/two/bld-devo/x86-elf /equinox/two/home
Index: rtlanal.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/rtlanal.c,v
retrieving revision 1.77
diff -c -2 -p -r1.77 rtlanal.c
*** rtlanal.c	2000/02/07 05:23:59	1.77
--- rtlanal.c	2000/03/01 17:59:14
*************** regno_use_in (regno, x)
*** 2176,2179 ****
--- 2176,2210 ----
  }
  
+ /* Searches X for the first reference to REGNO, returning the rtx of the
+    reference found if any.  Otherwise, returns NULL_RTX.  */
+ 
+ rtx
+ regno_first_use_in (regno, x)
+      int regno;
+      rtx x;
+ {
+   register const char *fmt;
+   int i, j;
+   rtx tem;
+ 
+   if (GET_CODE (x) == REG && REGNO (x) == regno)
+     return x;
+ 
+   fmt = GET_RTX_FORMAT (GET_CODE (x));
+   for (i = 0; i <= GET_RTX_LENGTH (GET_CODE (x)) - 1; i++)
+     {
+       if (fmt[i] == 'e')
+ 	{
+ 	  if ((tem = regno_use_in (regno, XEXP (x, i))))
+ 	    return tem;
+ 	}
+       else if (fmt[i] == 'E')
+ 	for (j = XVECLEN (x, i) - 1; j >= 0; j--)
+ 	  if ((tem = regno_use_in (regno , XVECEXP (x, i, j))))
+ 	    return tem;
+     }
+ 
+   return NULL_RTX;
+ }
  
  /* Return 1 if X is an autoincrement side effect and the register is
Index: rtl.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/rtl.h,v
retrieving revision 1.151
diff -c -2 -p -r1.151 rtl.h
*** rtl.h	2000/01/27 21:07:48	1.151
--- rtl.h	2000/03/01 17:59:26
*************** typedef int (*rtx_function)             
*** 1151,1154 ****
--- 1151,1155 ----
  extern int for_each_rtx                 PROTO((rtx *, rtx_function, void *));
  extern rtx regno_use_in			PROTO((int, rtx));
+ extern rtx regno_first_use_in		PROTO((int, rtx));
  extern int auto_inc_p			PROTO((rtx));
  extern void remove_node_from_expr_list	PROTO((rtx, rtx *));



More information about the Gcc-patches mailing list