public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: [03/12] Move decl hasher to header file
Date: Tue, 23 Jun 2015 14:47:00 -0000	[thread overview]
Message-ID: <87wpyua3fp.fsf@e105548-lin.cambridge.arm.com> (raw)
In-Reply-To: <87egl2bicm.fsf@e105548-lin.cambridge.arm.com> (Richard	Sandiford's message of "Tue, 23 Jun 2015 15:38:17 +0100")

Like the previous patch, but for decl hashers.  There's only one copy
of this so far, but the idea seems general.


gcc/
	* tree-hash-traits.h (tree_decl_hash): New class.
	* tree-ssa-strlen.c: Include tree-hash-traits.h.
	(stridxlist_hash_traits): Use tree_decl_hash.

Index: gcc/tree-hash-traits.h
===================================================================
--- gcc/tree-hash-traits.h	2015-06-23 15:45:22.993947116 +0100
+++ gcc/tree-hash-traits.h	2015-06-23 15:45:22.989947161 +0100
@@ -39,4 +39,18 @@ tree_operand_hash::equal_keys (const_tre
   return operand_equal_p (t1, t2, 0);
 }
 
+/* Hasher for tree decls.  Pointer equality is enough here, but the DECL_UID
+   is a better hash than the pointer value and gives a predictable traversal
+   order.  */
+struct tree_decl_hash : ggc_ptr_hash <tree_node>
+{
+  static inline hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_decl_hash::hash (tree t)
+{
+  return DECL_UID (t);
+}
+
 #endif
Index: gcc/tree-ssa-strlen.c
===================================================================
--- gcc/tree-ssa-strlen.c	2015-06-23 15:45:22.993947116 +0100
+++ gcc/tree-ssa-strlen.c	2015-06-23 15:45:22.989947161 +0100
@@ -73,6 +73,7 @@ the Free Software Foundation; either ver
 #include "ipa-ref.h"
 #include "cgraph.h"
 #include "ipa-chkp.h"
+#include "tree-hash-traits.h"
 
 /* A vector indexed by SSA_NAME_VERSION.  0 means unknown, positive value
    is an index into strinfo vector, negative value stands for
@@ -155,20 +156,7 @@ struct decl_stridxlist_map
   struct stridxlist list;
 };
 
-/* stridxlist hashtable helpers.  */
-
-struct stridxlist_hash_traits : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-};
-
-/* Hash a from tree in a decl_stridxlist_map.  */
-
-inline hashval_t
-stridxlist_hash_traits::hash (tree item)
-{
-  return DECL_UID (item);
-}
+typedef simple_hashmap_traits <tree_decl_hash> stridxlist_hash_traits;
 
 /* Hash table for mapping decls to a chained list of offset -> idx
    mappings.  */

  parent reply	other threads:[~2015-06-23 14:45 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
2015-06-23 14:44 ` [01/12] Add hash_map traits that use existing hash_table-like traits Richard Sandiford
2015-06-25 16:34   ` Jeff Law
2015-06-23 14:45 ` [02/12] Move tree operand hashers to a new header file Richard Sandiford
2015-06-25 16:34   ` Jeff Law
2015-06-23 14:47 ` Richard Sandiford [this message]
2015-06-25 16:34   ` [03/12] Move decl hasher to " Jeff Law
2015-06-23 14:48 ` [04/12] Move ssa_name " Richard Sandiford
2015-06-25 16:35   ` Jeff Law
2015-06-23 14:49 ` [05/12] Move TREE_HASH " Richard Sandiford
2015-06-25 16:36   ` Jeff Law
2015-06-23 14:50 ` [06/12] Consolidate string hashers Richard Sandiford
2015-06-24 10:13   ` Mikhail Maltsev
2015-06-24 11:39     ` Richard Sandiford
2015-06-25 16:37   ` Jeff Law
2015-06-23 14:52 ` [07/12] Use new string hasher for MIPS Richard Sandiford
2015-06-25 16:39   ` Jeff Law
2015-06-23 14:53 ` [08/12] Add common traits for integer hash keys Richard Sandiford
2015-06-25 16:40   ` Jeff Law
2015-06-23 14:55 ` [09/12] Remove all but one use of default_hashmap_traits Richard Sandiford
2015-06-25 16:41   ` Jeff Law
2015-06-23 14:56 ` [10/12] Add helper class for valued-based empty and deleted slots Richard Sandiford
2015-06-25 16:41   ` Jeff Law
2015-06-23 14:57 ` [11/12] Remove default_hashmap_traits Richard Sandiford
2015-06-25 16:42   ` Jeff Law
2015-06-23 14:58 ` [12/12] Simplify uses of hash_map Richard Sandiford
2015-06-25 16:57   ` Jeff Law
2015-06-26 13:50     ` Rainer Orth
2015-06-26 14:38       ` Richard Sandiford
2015-06-26 14:39         ` Jan-Benedict Glaw
2015-06-26 15:34         ` Rainer Orth
2015-06-26 16:17           ` Richard Sandiford
2015-06-26 16:45             ` Richard Sandiford
2015-06-26 17:03               ` Richard Sandiford
2015-06-26 16:09       ` Mikhail Maltsev
2015-06-26 14:36   ` [BUILDROBOT] could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’ (was: [12/12] Simplify uses of hash_map) Jan-Benedict Glaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wpyua3fp.fsf@e105548-lin.cambridge.arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).