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/alloc-pool.c | |
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/alloc-pool.c')
-rw-r--r-- | gcc/alloc-pool.c | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c index 49209ee6845..0d318351474 100644 --- a/gcc/alloc-pool.c +++ b/gcc/alloc-pool.c @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "alloc-pool.h" #include "hash-table.h" +#include "hash-map.h" #define align_eight(x) (((x+7) >> 3) << 3) @@ -69,7 +70,6 @@ static ALLOC_POOL_ID_TYPE last_id; size for that pool. */ struct alloc_pool_descriptor { - const char *name; /* Number of pools allocated. */ unsigned long created; /* Gross allocated storage. */ @@ -82,48 +82,17 @@ struct alloc_pool_descriptor int elt_size; }; -/* Hashtable helpers. */ -struct alloc_pool_hasher : typed_noop_remove <alloc_pool_descriptor> -{ - typedef alloc_pool_descriptor value_type; - typedef char compare_type; - static inline hashval_t hash (const alloc_pool_descriptor *); - static inline bool equal (const value_type *, const compare_type *); -}; - -inline hashval_t -alloc_pool_hasher::hash (const value_type *d) -{ - return htab_hash_pointer (d->name); -} - -inline bool -alloc_pool_hasher::equal (const value_type *d, - const compare_type *p2) -{ - return d->name == p2; -} - /* Hashtable mapping alloc_pool names to descriptors. */ -static hash_table<alloc_pool_hasher> *alloc_pool_hash; +static hash_map<const char *, alloc_pool_descriptor> *alloc_pool_hash; /* For given name, return descriptor, create new if needed. */ static struct alloc_pool_descriptor * allocate_pool_descriptor (const char *name) { - struct alloc_pool_descriptor **slot; - if (!alloc_pool_hash) - alloc_pool_hash = new hash_table<alloc_pool_hasher> (10); - - slot = alloc_pool_hash->find_slot_with_hash (name, - htab_hash_pointer (name), - INSERT); - if (*slot) - return *slot; - *slot = XCNEW (struct alloc_pool_descriptor); - (*slot)->name = name; - return *slot; + alloc_pool_hash = new hash_map<const char *, alloc_pool_descriptor> (10); + + return &alloc_pool_hash->get_or_insert (name); } /* Create a pool of things of size SIZE, with NUM in each block we @@ -375,23 +344,22 @@ struct output_info unsigned long total_allocated; }; -/* Called via hash_table.traverse. Output alloc_pool descriptor pointed out by +/* Called via hash_map.traverse. Output alloc_pool descriptor pointed out by SLOT and update statistics. */ -int -print_alloc_pool_statistics (alloc_pool_descriptor **slot, +bool +print_alloc_pool_statistics (const char *const &name, + const alloc_pool_descriptor &d, struct output_info *i) { - struct alloc_pool_descriptor *d = *slot; - - if (d->allocated) + if (d.allocated) { fprintf (stderr, "%-22s %6d %10lu %10lu(%10lu) %10lu(%10lu) %10lu(%10lu)\n", - d->name, d->elt_size, d->created, d->allocated, - d->allocated / d->elt_size, d->peak, d->peak / d->elt_size, - d->current, d->current / d->elt_size); - i->total_allocated += d->allocated; - i->total_created += d->created; + name, d.elt_size, d.created, d.allocated, + d.allocated / d.elt_size, d.peak, d.peak / d.elt_size, + d.current, d.current / d.elt_size); + i->total_allocated += d.allocated; + i->total_created += d.created; } return 1; } |