diff mbox

[04/12] Move ssa_name hasher to header file

Message ID 87si9ia3do.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford June 23, 2015, 2:46 p.m. UTC
Another tree hasher, this time for SSA names.  Again there's only one copy
at the moment, but the idea seems general.


gcc/
	* tree-hash-traits.h (tree_ssa_name_hasher): New class.
	* sese.c: Include tree-hash-traits.h.
	(rename_map_hasher): Use tree_ssa_name_hasher.

Comments

Jeff Law June 25, 2015, 4:34 p.m. UTC | #1
On 06/23/2015 08:46 AM, Richard Sandiford wrote:
> Another tree hasher, this time for SSA names.  Again there's only one copy
> at the moment, but the idea seems general.
>
>
> gcc/
> 	* tree-hash-traits.h (tree_ssa_name_hasher): New class.
> 	* sese.c: Include tree-hash-traits.h.
> 	(rename_map_hasher): Use tree_ssa_name_hasher.
OK.
jeff
diff mbox

Patch

Index: gcc/tree-hash-traits.h
===================================================================
--- gcc/tree-hash-traits.h	2015-06-23 15:46:11.453390373 +0100
+++ gcc/tree-hash-traits.h	2015-06-23 15:46:11.449390427 +0100
@@ -53,4 +53,18 @@  tree_decl_hash::hash (tree t)
   return DECL_UID (t);
 }
 
+/* Hash for SSA_NAMEs in the same function.  Pointer equality is enough
+   here, but the SSA_NAME_VERSION is a better hash than the pointer
+   value and gives a predictable traversal order.  */
+struct tree_ssa_name_hash : ggc_ptr_hash <tree_node>
+{
+  static inline hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_ssa_name_hash::hash (tree t)
+{
+  return SSA_NAME_VERSION (t);
+}
+
 #endif
Index: gcc/sese.c
===================================================================
--- gcc/sese.c	2015-06-23 15:46:11.453390373 +0100
+++ gcc/sese.c	2015-06-23 15:46:11.449390427 +0100
@@ -63,6 +63,7 @@  the Free Software Foundation; either ver
 #include "value-prof.h"
 #include "sese.h"
 #include "tree-ssa-propagate.h"
+#include "tree-hash-traits.h"
 
 /* Helper function for debug_rename_map.  */
 
@@ -78,22 +79,7 @@  debug_rename_map_1 (tree_node *const &ol
   return true;
 }
 
-
-/* Hashtable helpers.  */
-
-struct rename_map_hasher : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-};
-
-/* Computes a hash function for database element ELT.  */
-
-inline hashval_t
-rename_map_hasher::hash (tree old_name)
-{
-  return SSA_NAME_VERSION (old_name);
-}
-
+typedef simple_hashmap_traits<tree_ssa_name_hash> rename_map_hasher;
 typedef hash_map<tree, tree, rename_map_hasher> rename_map_type;