summaryrefslogtreecommitdiff
path: root/gcc/bitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r--gcc/bitmap.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/gcc/bitmap.c b/gcc/bitmap.c
index f0fba9cec05..2c5d228fdd1 100644
--- a/gcc/bitmap.c
+++ b/gcc/bitmap.c
@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see
#include "obstack.h"
#include "ggc.h"
#include "bitmap.h"
-#include "hashtab.h"
+#include "hash-table.h"
#include "vec.h"
/* Store information about each particular bitmap, per allocation site. */
@@ -50,48 +50,55 @@ static int next_bitmap_desc_id = 0;
/* Vector mapping descriptor ids to descriptors. */
static vec<bitmap_descriptor> bitmap_descriptors;
-/* Hashtable mapping bitmap names to descriptors. */
-static htab_t bitmap_desc_hash;
-
/* Hashtable helpers. */
-static hashval_t
-hash_descriptor (const void *p)
-{
- const_bitmap_descriptor d = (const_bitmap_descriptor) p;
- return htab_hash_pointer (d->file) + d->line;
-}
+
struct loc
{
const char *file;
const char *function;
int line;
};
-static int
-eq_descriptor (const void *p1, const void *p2)
+
+struct bitmap_desc_hasher : typed_noop_remove <bitmap_descriptor_d>
+{
+ typedef bitmap_descriptor_d value_type;
+ typedef loc compare_type;
+ static inline hashval_t hash (const value_type *);
+ static inline bool equal (const value_type *, const compare_type *);
+};
+
+inline hashval_t
+bitmap_desc_hasher::hash (const value_type *d)
+{
+ return htab_hash_pointer (d->file) + d->line;
+}
+
+inline bool
+bitmap_desc_hasher::equal (const value_type *d, const compare_type *l)
{
- const_bitmap_descriptor d = (const_bitmap_descriptor) p1;
- const struct loc *const l = (const struct loc *) p2;
return d->file == l->file && d->function == l->function && d->line == l->line;
}
+/* Hashtable mapping bitmap names to descriptors. */
+static hash_table <bitmap_desc_hasher> bitmap_desc_hash;
+
/* For given file and line, return descriptor, create new if needed. */
static bitmap_descriptor
get_bitmap_descriptor (const char *file, int line, const char *function)
{
- bitmap_descriptor *slot;
+ bitmap_descriptor_d **slot;
struct loc loc;
loc.file = file;
loc.function = function;
loc.line = line;
- if (!bitmap_desc_hash)
- bitmap_desc_hash = htab_create (10, hash_descriptor, eq_descriptor, NULL);
+ if (!bitmap_desc_hash.is_created ())
+ bitmap_desc_hash.create (10);
- slot = (bitmap_descriptor *)
- htab_find_slot_with_hash (bitmap_desc_hash, &loc,
- htab_hash_pointer (file) + line,
- INSERT);
+ slot = bitmap_desc_hash.find_slot_with_hash (&loc,
+ htab_hash_pointer (file) + line,
+ INSERT);
if (*slot)
return *slot;
@@ -2141,13 +2148,12 @@ struct output_info
unsigned HOST_WIDEST_INT count;
};
-/* Called via htab_traverse. Output bitmap descriptor pointed out by SLOT
- and update statistics. */
-static int
-print_statistics (void **slot, void *b)
+/* Called via hash_table::traverse. Output bitmap descriptor pointed out by
+ SLOT and update statistics. */
+int
+print_statistics (bitmap_descriptor_d **slot, output_info *i)
{
- bitmap_descriptor d = (bitmap_descriptor) *slot;
- struct output_info *i = (struct output_info *) b;
+ bitmap_descriptor d = *slot;
char s[4096];
if (d->allocated)
@@ -2181,7 +2187,7 @@ dump_bitmap_statistics (void)
if (! GATHER_STATISTICS)
return;
- if (!bitmap_desc_hash)
+ if (!bitmap_desc_hash.is_created ())
return;
fprintf (stderr,
@@ -2192,7 +2198,7 @@ dump_bitmap_statistics (void)
fprintf (stderr, "---------------------------------------------------------------------------------\n");
info.count = 0;
info.size = 0;
- htab_traverse (bitmap_desc_hash, print_statistics, &info);
+ bitmap_desc_hash.traverse <output_info *, print_statistics> (&info);
fprintf (stderr, "---------------------------------------------------------------------------------\n");
fprintf (stderr,
"%-41s %9"HOST_WIDEST_INT_PRINT"d %15"HOST_WIDEST_INT_PRINT"d\n",