]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Jun 2015 17:16:44 +0000 (17:16 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Jun 2015 17:16:44 +0000 (17:16 +0000)
* 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

gcc/ChangeLog
gcc/alias.c
gcc/gengtype-parse.c
gcc/hash-traits.h
gcc/symbol-summary.h
gcc/tree-inline.h
gcc/tree-ssa-reassoc.c
gcc/value-prof.c

index 3a639edcd4f4150d2f3d74f246fd6d2db055afa5..fed4758760f24785bb18871f6e18b6ce8624a620 100644 (file)
@@ -1,3 +1,18 @@
+2015-06-25  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * 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.
+
 2015-06-25  Richard Sandiford  <richard.sandiford@arm.com>
 
        * config/mips/mips.c (mips16_flip_traits): Use it.
index f79cc4236a9df50798f0b09b46717afffb86201a..32eb3cf77adcbac4f496d22dd98a0f6fef12a82e 100644 (file)
@@ -141,31 +141,8 @@ along with GCC; see the file COPYING3.  If not see
    However, this is no actual entry for alias set zero.  It is an
    error to attempt to explicitly construct a subset of zero.  */
 
-struct alias_set_traits : default_hashmap_traits
-{
-  template<typename T>
-  static bool
-  is_empty (T &e)
-  {
-    return e.m_key == INT_MIN;
-  }
-
-  template<typename  T>
-  static bool
-  is_deleted (T &e)
-  {
-    return e.m_key == (INT_MIN + 1);
-  }
-
-  template<typename T> static void mark_empty (T &e) { e.m_key = INT_MIN; }
-
-  template<typename T>
-  static void
-  mark_deleted (T &e)
-  {
-    e.m_key = INT_MIN + 1;
-  }
-};
+struct alias_set_hash : int_hash <int, INT_MIN, INT_MIN + 1> {};
+struct alias_set_traits : simple_hashmap_traits <alias_set_hash> {};
 
 struct GTY(()) alias_set_entry_d {
   /* The alias set number, as stored in MEM_ALIAS_SET.  */
index 5663a268ec69a5d459cde705f75f95c60e9185a0..13b2b5c715ba942a47926fae5fc9529e5e706ac4 100644 (file)
@@ -274,17 +274,13 @@ require_template_declaration (const char *tmpl_name)
          str = concat (str, "enum ", (char *) 0);
          continue;
        }
-      if (token () == NUM)
+      if (token () == NUM
+         || token () == ':'
+         || token () == '+')
        {
          str = concat (str, advance (), (char *) 0);
          continue;
        }
-      if (token () == ':')
-       {
-         advance ();
-         str = concat (str, ":", (char *) 0);
-         continue;
-       }
       if (token () == '<')
        {
          advance ();
index 8f97646f3e1eab5e6c273ff2ecd07b5c81d0c442..26da1f239b8c943830081f630a9d15d38566c05c 100644 (file)
@@ -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).  */
index 04483103a94036a65bb35c7764a7f54bd212dee9..facb5961eb60e60531fae0d39659a2304049b807 100644 (file)
@@ -200,45 +200,8 @@ protected:
   bool m_ggc;
 
 private:
-  struct summary_hashmap_traits: default_hashmap_traits
-  {
-    static const int deleted_value = -1;
-    static const int empty_value = 0;
-
-    static hashval_t
-    hash (const int v)
-    {
-      return (hashval_t)v;
-    }
-
-    template<typename Type>
-    static bool
-    is_deleted (Type &e)
-    {
-      return e.m_key == deleted_value;
-    }
-
-    template<typename Type>
-    static bool
-    is_empty (Type &e)
-    {
-      return e.m_key == empty_value;
-    }
-
-    template<typename Type>
-    static void
-    mark_deleted (Type &e)
-    {
-      e.m_key = deleted_value;
-    }
-
-    template<typename Type>
-    static void
-    mark_empty (Type &e)
-    {
-      e.m_key = empty_value;
-    }
-  };
+  typedef int_hash <int, 0, -1> map_hash;
+  typedef simple_hashmap_traits <map_hash> summary_hashmap_traits;
 
   /* Getter for summary callgraph ID.  */
   T* get (int uid)
index 0bfd20c7776dbc88c6833a6964b5b1b92018c885..3a47d978e123c596977269209c5fb8b1e5a63aa5 100644 (file)
@@ -35,25 +35,8 @@ enum copy_body_cge_which
   CB_CGE_MOVE_CLONES
 };
 
-struct dependence_hasher : default_hashmap_traits
-{
-  template<typename T>
-  static void
-  mark_deleted (T &e)
-    { gcc_unreachable (); }
-
-  template<typename T>
-  static void
-  mark_empty (T &e)
-    { e.m_key = 0; }
-
-  template<typename T>
-  static bool
-  is_deleted (T &)
-    { return false; }
-
-  template<typename T> static bool is_empty (T &e) { return e.m_key == 0; }
-};
+typedef int_hash <unsigned short, 0> dependence_hash;
+typedef simple_hashmap_traits <dependence_hash> dependence_hasher;
 
 /* Data required for function body duplication.  */
 
index 3eb098eca5a167e43d61c917a8465ed4205e113c..f243df5103483d3ea7bc6088ba287875497b5a98 100644 (file)
@@ -1017,23 +1017,16 @@ static vec<oecount> cvec;
 
 /* Oecount hashtable helpers.  */
 
-struct oecount_hasher
+struct oecount_hasher : int_hash <int, 0, 1>
 {
-  typedef int value_type;
-  typedef int compare_type;
-  static inline hashval_t hash (const value_type &);
-  static inline bool equal (const value_type &, const compare_type &);
-  static bool is_deleted (int &v) { return v == 1; }
-  static void mark_deleted (int &e) { e = 1; }
-  static bool is_empty (int &v) { return v == 0; }
-  static void mark_empty (int &e) { e = 0; }
-  static void remove (int &) {}
+  static inline hashval_t hash (int);
+  static inline bool equal (int, int);
 };
 
 /* Hash function for oecount.  */
 
 inline hashval_t
-oecount_hasher::hash (const value_type &p)
+oecount_hasher::hash (int p)
 {
   const oecount *c = &cvec[p - 42];
   return htab_hash_pointer (c->op) ^ (hashval_t)c->oecode;
@@ -1042,7 +1035,7 @@ oecount_hasher::hash (const value_type &p)
 /* Comparison function for oecount.  */
 
 inline bool
-oecount_hasher::equal (const value_type &p1, const compare_type &p2)
+oecount_hasher::equal (int p1, int p2)
 {
   const oecount *c1 = &cvec[p1 - 42];
   const oecount *c2 = &cvec[p2 - 42];
index 74f53754052b12678d38ef4f31ba4f01c19424e1..a84b8dae7a3c6a1bc38eec8ba46af8c5f765eb00 100644 (file)
@@ -1248,19 +1248,8 @@ gimple_mod_subtract_transform (gimple_stmt_iterator *si)
   return true;
 }
 
-struct profile_id_traits : default_hashmap_traits
-{
-  template<typename T>
-  static bool
-  is_deleted (T &e)
-    {
-      return e.m_key == UINT_MAX;
-    }
-
-  template<typename T> static bool is_empty (T &e) { return e.m_key == 0; }
-  template<typename T> static void mark_deleted (T &e) { e.m_key = UINT_MAX; }
-  template<typename T> static void mark_empty (T &e) { e.m_key = 0; }
-};
+typedef int_hash <unsigned int, 0, UINT_MAX> profile_id_hash;
+typedef simple_hashmap_traits <profile_id_hash> profile_id_traits;
 
 static hash_map<unsigned int, cgraph_node *, profile_id_traits> *
 cgraph_node_map = 0;