[PR67828] don't unswitch on default defs of non-parms
[official-gcc.git] / gcc / tree-hash-traits.h
blob1edc49eda46748648d263a2cfefce8c5f3aa567b
1 /* Traits for hashing trees.
2 Copyright (C) 2014-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef tree_hash_traits_h
21 #define tree_hash_traits_h
23 /* Hash for trees based on operand_equal_p. */
24 struct tree_operand_hash : ggc_ptr_hash <tree_node>
26 static inline hashval_t hash (const_tree);
27 static inline bool equal_keys (const_tree, const_tree);
30 inline hashval_t
31 tree_operand_hash::hash (const_tree t)
33 return iterative_hash_expr (t, 0);
36 inline bool
37 tree_operand_hash::equal_keys (const_tree t1, const_tree t2)
39 return operand_equal_p (t1, t2, 0);
42 /* Hasher for tree decls. Pointer equality is enough here, but the DECL_UID
43 is a better hash than the pointer value and gives a predictable traversal
44 order. */
45 struct tree_decl_hash : ggc_ptr_hash <tree_node>
47 static inline hashval_t hash (tree);
50 inline hashval_t
51 tree_decl_hash::hash (tree t)
53 return DECL_UID (t);
56 /* Hash for SSA_NAMEs in the same function. Pointer equality is enough
57 here, but the SSA_NAME_VERSION is a better hash than the pointer
58 value and gives a predictable traversal order. */
59 struct tree_ssa_name_hash : ggc_ptr_hash <tree_node>
61 static inline hashval_t hash (tree);
64 inline hashval_t
65 tree_ssa_name_hash::hash (tree t)
67 return SSA_NAME_VERSION (t);
70 /* Hasher for general trees, based on their TREE_HASH. */
71 struct tree_hash : ggc_ptr_hash <tree_node>
73 static hashval_t hash (tree);
76 inline hashval_t
77 tree_hash::hash (tree t)
79 return TREE_HASH (t);
82 #endif