aboutsummaryrefslogtreecommitdiff
path: root/gcc/hash-traits.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-06-25 17:16:44 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-06-25 17:16:44 +0000
commite0702244b8e0fa5555e20b5554545bab9d06927f (patch)
treef415bf86a67f1423c4e6ac1b4d5c826ba1116f12 /gcc/hash-traits.h
parent1c9524603bf6207984cc21e7df6520e935a85e35 (diff)
downloadgcc-e0702244b8e0fa5555e20b5554545bab9d06927f.zip
gcc-e0702244b8e0fa5555e20b5554545bab9d06927f.tar.gz
gcc-e0702244b8e0fa5555e20b5554545bab9d06927f.tar.bz2
gengtype-parse.c (require_template_declaration): Allow '+' in template parameters.
gcc/ * gengtype-parse.c (require_template_declaration): Allow '+' in template parameters. Consolidate cases. * hash-traits.h (int_hash): New class. * alias.c (alias_set_hash): New structure. (alias_set_traits): Use it. * symbol-summary.h (function_summary::map_hash): New class. (function_summary::summary_hashmap_traits): Use it. * tree-inline.h (dependence_hash): New class. (dependence_hasher): Use it. * tree-ssa-reassoc.c (oecount_hasher): Use int_hash. * value-prof.c (profile_id_hash): New class. (profile_id_traits): Use it. From-SVN: r224973
Diffstat (limited to 'gcc/hash-traits.h')
-rw-r--r--gcc/hash-traits.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/gcc/hash-traits.h b/gcc/hash-traits.h
index 8f97646..26da1f2 100644
--- a/gcc/hash-traits.h
+++ b/gcc/hash-traits.h
@@ -57,6 +57,68 @@ typed_noop_remove <Type>::remove (Type &)
}
+/* Hasher for integer type Type in which Empty is a spare value that can be
+ used to mark empty slots. If Deleted != Empty then Deleted is another
+ spare value that can be used for deleted slots; if Deleted == Empty then
+ hash table entries cannot be deleted. */
+
+template <typename Type, Type Empty, Type Deleted = Empty>
+struct int_hash : typed_noop_remove <Type>
+{
+ typedef Type value_type;
+ typedef Type compare_type;
+
+ static inline hashval_t hash (value_type);
+ static inline bool equal (value_type existing, value_type candidate);
+ static inline void mark_deleted (Type &);
+ static inline void mark_empty (Type &);
+ static inline bool is_deleted (Type);
+ static inline bool is_empty (Type);
+};
+
+template <typename Type, Type Empty, Type Deleted>
+inline hashval_t
+int_hash <Type, Empty, Deleted>::hash (value_type x)
+{
+ return x;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline bool
+int_hash <Type, Empty, Deleted>::equal (value_type x, value_type y)
+{
+ return x == y;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline void
+int_hash <Type, Empty, Deleted>::mark_deleted (Type &x)
+{
+ gcc_assert (Empty != Deleted);
+ x = Deleted;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline void
+int_hash <Type, Empty, Deleted>::mark_empty (Type &x)
+{
+ x = Empty;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline bool
+int_hash <Type, Empty, Deleted>::is_deleted (Type x)
+{
+ return Empty != Deleted && x == Deleted;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline bool
+int_hash <Type, Empty, Deleted>::is_empty (Type x)
+{
+ return x == Empty;
+}
+
/* Pointer hasher based on pointer equality. Other types of pointer hash
can inherit this and override the hash and equal functions with some
other form of equality (such as string equality). */