diff options
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 27161cd1860..8ffb0947648 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" +#include "hash-table.h" #include "tm.h" #include "tree.h" #include "basic-block.h" @@ -943,10 +944,23 @@ typedef struct oecount_s { /* The heap for the oecount hashtable and the sorted list of operands. */ static vec<oecount> cvec; + +/* Oecount hashtable helpers. */ + +struct oecount_hasher : typed_noop_remove <void> +{ + /* Note that this hash table stores integers, not pointers. + So, observe the casting in the member functions. */ + typedef void value_type; + typedef void compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); +}; + /* Hash function for oecount. */ -static hashval_t -oecount_hash (const void *p) +inline hashval_t +oecount_hasher::hash (const value_type *p) { const oecount *c = &cvec[(size_t)p - 42]; return htab_hash_pointer (c->op) ^ (hashval_t)c->oecode; @@ -954,8 +968,8 @@ oecount_hash (const void *p) /* Comparison function for oecount. */ -static int -oecount_eq (const void *p1, const void *p2) +inline bool +oecount_hasher::equal (const value_type *p1, const compare_type *p2) { const oecount *c1 = &cvec[(size_t)p1 - 42]; const oecount *c2 = &cvec[(size_t)p2 - 42]; @@ -1257,7 +1271,7 @@ undistribute_ops_list (enum tree_code opcode, unsigned nr_candidates, nr_candidates2; sbitmap_iterator sbi0; vec<operand_entry_t> *subops; - htab_t ctable; + hash_table <oecount_hasher> ctable; bool changed = false; int next_oecount_id = 0; @@ -1305,7 +1319,7 @@ undistribute_ops_list (enum tree_code opcode, /* Build linearized sub-operand lists and the counting table. */ cvec.create (0); - ctable = htab_create (15, oecount_hash, oecount_eq, NULL); + ctable.create (15); /* ??? Macro arguments cannot have multi-argument template types in them. This typedef is needed to workaround that limitation. */ typedef vec<operand_entry_t> vec_operand_entry_t_heap; @@ -1332,7 +1346,7 @@ undistribute_ops_list (enum tree_code opcode, c.op = oe1->op; cvec.safe_push (c); idx = cvec.length () + 41; - slot = htab_find_slot (ctable, (void *)idx, INSERT); + slot = ctable.find_slot ((void *)idx, INSERT); if (!*slot) { *slot = (void *)idx; @@ -1344,7 +1358,7 @@ undistribute_ops_list (enum tree_code opcode, } } } - htab_delete (ctable); + ctable.dispose (); /* Sort the counting table. */ cvec.qsort (oecount_cmp); |