summaryrefslogtreecommitdiff
path: root/gcc/hash-traits.h
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-25 17:16:44 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-25 17:16:44 +0000
commit613732c1f5aaa8941c1e45b762a89aaaf10d36e1 (patch)
treef415bf86a67f1423c4e6ac1b4d5c826ba1116f12 /gcc/hash-traits.h
parent8a6732650cc541a7fca21987667343da4d244e72 (diff)
downloadgcc-613732c1f5aaa8941c1e45b762a89aaaf10d36e1.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224973 138bc75d-0d04-0410-961f-82ee72b054a4
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 8f97646f3e1..26da1f239b8 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). */