aboutsummaryrefslogtreecommitdiff
path: root/gcc/rtl.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-10-12 08:24:07 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2010-10-12 08:24:07 +0200
commitd95828db91607d1060c4301ab5631cb5a75cc787 (patch)
tree4255e8245018661107838a186d047ddb5e1f3550 /gcc/rtl.c
parent8207e1fb1b9452bb5660167b2e17d96b259e9fe2 (diff)
downloadgcc-d95828db91607d1060c4301ab5631cb5a75cc787.zip
gcc-d95828db91607d1060c4301ab5631cb5a75cc787.tar.gz
gcc-d95828db91607d1060c4301ab5631cb5a75cc787.tar.bz2
rtl.h: Include hashtab.h.
* rtl.h: Include hashtab.h. (iterative_hash_rtx): New prototype. * rtl.c (iterative_hash_rtx): New function. * dwarf2out.c (dw_loc_list_node): Add hash and emitted fields. (output_loc_list): Return immediately if emitted is set, set it. (hash_loc_operands, hash_locs, hash_loc_list, compare_loc_operands, compare_locs, loc_list_hash, loc_list_eq, optimize_location_lists_1, optimize_location_lists): New function. (dwarf2out_finish): Call optimize_location_lists. * Makefile.in (RTL_BASE_H): Depend on $(HASHTAB_H). From-SVN: r165351
Diffstat (limited to 'gcc/rtl.c')
-rw-r--r--gcc/rtl.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/rtl.c b/gcc/rtl.c
index 3a6affc..6f34979 100644
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -601,6 +601,79 @@ rtx_equal_p (const_rtx x, const_rtx y)
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)
{