/* RTL utility routines.
Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of GCC.
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
-#include "real.h"
#include "ggc.h"
#ifdef GENERATOR_FILE
# include "errors.h"
#else
-# include "toplev.h"
+# include "diagnostic-core.h"
#endif
\f
{
rtvec rt;
- rt = ggc_alloc_rtvec (n);
+ rt = ggc_alloc_rtvec_sized (n);
/* Clear out the vector. */
memset (&rt->elem[0], 0, n * sizeof (rtx));
return rt;
}
+/* Create a bitwise copy of VEC. */
+
+rtvec
+shallow_copy_rtvec (rtvec vec)
+{
+ rtvec newvec;
+ int n;
+
+ n = GET_NUM_ELEM (vec);
+ newvec = rtvec_alloc (n);
+ memcpy (&newvec->elem[0], &vec->elem[0], sizeof (rtx) * n);
+ return newvec;
+}
+
/* Return the number of bytes occupied by rtx value X. */
unsigned int
rtx
rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
{
- rtx rt;
-
- rt = (rtx) ggc_alloc_zone_pass_stat (RTX_CODE_SIZE (code), &rtl_zone);
+ rtx rt = ggc_alloc_zone_rtx_def_stat (&rtl_zone, RTX_CODE_SIZE (code)
+ PASS_MEM_STAT);
/* We want to clear everything up to the FLD array. Normally, this
is one int, but we don't want to assume that and it isn't very
shared_const_p (const_rtx orig)
{
gcc_assert (GET_CODE (orig) == CONST);
-
+
/* CONST can be shared if it contains a SYMBOL_REF. If it contains
a LABEL_REF, it isn't sharable. */
return (GET_CODE (XEXP (orig, 0)) == PLUS
switch (code)
{
case REG:
+ case DEBUG_EXPR:
+ case VALUE:
case CONST_INT:
case CONST_DOUBLE:
case CONST_FIXED:
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);
+ rtx const copy = ggc_alloc_zone_rtx_def_stat (&rtl_zone, size PASS_MEM_STAT);
return (rtx) memcpy (copy, orig, size);
}
\f
\f
-/* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL.
+/* 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.
Whenever changing this function check if rtx_equal_p below doesn't need
changing as well. */
if (GET_MODE (x) != GET_MODE (y))
return 0;
+ /* MEMs refering to different address space are not equivalent. */
+ if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
+ return 0;
+
/* Some RTL can be compared nonrecursively. */
switch (code)
{
case SYMBOL_REF:
return XSTR (x, 0) == XSTR (y, 0);
+ case DEBUG_EXPR:
case VALUE:
case SCRATCH:
case CONST_DOUBLE:
case CONST_FIXED:
return 0;
+ case DEBUG_IMPLICIT_PTR:
+ return DEBUG_IMPLICIT_PTR_DECL (x)
+ == DEBUG_IMPLICIT_PTR_DECL (y);
+
default:
break;
}
case 'n':
case 'i':
if (XINT (x, i) != XINT (y, i))
- return 0;
+ {
+#ifndef GENERATOR_FILE
+ if (((code == ASM_OPERANDS && i == 6)
+ || (code == ASM_INPUT && i == 1))
+ && locator_eq (XINT (x, i), XINT (y, i)))
+ break;
+#endif
+ return 0;
+ }
break;
case 'V':
/* And the corresponding elements must match. */
for (j = 0; j < XVECLEN (x, i); j++)
- if (rtx_equal_p_cb (XVECEXP (x, i, j),
+ if (rtx_equal_p_cb (XVECEXP (x, i, j),
XVECEXP (y, i, j), cb) == 0)
return 0;
break;
if (GET_MODE (x) != GET_MODE (y))
return 0;
+ /* MEMs refering to different address space are not equivalent. */
+ if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
+ return 0;
+
/* Some RTL can be compared nonrecursively. */
switch (code)
{
case SYMBOL_REF:
return XSTR (x, 0) == XSTR (y, 0);
+ case DEBUG_EXPR:
case VALUE:
case SCRATCH:
case CONST_DOUBLE:
case CONST_FIXED:
return 0;
+ case DEBUG_IMPLICIT_PTR:
+ return DEBUG_IMPLICIT_PTR_DECL (x)
+ == DEBUG_IMPLICIT_PTR_DECL (y);
+
default:
break;
}
case 'n':
case 'i':
if (XINT (x, i) != XINT (y, i))
- return 0;
+ {
+#ifndef GENERATOR_FILE
+ if (((code == ASM_OPERANDS && i == 6)
+ || (code == ASM_INPUT && i == 1))
+ && locator_eq (XINT (x, i), XINT (y, i)))
+ break;
+#endif
+ return 0;
+ }
break;
case 'V':
return 1;
}
+/* Iteratively hash rtx X. */
+
+hashval_t
+iterative_hash_rtx (const_rtx x, hashval_t hash)
+{
+ enum rtx_code code;
+ enum machine_mode mode;
+ int i, j;
+ const char *fmt;
+
+ if (x == NULL_RTX)
+ return hash;
+ code = GET_CODE (x);
+ hash = iterative_hash_object (code, hash);
+ mode = GET_MODE (x);
+ hash = iterative_hash_object (mode, hash);
+ switch (code)
+ {
+ case REG:
+ i = REGNO (x);
+ return iterative_hash_object (i, hash);
+ case CONST_INT:
+ return iterative_hash_object (INTVAL (x), hash);
+ case SYMBOL_REF:
+ if (XSTR (x, 0))
+ return iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
+ hash);
+ return hash;
+ case LABEL_REF:
+ case DEBUG_EXPR:
+ case VALUE:
+ case SCRATCH:
+ case CONST_DOUBLE:
+ case CONST_FIXED:
+ case DEBUG_IMPLICIT_PTR:
+ return hash;
+ default:
+ break;
+ }
+
+ fmt = GET_RTX_FORMAT (code);
+ for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+ switch (fmt[i])
+ {
+ case 'w':
+ hash = iterative_hash_object (XWINT (x, i), hash);
+ break;
+ case 'n':
+ case 'i':
+ hash = iterative_hash_object (XINT (x, i), hash);
+ break;
+ case 'V':
+ case 'E':
+ j = XVECLEN (x, i);
+ hash = iterative_hash_object (j, hash);
+ for (j = 0; j < XVECLEN (x, i); j++)
+ hash = iterative_hash_rtx (XVECEXP (x, i, j), hash);
+ break;
+ case 'e':
+ hash = iterative_hash_rtx (XEXP (x, i), hash);
+ break;
+ case 'S':
+ case 's':
+ if (XSTR (x, i))
+ hash = iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
+ hash);
+ break;
+ default:
+ break;
+ }
+ return hash;
+}
+
void
dump_rtx_statistics (void)
{
fprintf (stderr, "%-20s %7d %10d\n",
"Total", total_counts, total_sizes);
fprintf (stderr, "---------------------------------------\n");
-#endif
+#endif
}
\f
#if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)