diff options
author | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-24 13:22:11 +0000 |
---|---|---|
committer | tbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-06-24 13:22:11 +0000 |
commit | d62dd03970a5f6e18a0479428413081d7e1d7b96 (patch) | |
tree | e42565bc6a235c9d4d379f34d53a38e7f997cb45 /gcc/pointer-set.h | |
parent | 2933f7af8a2a577315202dc58abaa5ed4cc808b6 (diff) | |
download | gcc-d62dd03970a5f6e18a0479428413081d7e1d7b96.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211938 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/pointer-set.h')
-rw-r--r-- | gcc/pointer-set.h | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/gcc/pointer-set.h b/gcc/pointer-set.h index a426534ac44..fc592121872 100644 --- a/gcc/pointer-set.h +++ b/gcc/pointer-set.h @@ -45,117 +45,6 @@ void pointer_set_traverse (const struct pointer_set_t *, void *); bool pointer_set_lookup (const pointer_set_t *, const void *, size_t *); -/* A pointer map is represented the same way as a pointer_set, so - the hash code is based on the address of the key, rather than - its contents. Null keys are a reserved value. Deletion is not - supported (yet). There is no mechanism for user control of hash - function, equality comparison, initial size, or resizing policy. */ - -template <typename T> -class pointer_map : protected pointer_set_t -{ - T *values; - -public: - pointer_map (); - ~pointer_map (); - T *contains (const void *p); - T *insert (const void *p, bool *existed_p = NULL); - void traverse (bool (*fn) (const void *, T *, void *), void *data); -}; - -/* Allocate an empty pointer map. */ -template <typename T> -pointer_map<T>::pointer_map (void) -{ - n_elements = 0; - log_slots = 8; - n_slots = (size_t) 1 << log_slots; - - slots = XCNEWVEC (const void *, n_slots); - values = XNEWVEC (T, n_slots); -} - -/* Reclaims all memory associated with PMAP. */ -template <typename T> -pointer_map<T>::~pointer_map (void) -{ - XDELETEVEC (slots); - XDELETEVEC (values); -} - -/* Returns a pointer to the value to which P maps, if PMAP contains P. P - must be nonnull. Return NULL if PMAP does not contain P. - - Collisions are resolved by linear probing. */ -template <typename T> -T * -pointer_map<T>::contains (const void *p) -{ - size_t n; - if (!pointer_set_lookup (this, p, &n)) - return NULL; - return &values[n]; -} - -/* Inserts P into PMAP if it wasn't already there. Returns a pointer - to the value. P must be nonnull. */ -template <typename T> -T * -pointer_map<T>::insert (const void *p, bool *existed_p) -{ - size_t n; - - /* For simplicity, expand the map even if P is already there. This can be - superfluous but can happen at most once. */ - /* ??? Fugly that we have to inline that here. */ - if (n_elements > n_slots / 4) - { - size_t old_n_slots = n_slots; - const void **old_keys = slots; - T *old_values = values; - log_slots = log_slots + 1; - n_slots = n_slots * 2; - slots = XCNEWVEC (const void *, n_slots); - values = XNEWVEC (T, n_slots); - for (size_t i = 0; i < old_n_slots; ++i) - if (old_keys[i]) - { - const void *key = old_keys[i]; - pointer_set_lookup (this, key, &n); - slots[n] = key; - values[n] = old_values[i]; - } - XDELETEVEC (old_keys); - XDELETEVEC (old_values); - } - - if (!pointer_set_lookup (this, p, &n)) - { - ++n_elements; - slots[n] = p; - if (existed_p) - *existed_p = false; - } - else if (existed_p) - *existed_p = true; - - return &values[n]; -} - -/* Pass each pointer in PMAP to the function in FN, together with the pointer - to the value and the fixed parameter DATA. If FN returns false, the - iteration stops. */ - -template <class T> -void -pointer_map<T>::traverse (bool (*fn) (const void *, T *, void *), void *data) -{ - for (size_t i = 0; i < n_slots; ++i) - if (slots[i] && !fn (slots[i], &values[i], data)) - break; -} - struct pointer_map_t; pointer_map_t *pointer_map_create (void); |