diff options
author | Trevor Saunders <tsaunders@mozilla.com> | 2014-06-24 13:22:11 +0000 |
---|---|---|
committer | Trevor Saunders <tbsaunde@gcc.gnu.org> | 2014-06-24 13:22:11 +0000 |
commit | 1eb68d2d011dd181aca030e98ab02f29375e89da (patch) | |
tree | e42565bc6a235c9d4d379f34d53a38e7f997cb45 /gcc/tree-ssa-uncprop.c | |
parent | 84baa4b968f2dbf4e85e49dba9215ad0f0f3ddc8 (diff) | |
download | gcc-1eb68d2d011dd181aca030e98ab02f29375e89da.zip gcc-1eb68d2d011dd181aca030e98ab02f29375e89da.tar.gz gcc-1eb68d2d011dd181aca030e98ab02f29375e89da.tar.bz2 |
add hash_map class
gcc/
* alloc-pool.c (alloc_pool_hash): Use hash_map instead of hash_table.
* dominance.c (iterate_fix_dominators): Use hash_map instead of
pointer_map.
* hash-map.h: New file.
* ipa-comdats.c: Use hash_map instead of pointer_map.
* ipa.c: Likewise.
* lto-section-out.c: Adjust.
* lto-streamer.h: Replace pointer_map with hash_map.
* symtab.c (verify_symtab): Likewise.
* tree-ssa-strlen.c (decl_to_stridxlist_htab): Likewise.
* tree-ssa-uncprop.c (val_ssa_equiv): Likewise.
* tree-streamer.h: Likewise.
* tree-streamer.c: Adjust.
* pointer-set.h: Remove pointer_map.
gcc/lto/
* lto.c (canonical_type_hash_cache): Use hash_map instead of
pointer_map.
From-SVN: r211938
Diffstat (limited to 'gcc/tree-ssa-uncprop.c')
-rw-r--r-- | gcc/tree-ssa-uncprop.c | 75 |
1 files changed, 19 insertions, 56 deletions
diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c index 81d3085..5c928b4 100644 --- a/gcc/tree-ssa-uncprop.c +++ b/gcc/tree-ssa-uncprop.c @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "function.h" #include "hash-table.h" +#include "hash-map.h" #include "tree-ssa-alias.h" #include "internal-fn.h" #include "gimple-expr.h" @@ -284,44 +285,38 @@ struct equiv_hash_elt /* Value to ssa name equivalence hashtable helpers. */ -struct val_ssa_equiv_hasher +struct val_ssa_equiv_hash_traits : default_hashmap_traits { - typedef equiv_hash_elt value_type; - typedef equiv_hash_elt compare_type; - static inline hashval_t hash (const value_type *); - static inline bool equal (const value_type *, const compare_type *); - static inline void remove (value_type *); + static inline hashval_t hash (tree); + static inline bool equal_keys (tree, tree); + template<typename T> static inline void remove (T &); }; inline hashval_t -val_ssa_equiv_hasher::hash (const value_type *p) +val_ssa_equiv_hash_traits::hash (tree value) { - tree const value = p->value; return iterative_hash_expr (value, 0); } inline bool -val_ssa_equiv_hasher::equal (const value_type *p1, const compare_type *p2) +val_ssa_equiv_hash_traits::equal_keys (tree value1, tree value2) { - tree value1 = p1->value; - tree value2 = p2->value; - return operand_equal_p (value1, value2, 0); } /* Free an instance of equiv_hash_elt. */ +template<typename T> inline void -val_ssa_equiv_hasher::remove (value_type *elt) +val_ssa_equiv_hash_traits::remove (T &elt) { - elt->equivalences.release (); - free (elt); + elt.m_value.release (); } /* Global hash table implementing a mapping from invariant values to a list of SSA_NAMEs which have the same value. We might be able to reuse tree-vn for this code. */ -static hash_table<val_ssa_equiv_hasher> *val_ssa_equiv; +static hash_map<tree, vec<tree>, val_ssa_equiv_hash_traits> *val_ssa_equiv; static void uncprop_into_successor_phis (basic_block); @@ -330,16 +325,7 @@ static void uncprop_into_successor_phis (basic_block); static void remove_equivalence (tree value) { - struct equiv_hash_elt an_equiv_elt, *an_equiv_elt_p; - equiv_hash_elt **slot; - - an_equiv_elt.value = value; - an_equiv_elt.equivalences.create (0); - - slot = val_ssa_equiv->find_slot (&an_equiv_elt, NO_INSERT); - - an_equiv_elt_p = *slot; - an_equiv_elt_p->equivalences.pop (); + val_ssa_equiv->get (value)->pop (); } /* Record EQUIVALENCE = VALUE into our hash table. */ @@ -347,23 +333,7 @@ remove_equivalence (tree value) static void record_equiv (tree value, tree equivalence) { - equiv_hash_elt *an_equiv_elt_p; - equiv_hash_elt **slot; - - an_equiv_elt_p = XNEW (struct equiv_hash_elt); - an_equiv_elt_p->value = value; - an_equiv_elt_p->equivalences.create (0); - - slot = val_ssa_equiv->find_slot (an_equiv_elt_p, INSERT); - - if (*slot == NULL) - *slot = an_equiv_elt_p; - else - free (an_equiv_elt_p); - - an_equiv_elt_p = *slot; - - an_equiv_elt_p->equivalences.safe_push (equivalence); + val_ssa_equiv->get_or_insert (value).safe_push (equivalence); } class uncprop_dom_walker : public dom_walker @@ -433,8 +403,6 @@ uncprop_into_successor_phis (basic_block bb) gimple phi = gsi_stmt (gsi); tree arg = PHI_ARG_DEF (phi, e->dest_idx); tree res = PHI_RESULT (phi); - equiv_hash_elt an_equiv_elt; - equiv_hash_elt **slot; /* If the argument is not an invariant and can be potentially coalesced with the result, then there's no point in @@ -444,23 +412,17 @@ uncprop_into_successor_phis (basic_block bb) continue; /* Lookup this argument's value in the hash table. */ - an_equiv_elt.value = arg; - an_equiv_elt.equivalences.create (0); - slot = val_ssa_equiv->find_slot (&an_equiv_elt, NO_INSERT); - - if (slot) + vec<tree> *equivalences = val_ssa_equiv->get (arg); + if (equivalences) { - struct equiv_hash_elt *elt = *slot; - int j; - /* Walk every equivalence with the same value. If we find one that can potentially coalesce with the PHI rsult, then replace the value in the argument with its equivalent SSA_NAME. Use the most recent equivalence as hopefully that results in shortest lifetimes. */ - for (j = elt->equivalences.length () - 1; j >= 0; j--) + for (int j = equivalences->length () - 1; j >= 0; j--) { - tree equiv = elt->equivalences[j]; + tree equiv = (*equivalences)[j]; if (gimple_can_coalesce_p (equiv, res)) { @@ -578,7 +540,8 @@ pass_uncprop::execute (function *fun) associate_equivalences_with_edges (); /* Create our global data structures. */ - val_ssa_equiv = new hash_table<val_ssa_equiv_hasher> (1024); + val_ssa_equiv + = new hash_map<tree, vec<tree>, val_ssa_equiv_hash_traits> (1024); /* We're going to do a dominator walk, so ensure that we have dominance information. */ |