t2r_hash (const void *pentry)
{
tree entry = (tree) pentry;
- return TYPE_HASH (TREE_PURPOSE (entry));
+ return TREE_HASH (TREE_PURPOSE (entry));
}
static void
tree *slot;
slot = (tree *) htab_find_slot_with_hash (type_to_runtime_map, type,
- TYPE_HASH (type), INSERT);
+ TREE_HASH (type), INSERT);
if (*slot == NULL)
{
tree runtime = (*lang_eh_runtime_type) (type);
tree *slot;
slot = (tree *) htab_find_slot_with_hash (type_to_runtime_map, type,
- TYPE_HASH (type), NO_INSERT);
+ TREE_HASH (type), NO_INSERT);
/* We should have always inserted the data earlier. */
return TREE_VALUE (*slot);
ttypes_filter_hash (const void *pentry)
{
const struct ttypes_filter *entry = (const struct ttypes_filter *) pentry;
- return TYPE_HASH (entry->t);
+ return TREE_HASH (entry->t);
}
/* Compare ENTRY with DATA (both struct ttypes_filter) for a @TTypes
tree list;
for (list = entry->t; list ; list = TREE_CHAIN (list))
- h = (h << 5) + (h >> 27) + TYPE_HASH (TREE_VALUE (list));
+ h = (h << 5) + (h >> 27) + TREE_HASH (TREE_VALUE (list));
return h;
}
-/* Add TYPE to cfun->eh->ttype_data, using TYPES_HASH to speed
- up the search. Return the filter value to be used. */
+/* Add TYPE (which may be NULL) to cfun->eh->ttype_data, using TYPES_HASH
+ to speed up the search. Return the filter value to be used. */
static int
add_ttypes_entry (htab_t ttypes_hash, tree type)
struct ttypes_filter **slot, *n;
slot = (struct ttypes_filter **)
- htab_find_slot_with_hash (ttypes_hash, type, TYPE_HASH (type), INSERT);
+ htab_find_slot_with_hash (ttypes_hash, type, TREE_HASH (type), INSERT);
if ((n = *slot) == NULL)
{
static void print_type_hash_statistics (void);
static void finish_vector_type (tree);
static int type_hash_marked_p (const void *);
+static unsigned int type_hash_list (tree, hashval_t);
+static unsigned int attribute_hash_list (tree, hashval_t);
tree global_trees[TI_MAX];
tree integer_types[itk_none];
{
if (! attribute_list_equal (TYPE_ATTRIBUTES (ttype), attribute))
{
- unsigned int hashcode;
+ hashval_t hashcode = 0;
tree ntype;
+ enum tree_code code = TREE_CODE (ttype);
ntype = copy_node (ttype);
TYPE_NEXT_VARIANT (ntype) = 0;
set_type_quals (ntype, TYPE_UNQUALIFIED);
- hashcode = (TYPE_HASH (TREE_CODE (ntype))
- + TYPE_HASH (TREE_TYPE (ntype))
- + attribute_hash_list (attribute));
+ hashcode = iterative_hash_object (code, hashcode);
+ if (TREE_TYPE (ntype))
+ hashcode = iterative_hash_object (TYPE_HASH (TREE_TYPE (ntype)),
+ hashcode);
+ hashcode = attribute_hash_list (attribute, hashcode);
switch (TREE_CODE (ntype))
{
case FUNCTION_TYPE:
- hashcode += TYPE_HASH (TYPE_ARG_TYPES (ntype));
+ hashcode = type_hash_list (TYPE_ARG_TYPES (ntype), hashcode);
break;
case ARRAY_TYPE:
- hashcode += TYPE_HASH (TYPE_DOMAIN (ntype));
+ hashcode = iterative_hash_object (TYPE_HASH (TYPE_DOMAIN (ntype)),
+ hashcode);
break;
case INTEGER_TYPE:
- hashcode += TYPE_HASH (TYPE_MAX_VALUE (ntype));
+ hashcode = iterative_hash_object
+ (TREE_INT_CST_LOW (TYPE_MAX_VALUE (ntype)), hashcode);
+ hashcode = iterative_hash_object
+ (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (ntype)), hashcode);
break;
case REAL_TYPE:
- hashcode += TYPE_HASH (TYPE_PRECISION (ntype));
+ {
+ unsigned int precision = TYPE_PRECISION (ntype);
+ hashcode = iterative_hash_object (precision, hashcode);
+ }
break;
default:
break;
of the individual types. */
unsigned int
-type_hash_list (tree list)
+type_hash_list (tree list, hashval_t hashcode)
{
- unsigned int hashcode;
tree tail;
- for (hashcode = 0, tail = list; tail; tail = TREE_CHAIN (tail))
- hashcode += TYPE_HASH (TREE_VALUE (tail));
+ for (tail = list; tail; tail = TREE_CHAIN (tail))
+ if (TREE_VALUE (tail) != error_mark_node)
+ hashcode = iterative_hash_object (TYPE_HASH (TREE_VALUE (tail)),
+ hashcode);
return hashcode;
}
If one is found, return it. Otherwise return 0. */
tree
-type_hash_lookup (unsigned int hashcode, tree type)
+type_hash_lookup (hashval_t hashcode, tree type)
{
struct type_hash *h, in;
for a type TYPE whose hash code is HASHCODE. */
void
-type_hash_add (unsigned int hashcode, tree type)
+type_hash_add (hashval_t hashcode, tree type)
{
struct type_hash *h;
void **loc;
by adding the hash codes of the individual attributes. */
unsigned int
-attribute_hash_list (tree list)
+attribute_hash_list (tree list, hashval_t hashcode)
{
- unsigned int hashcode;
tree tail;
- for (hashcode = 0, tail = list; tail; tail = TREE_CHAIN (tail))
+ for (tail = list; tail; tail = TREE_CHAIN (tail))
/* ??? Do we want to add in TREE_VALUE too? */
- hashcode += TYPE_HASH (TREE_PURPOSE (tail));
+ hashcode = iterative_hash_object
+ (IDENTIFIER_HASH_VALUE (TREE_PURPOSE (tail)), hashcode);
return hashcode;
}
build_array_type (tree elt_type, tree index_type)
{
tree t;
- unsigned int hashcode;
+ hashval_t hashcode = 0;
if (TREE_CODE (elt_type) == FUNCTION_TYPE)
{
return t;
}
- hashcode = TYPE_HASH (elt_type) + TYPE_HASH (index_type);
+ hashcode = iterative_hash_object (TYPE_HASH (elt_type), hashcode);
+ hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode);
t = type_hash_canon (hashcode, t);
if (!COMPLETE_TYPE_P (t))
build_function_type (tree value_type, tree arg_types)
{
tree t;
- unsigned int hashcode;
+ hashval_t hashcode = 0;
if (TREE_CODE (value_type) == FUNCTION_TYPE)
{
TYPE_ARG_TYPES (t) = arg_types;
/* If we already have such a type, use the old one and free this one. */
- hashcode = TYPE_HASH (value_type) + type_hash_list (arg_types);
+ hashcode = iterative_hash_object (TYPE_HASH (value_type), hashcode);
+ hashcode = type_hash_list (arg_types, hashcode);
t = type_hash_canon (hashcode, t);
if (!COMPLETE_TYPE_P (t))
{
tree t;
tree ptype;
- int hashcode;
+ int hashcode = 0;
/* Make a node of the sort we want. */
t = make_node (METHOD_TYPE);
/* If we already have such a type, use the old one and free this one.
Note that it also frees up the above cons cell if found. */
- hashcode = TYPE_HASH (basetype) + TYPE_HASH (rettype) +
- type_hash_list (argtypes);
+ hashcode = iterative_hash_object (TYPE_HASH (basetype), hashcode);
+ hashcode = iterative_hash_object (TYPE_HASH (rettype), hashcode);
+ hashcode = type_hash_list (argtypes, hashcode);
t = type_hash_canon (hashcode, t);
build_offset_type (tree basetype, tree type)
{
tree t;
- unsigned int hashcode;
+ hashval_t hashcode = 0;
/* Make a node of the sort we want. */
t = make_node (OFFSET_TYPE);
TREE_TYPE (t) = type;
/* If we already have such a type, use the old one and free this one. */
- hashcode = TYPE_HASH (basetype) + TYPE_HASH (type);
+ hashcode = iterative_hash_object (TYPE_HASH (basetype), hashcode);
+ hashcode = iterative_hash_object (TYPE_HASH (type), hashcode);
t = type_hash_canon (hashcode, t);
if (!COMPLETE_TYPE_P (t))
build_complex_type (tree component_type)
{
tree t;
- unsigned int hashcode;
+ hashval_t hashcode;
/* Make a node of the sort we want. */
t = make_node (COMPLEX_TYPE);
set_type_quals (t, TYPE_QUALS (component_type));
/* If we already have such a type, use the old one and free this one. */
- hashcode = TYPE_HASH (component_type);
+ hashcode = iterative_hash_object (TYPE_HASH (component_type), 0);
t = type_hash_canon (hashcode, t);
if (!COMPLETE_TYPE_P (t))
/* Here is how primitive or already-canonicalized types' hash codes
are made. */
-#define TYPE_HASH(TYPE) ((size_t) (TYPE) & 0777777)
+#define TYPE_HASH(TYPE) (TYPE_UID (TYPE))
+
+/* A simple hash function for an arbitrary tree node. This must not be
+ used in hash tables which are saved to a PCH. */
+#define TREE_HASH(NODE) ((size_t) (NODE) & 0777777)
/* Nodes are chained together for many purposes.
Types are chained together to record them for being output to the debugger
extern tree value_member (tree, tree);
extern tree purpose_member (tree, tree);
extern tree binfo_member (tree, tree);
-extern unsigned int attribute_hash_list (tree);
+
extern int attribute_list_equal (tree, tree);
extern int attribute_list_contained (tree, tree);
extern int tree_int_cst_equal (tree, tree);
extern int chain_member (tree, tree);
extern tree type_hash_lookup (unsigned int, tree);
extern void type_hash_add (unsigned int, tree);
-extern unsigned int type_hash_list (tree);
extern int simple_cst_list_equal (tree, tree);
extern void dump_tree_statistics (void);
extern void expand_function_end (void);