+/* Return true if the DECL_UID in both trees are equal. */
+
+int
+uid_decl_map_eq (const void *va, const void *vb)
+{
+ const_tree a = (const_tree) va;
+ const_tree b = (const_tree) vb;
+ return (a->decl_minimal.uid == b->decl_minimal.uid);
+}
+
+/* Hash a tree in a uid_decl_map. */
+
+unsigned int
+uid_decl_map_hash (const void *item)
+{
+ return ((const_tree)item)->decl_minimal.uid;
+}
+
+/* Insert the declaration NODE into the map mapping its unique uid
+ back to the tree. */
+
+static void
+insert_decl_to_uid_decl_map (tree node)
+{
+ void **slot;
+ struct tree_decl_minimal key;
+
+ key.uid = DECL_UID (node);
+ slot = htab_find_slot_with_hash (decl_for_uid_map,
+ &key, DECL_UID (node), INSERT);
+
+ /* We should never try to re-insert a decl with the same uid.
+ ??? The C++ frontend breaks this invariant. Hopefully in a
+ non-fatal way, so just overwrite the slot in this case. */
+#if 0
+ gcc_assert (!*slot);
+#endif
+
+ *(tree *)slot = node;
+}
+
+/* Lookup the declaration tree from its unique DECL_UID UID. Returns
+ the tree node with DECL_UID UID or NULL, if this node was collected. */
+
+tree
+lookup_decl_from_uid (int uid)
+{
+ struct tree_decl_minimal key;
+
+ key.uid = uid;
+ return (tree) htab_find_with_hash (decl_for_uid_map, &key, uid);
+}
+
+/* Remove the declaration tree DECL from the global UID to decl map.
+ This needs to be called if you ggc_free a decl tree, otherwise
+ garbage collection will take care of it. */
+
+void
+remove_decl_from_map (tree decl)
+{
+ struct tree_decl_minimal key;
+
+ key.uid = DECL_UID (decl);
+#if ENABLE_CHECKING
+ gcc_assert (decl == htab_find_with_hash (decl_for_uid_map, &key, key.uid));
+#endif
+ htab_remove_elt_with_hash (decl_for_uid_map, &key, key.uid);
+}
+
+/* Print out the statistics for the decl_for_uid_map hash table. */
+
+static void
+print_decl_for_uid_map_statistics (void)
+{
+ fprintf (stderr, "DECL_FOR_UID_MAP hash: size %ld, %ld elements, %f collisions\n",
+ (long) htab_size (decl_for_uid_map),
+ (long) htab_elements (decl_for_uid_map),
+ htab_collisions (decl_for_uid_map));
+}
+