+2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
+
+ * ipa-utils.c, lto-section-in.c, lto-streamer.h,
+ tree-scalar-evolution.c: Replace htab with hash_table.
+
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* lto-section-in.c (lto_delete_in_decl_state): Adjust.
temporarily inconsistent. */
if (src->decl == dst->decl)
{
- void **slot;
struct lto_in_decl_state temp;
struct lto_in_decl_state *state;
/* We are going to move the decl, we want to remove its file decl data.
and link these with the new decl. */
temp.fn_decl = src->decl;
- slot = htab_find_slot (src->lto_file_data->function_decl_states,
- &temp, NO_INSERT);
- state = (lto_in_decl_state *)*slot;
- htab_clear_slot (src->lto_file_data->function_decl_states, slot);
+ lto_in_decl_state **slot
+ = src->lto_file_data->function_decl_states->find_slot (&temp,
+ NO_INSERT);
+ state = *slot;
+ src->lto_file_data->function_decl_states->clear_slot (slot);
gcc_assert (state);
/* Duplicate the decl and be sure it does not link into body of DST. */
/* Associate the decl state with new declaration, so LTO streamer
can look it up. */
state->fn_decl = src->decl;
- slot = htab_find_slot (src->lto_file_data->function_decl_states,
- state, INSERT);
+ slot
+ = src->lto_file_data->function_decl_states->find_slot (state, INSERT);
gcc_assert (!*slot);
*slot = state;
}
ggc_free (state);
}
-/* Hashtable helpers. lto_in_decl_states are hash by their function decls. */
-
-hashval_t
-lto_hash_in_decl_state (const void *p)
-{
- const struct lto_in_decl_state *state = (const struct lto_in_decl_state *) p;
- return htab_hash_pointer (state->fn_decl);
-}
-
-/* Return true if the fn_decl field of the lto_in_decl_state pointed to by
- P1 equals to the function decl P2. */
-
-int
-lto_eq_in_decl_state (const void *p1, const void *p2)
-{
- const struct lto_in_decl_state *state1 =
- (const struct lto_in_decl_state *) p1;
- const struct lto_in_decl_state *state2 =
- (const struct lto_in_decl_state *) p2;
- return state1->fn_decl == state2->fn_decl;
-}
-
-
/* Search the in-decl state of a function FUNC contained in the file
associated with FILE_DATA. Return NULL if not found. */
tree func)
{
struct lto_in_decl_state temp;
- void **slot;
+ lto_in_decl_state **slot;
temp.fn_decl = func;
- slot = htab_find_slot (file_data->function_decl_states, &temp, NO_INSERT);
- return slot? ((struct lto_in_decl_state*) *slot) : NULL;
+ slot = file_data->function_decl_states->find_slot (&temp, NO_INSERT);
+ return slot? *slot : NULL;
}
/* Free decl_states. */
lto_free_function_in_decl_state_for_node (symtab_node *node)
{
struct lto_in_decl_state temp;
- void **slot;
+ lto_in_decl_state **slot;
if (!node->lto_file_data)
return;
temp.fn_decl = node->decl;
- slot = htab_find_slot (node->lto_file_data->function_decl_states,
- &temp, NO_INSERT);
+ slot
+ = node->lto_file_data->function_decl_states->find_slot (&temp, NO_INSERT);
if (slot && *slot)
{
- lto_free_function_in_decl_state ((struct lto_in_decl_state*) *slot);
- htab_clear_slot (node->lto_file_data->function_decl_states,
- slot);
+ lto_free_function_in_decl_state (*slot);
+ node->lto_file_data->function_decl_states->clear_slot (slot);
}
node->lto_file_data = NULL;
}
/* Structure to hold states of input scope. */
-struct GTY(()) lto_in_decl_state
+struct GTY((for_user)) lto_in_decl_state
{
/* Array of lto_in_decl_buffers to store type and decls streams. */
vec<tree, va_gc> *streams[LTO_N_DECL_STREAMS];
typedef struct lto_in_decl_state *lto_in_decl_state_ptr;
+struct decl_state_hasher : ggc_hasher<lto_in_decl_state *>
+{
+ static hashval_t
+ hash (lto_in_decl_state *s)
+ {
+ return htab_hash_pointer (s->fn_decl);
+ }
+
+ static bool
+ equal (lto_in_decl_state *a, lto_in_decl_state *b)
+ {
+ return a->fn_decl == b->fn_decl;
+ }
+};
/* The structure that holds all of the vectors of global types,
decls and cgraph nodes used in the serialization of this file. */
lto_symtab_encoder_t GTY((skip)) symtab_node_encoder;
/* Hash table maps lto-related section names to location in file. */
- htab_t GTY((param_is (struct lto_in_decl_state))) function_decl_states;
+ hash_table<decl_state_hasher> *function_decl_states;
/* The .o file that these offsets relate to. */
const char *GTY((skip)) file_name;
const char *);
extern struct lto_in_decl_state *lto_new_in_decl_state (void);
extern void lto_delete_in_decl_state (struct lto_in_decl_state *);
-extern hashval_t lto_hash_in_decl_state (const void *);
-extern int lto_eq_in_decl_state (const void *, const void *);
extern struct lto_in_decl_state *lto_get_function_in_decl_state (
struct lto_file_decl_data *, tree);
extern void lto_free_function_in_decl_state (struct lto_in_decl_state *);
+2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
+
+ * lto.c: Replace htab with hash_table.
+
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* lto.c (lto_read_in_decl_state): Adjust.
/* Read in per-function decl states and enter them in hash table. */
decl_data->function_decl_states =
- htab_create_ggc (37, lto_hash_in_decl_state, lto_eq_in_decl_state, NULL);
+ hash_table<decl_state_hasher>::create_ggc (37);
for (i = 1; i < num_decl_states; i++)
{
struct lto_in_decl_state *state = lto_new_in_decl_state ();
- void **slot;
data_ptr = lto_read_in_decl_state (data_in, data_ptr, state);
- slot = htab_find_slot (decl_data->function_decl_states, state, INSERT);
+ lto_in_decl_state **slot
+ = decl_data->function_decl_states->find_slot (state, INSERT);
gcc_assert (*slot == NULL);
*slot = state;
}
}
}
-/* A callback of htab_traverse. Just extracts a state from SLOT
- and calls lto_fixup_state. */
-
-static int
-lto_fixup_state_aux (void **slot, void *aux ATTRIBUTE_UNUSED)
-{
- struct lto_in_decl_state *state = (struct lto_in_decl_state *) *slot;
- lto_fixup_state (state);
- return 1;
-}
-
/* Fix the decls from all FILES. Replaces each decl with the corresponding
prevailing one. */
struct lto_in_decl_state *state = file->global_decl_state;
lto_fixup_state (state);
- htab_traverse (file->function_decl_states, lto_fixup_state_aux, NULL);
+ hash_table<decl_state_hasher>::iterator iter;
+ lto_in_decl_state *elt;
+ FOR_EACH_HASH_TABLE_ELEMENT (*file->function_decl_states, elt,
+ lto_in_decl_state *, iter)
+ lto_fixup_state (elt);
}
}
claiming that below basic block with index INSTANTIATED_BELOW, the
value of the SSA name can be expressed as CHREC. */
-struct GTY(()) scev_info_str {
+struct GTY((for_user)) scev_info_str {
unsigned int name_version;
int instantiated_below;
tree chrec;
happen, then it qualifies it with chrec_known. */
tree chrec_known;
-static GTY ((param_is (struct scev_info_str))) htab_t scalar_evolution_info;
+struct scev_info_hasher : ggc_hasher<scev_info_str *>
+{
+ static hashval_t hash (scev_info_str *i);
+ static bool equal (const scev_info_str *a, const scev_info_str *b);
+};
+
+static GTY (()) hash_table<scev_info_hasher> *scalar_evolution_info;
\f
/* Constructs a new SCEV_INFO_STR structure for VAR and INSTANTIATED_BELOW. */
/* Computes a hash function for database element ELT. */
-static inline hashval_t
-hash_scev_info (const void *elt_)
+hashval_t
+scev_info_hasher::hash (scev_info_str *elt)
{
- const struct scev_info_str *elt = (const struct scev_info_str *) elt_;
return elt->name_version ^ elt->instantiated_below;
}
/* Compares database elements E1 and E2. */
-static inline int
-eq_scev_info (const void *e1, const void *e2)
+bool
+scev_info_hasher::equal (const scev_info_str *elt1, const scev_info_str *elt2)
{
- const struct scev_info_str *elt1 = (const struct scev_info_str *) e1;
- const struct scev_info_str *elt2 = (const struct scev_info_str *) e2;
-
return (elt1->name_version == elt2->name_version
&& elt1->instantiated_below == elt2->instantiated_below);
}
-/* Deletes database element E. */
-
-static void
-del_scev_info (void *e)
-{
- ggc_free (e);
-}
-
-
/* Get the scalar evolution of VAR for INSTANTIATED_BELOW basic block.
A first query on VAR returns chrec_not_analyzed_yet. */
{
struct scev_info_str *res;
struct scev_info_str tmp;
- PTR *slot;
tmp.name_version = SSA_NAME_VERSION (var);
tmp.instantiated_below = instantiated_below->index;
- slot = htab_find_slot (scalar_evolution_info, &tmp, INSERT);
+ scev_info_str **slot = scalar_evolution_info->find_slot (&tmp, INSERT);
if (!*slot)
*slot = new_scev_info_str (instantiated_below, var);
- res = (struct scev_info_str *) *slot;
+ res = *slot;
return &res->chrec;
}
hash_idx_scev_info (const void *elt_)
{
unsigned idx = ((size_t) elt_) - 2;
- return hash_scev_info (&global_cache->entries[idx]);
+ return scev_info_hasher::hash (&global_cache->entries[idx]);
}
/* Compares database elements E1 and E2. */
eq_idx_scev_info (const void *e1, const void *e2)
{
unsigned idx1 = ((size_t) e1) - 2;
- return eq_scev_info (&global_cache->entries[idx1], e2);
+ return scev_info_hasher::equal (&global_cache->entries[idx1],
+ (const scev_info_str *) e2);
}
/* Returns from CACHE the slot number of the cached chrec for NAME. */
e.name_version = SSA_NAME_VERSION (name);
e.instantiated_below = instantiate_below->index;
void **slot = htab_find_slot_with_hash (cache.map, &e,
- hash_scev_info (&e), INSERT);
+ scev_info_hasher::hash (&e), INSERT);
if (!*slot)
{
e.chrec = chrec_not_analyzed_yet;
stats->nb_undetermined);
fprintf (file, "-----------------------------------------\n");
fprintf (file, "%d\tchrecs in the scev database\n",
- (int) htab_elements (scalar_evolution_info));
+ (int) scalar_evolution_info->elements ());
fprintf (file, "%d\tsets in the scev database\n", nb_set_scev);
fprintf (file, "%d\tgets in the scev database\n", nb_get_scev);
fprintf (file, "-----------------------------------------\n");
fprintf (dump_file, ")\n");
}
-/* Callback for htab_traverse, gathers information on chrecs in the
- hashtable. */
-
-static int
-gather_stats_on_scev_database_1 (void **slot, void *stats)
-{
- struct scev_info_str *entry = (struct scev_info_str *) *slot;
-
- gather_chrec_stats (entry->chrec, (struct chrec_stats *) stats);
-
- return 1;
-}
-
/* Classify the chrecs of the whole database. */
void
reset_chrecs_counters (&stats);
- htab_traverse (scalar_evolution_info, gather_stats_on_scev_database_1,
- &stats);
+ hash_table<scev_info_hasher>::iterator iter;
+ scev_info_str *elt;
+ FOR_EACH_HASH_TABLE_ELEMENT (*scalar_evolution_info, elt, scev_info_str *,
+ iter)
+ gather_chrec_stats (elt->chrec, &stats);
dump_chrecs_stats (dump_file, &stats);
}
{
struct loop *loop;
- scalar_evolution_info = htab_create_ggc (100, hash_scev_info, eq_scev_info,
- del_scev_info);
+ scalar_evolution_info = hash_table<scev_info_hasher>::create_ggc (100);
initialize_scalar_evolutions_analyzer ();
if (!scalar_evolution_info)
return;
- htab_empty (scalar_evolution_info);
+ scalar_evolution_info->empty ();
}
/* Cleans up the information cached by the scalar evolutions analysis
{
if (!scalar_evolution_info)
return;
- htab_delete (scalar_evolution_info);
+ scalar_evolution_info->empty ();
scalar_evolution_info = NULL;
}