diff mbox

[05/12] Move TREE_HASH hasher to header file

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

Commit Message

Richard Sandiford June 23, 2015, 2:47 p.m. UTC
One more tree hasher, this time based on TREE_HASH.


gcc/
	* tree-hash-traits.h (tree_hash): New class.
	* except.c: Include tree-hash-traits.h.
	(tree_hash_traits): Use tree_hash.

Comments

Jeff Law June 25, 2015, 4:35 p.m. UTC | #1
On 06/23/2015 08:47 AM, Richard Sandiford wrote:
> One more tree hasher, this time based on TREE_HASH.
>
>
> gcc/
> 	* tree-hash-traits.h (tree_hash): New class.
> 	* except.c: Include tree-hash-traits.h.
> 	(tree_hash_traits): Use tree_hash.
OK.
jeff
diff mbox

Patch

Index: gcc/tree-hash-traits.h
===================================================================
--- gcc/tree-hash-traits.h	2015-06-23 15:47:41.132358999 +0100
+++ gcc/tree-hash-traits.h	2015-06-23 15:47:41.128359041 +0100
@@ -67,4 +67,16 @@  tree_ssa_name_hash::hash (tree t)
   return SSA_NAME_VERSION (t);
 }
 
+/* Hasher for general trees, based on their TREE_HASH.  */
+struct tree_hash : ggc_ptr_hash <tree_node>
+{
+  static hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_hash::hash (tree t)
+{
+  return TREE_HASH (t);
+}
+
 #endif
Index: gcc/except.c
===================================================================
--- gcc/except.c	2015-06-23 15:47:41.132358999 +0100
+++ gcc/except.c	2015-06-23 15:47:41.128359041 +0100
@@ -161,14 +161,11 @@  Software Foundation; either version 3, o
 #include "tree-pass.h"
 #include "cfgloop.h"
 #include "builtins.h"
+#include "tree-hash-traits.h"
 
 static GTY(()) int call_site_base;
 
-struct tree_hash_traits : default_hashmap_traits
-{
-  static hashval_t hash (tree t) { return TREE_HASH (t); }
-};
-
+struct tree_hash_traits : simple_hashmap_traits <tree_hash> {};
 static GTY (()) hash_map<tree, tree, tree_hash_traits> *type_to_runtime_map;
 
 /* Describe the SjLj_Function_Context structure.  */