]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Jun 2015 17:05:39 +0000 (17:05 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Jun 2015 17:05:39 +0000 (17:05 +0000)
* hash-table.h: Include hash-traits.h.
(typed_free_remove, typed_noop_remove, pointer_hash, ggc_hasher)
(ggc_cache_hasher): Move to...
* hash-traits.h: ...this new file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224953 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/hash-table.h
gcc/hash-traits.h [new file with mode: 0644]

index 202c3a71949ef557275a9ab815ab2d4830634ec8..2045dc778c8e229c0c4d0ea7949745cb70ac31c2 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-25  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * hash-table.h: Include hash-traits.h.
+       (typed_free_remove, typed_noop_remove, pointer_hash, ggc_hasher)
+       (ggc_cache_hasher): Move to...
+       * hash-traits.h: ...this new file.
+
 2015-06-25  Andrew MacLeod  <amacleod@redhat.com>
 
        * tree-core.h (struct tree_optimization_option): Make opts a pointer to
index 1b9322d2c54124a051ed2fbd7fcec3a851c61550..71c0f63ec9a5dfd6fc7294538197adf9b3b56022 100644 (file)
@@ -81,7 +81,7 @@ along with GCC; see the file COPYING3.  If not see
    We compose this into a few steps.
 
       1. Decide on a removal policy for values stored in the table.
-         This header provides class templates for the two most common
+         hash-traits.h provides class templates for the two most common
          policies.
 
          * typed_free_remove implements the static 'remove' member function
@@ -202,6 +202,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "hashtab.h"
 #include "inchash.h"
 #include "mem-stats-traits.h"
+#include "hash-traits.h"
 #include "hash-map-traits.h"
 
 template<typename, typename, typename> class hash_map;
@@ -238,143 +239,6 @@ xcallocator <Type>::data_free (Type *memory)
 }
 
 
-/* Helpful type for removing with free.  */
-
-template <typename Type>
-struct typed_free_remove
-{
-  static inline void remove (Type *p);
-};
-
-
-/* Remove with free.  */
-
-template <typename Type>
-inline void
-typed_free_remove <Type>::remove (Type *p)
-{
-  free (p);
-}
-
-
-/* Helpful type for a no-op remove.  */
-
-template <typename Type>
-struct typed_noop_remove
-{
-  static inline void remove (Type *p);
-};
-
-
-/* Remove doing nothing.  */
-
-template <typename Type>
-inline void
-typed_noop_remove <Type>::remove (Type *p ATTRIBUTE_UNUSED)
-{
-}
-
-
-/* Pointer hash with a no-op remove method.  */
-
-template <typename Type>
-struct pointer_hash : typed_noop_remove <Type>
-{
-  typedef Type *value_type;
-  typedef Type *compare_type;
-
-  static inline hashval_t hash (const value_type &);
-
-  static inline bool equal (const value_type &existing,
-                           const compare_type &candidate);
-};
-
-template <typename Type>
-inline hashval_t
-pointer_hash <Type>::hash (const value_type &candidate)
-{
-  /* This is a really poor hash function, but it is what the current code uses,
-     so I am reusing it to avoid an additional axis in testing.  */
-  return (hashval_t) ((intptr_t)candidate >> 3);
-}
-
-template <typename Type>
-inline bool
-pointer_hash <Type>::equal (const value_type &existing,
-                          const compare_type &candidate)
-{
-  return existing == candidate;
-}
-
-/* Hasher for entry in gc memory.  */
-
-template<typename T>
-struct ggc_hasher
-{
-  typedef T value_type;
-  typedef T compare_type;
-
-  static void remove (T) {}
-
-  static void
-  ggc_mx (T p)
-  {
-    extern void gt_ggc_mx (T &);
-    gt_ggc_mx (p);
-  }
-
-  static void
-  pch_nx (T &p)
-  {
-  extern void gt_pch_nx (T &);
-  gt_pch_nx (p);
-  }
-
-  static void
-  pch_nx (T &p, gt_pointer_operator op, void *cookie)
-  {
-    op (&p, cookie);
-  }
-};
-
-/* Hasher for cache entry in gc memory.  */
-
-template<typename T>
-struct ggc_cache_hasher
-{
-  typedef T value_type;
-  typedef T compare_type;
-
-  static void remove (T &) {}
-
-  /* Entries are weakly held because this is for caches.  */
-
-  static void ggc_mx (T &) {}
-
-  static void
-  pch_nx (T &p)
-  {
-  extern void gt_pch_nx (T &);
-  gt_pch_nx (p);
-  }
-
-  static void
-  pch_nx (T &p, gt_pointer_operator op, void *cookie)
-  {
-    op (&p, cookie);
-  }
-
-  /* Clear out entries if they are about to be gc'd.  */
-
-  static void
-  handle_cache_entry (T &e)
-  {
-    if (e != HTAB_EMPTY_ENTRY && e != HTAB_DELETED_ENTRY && !ggc_marked_p (e))
-      e = static_cast<T> (HTAB_DELETED_ENTRY);
-  }
-};
-
-
 /* Table of primes and their inversion information.  */
 
 struct prime_ent
diff --git a/gcc/hash-traits.h b/gcc/hash-traits.h
new file mode 100644 (file)
index 0000000..1bac581
--- /dev/null
@@ -0,0 +1,159 @@
+/* Traits for hashable types.
+   Copyright (C) 2014-2015 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef hash_traits_h
+#define hash_traits_h
+
+/* Helpful type for removing with free.  */
+
+template <typename Type>
+struct typed_free_remove
+{
+  static inline void remove (Type *p);
+};
+
+
+/* Remove with free.  */
+
+template <typename Type>
+inline void
+typed_free_remove <Type>::remove (Type *p)
+{
+  free (p);
+}
+
+
+/* Helpful type for a no-op remove.  */
+
+template <typename Type>
+struct typed_noop_remove
+{
+  static inline void remove (Type *p);
+};
+
+
+/* Remove doing nothing.  */
+
+template <typename Type>
+inline void
+typed_noop_remove <Type>::remove (Type *p ATTRIBUTE_UNUSED)
+{
+}
+
+
+/* Pointer hash with a no-op remove method.  */
+
+template <typename Type>
+struct pointer_hash : typed_noop_remove <Type>
+{
+  typedef Type *value_type;
+  typedef Type *compare_type;
+
+  static inline hashval_t hash (const value_type &);
+
+  static inline bool equal (const value_type &existing,
+                           const compare_type &candidate);
+};
+
+template <typename Type>
+inline hashval_t
+pointer_hash <Type>::hash (const value_type &candidate)
+{
+  /* This is a really poor hash function, but it is what the current code uses,
+     so I am reusing it to avoid an additional axis in testing.  */
+  return (hashval_t) ((intptr_t)candidate >> 3);
+}
+
+template <typename Type>
+inline bool
+pointer_hash <Type>::equal (const value_type &existing,
+                          const compare_type &candidate)
+{
+  return existing == candidate;
+}
+
+/* Hasher for entry in gc memory.  */
+
+template<typename T>
+struct ggc_hasher
+{
+  typedef T value_type;
+  typedef T compare_type;
+
+  static void remove (T) {}
+
+  static void
+  ggc_mx (T p)
+  {
+    extern void gt_ggc_mx (T &);
+    gt_ggc_mx (p);
+  }
+
+  static void
+  pch_nx (T &p)
+  {
+    extern void gt_pch_nx (T &);
+    gt_pch_nx (p);
+  }
+
+  static void
+  pch_nx (T &p, gt_pointer_operator op, void *cookie)
+  {
+    op (&p, cookie);
+  }
+};
+
+/* Hasher for cache entry in gc memory.  */
+
+template<typename T>
+struct ggc_cache_hasher
+{
+  typedef T value_type;
+  typedef T compare_type;
+
+  static void remove (T &) {}
+
+  /* Entries are weakly held because this is for caches.  */
+
+  static void ggc_mx (T &) {}
+
+  static void
+  pch_nx (T &p)
+  {
+    extern void gt_pch_nx (T &);
+    gt_pch_nx (p);
+  }
+
+  static void
+  pch_nx (T &p, gt_pointer_operator op, void *cookie)
+  {
+    op (&p, cookie);
+  }
+
+  /* Clear out entries if they are about to be gc'd.  */
+
+  static void
+  handle_cache_entry (T &e)
+  {
+    if (e != HTAB_EMPTY_ENTRY && e != HTAB_DELETED_ENTRY && !ggc_marked_p (e))
+      e = static_cast<T> (HTAB_DELETED_ENTRY);
+  }
+};
+
+#endif