OSDN Git Service

2009-05-08 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / rtl.c
index edf393f..c275091 100644 (file)
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -1,6 +1,6 @@
 /* RTL utility routines.
    Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -323,7 +323,7 @@ shallow_copy_rtx_stat (const_rtx orig MEM_STAT_DECL)
 {
   const unsigned int size = rtx_size (orig);
   rtx const copy = (rtx) ggc_alloc_zone_pass_stat (size, &rtl_zone);
-  return memcpy (copy, orig, size);
+  return (rtx) memcpy (copy, orig, size);
 }
 \f
 /* Nonzero when we are generating CONCATs.  */
@@ -333,22 +333,29 @@ int generating_concat_p;
 int currently_expanding_to_rtl;
 
 \f
-/* Return 1 if X and Y are identical-looking rtx's.
-   This is the Lisp function EQUAL for rtx arguments.  */
+
+/* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL.  
+   When the callback returns true, we continue with the new pair.  */
 
 int
-rtx_equal_p (const_rtx x, const_rtx y)
+rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
 {
   int i;
   int j;
   enum rtx_code code;
   const char *fmt;
+  rtx nx, ny;
 
   if (x == y)
     return 1;
   if (x == 0 || y == 0)
     return 0;
 
+  /* Invoke the callback first.  */
+  if (cb != NULL
+      && ((*cb) (&x, &y, &nx, &ny)))
+    return rtx_equal_p_cb (nx, ny, cb);
+
   code = GET_CODE (x);
   /* Rtx's of different codes cannot be equal.  */
   if (code != GET_CODE (y))
@@ -409,12 +416,13 @@ rtx_equal_p (const_rtx x, const_rtx y)
 
          /* And the corresponding elements must match.  */
          for (j = 0; j < XVECLEN (x, i); j++)
-           if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
+           if (rtx_equal_p_cb (XVECEXP (x, i, j), 
+                                XVECEXP (y, i, j), cb) == 0)
              return 0;
          break;
 
        case 'e':
-         if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
+         if (rtx_equal_p_cb (XEXP (x, i), XEXP (y, i), cb) == 0)
            return 0;
          break;
 
@@ -444,6 +452,15 @@ rtx_equal_p (const_rtx x, const_rtx y)
   return 1;
 }
 
+/* Return 1 if X and Y are identical-looking rtx's.
+   This is the Lisp function EQUAL for rtx arguments.  */
+
+int
+rtx_equal_p (const_rtx x, const_rtx y)
+{
+  return rtx_equal_p_cb (x, y, NULL);
+}
+
 void
 dump_rtx_statistics (void)
 {