Commit 5deac340 by Richard Guenther Committed by Richard Biener

hash-table.h (class hash_table): Use a descriptor template argument instead of…

hash-table.h (class hash_table): Use a descriptor template argument instead of decomposed element type and...

2012-08-17  Richard Guenther  <rguenther@suse.de>

	* hash-table.h (class hash_table): Use a descriptor template
	argument instead of decomposed element type and support
	functions.
	(struct pointer_hash): New generic typed pointer-hash.
	(struct typed_free_remove, struct typed_noop_remove): Generic
	hash_table support pieces.
	* coverage.c (struct counts_entry): Add hash_table support
	members.
	* tree-ssa-ccp.c (gimple_htab): Use pointer_hash.
	* tree-ssa-coalesce.c (struct ssa_name_var_hash): New generic
	SSA name by SSA_NAME_VAR hash.
	(coalesce_ssa_name): Use it.
	* tree-ssa-pre.c (struct pre_expr_d): Add hash_table support.
	(expression_to_id): Adjust.
	(struct expr_pred_trans_d): Add hash_table support.
	(phi_translate_table): Adjust.
	(phi_trans_lookup): Likewise.
	(phi_trans_add): Likewise.
	(do_regular_insertion): Likewise.
	* tree-ssa-tail-merge.c (struct same_succ_def): Add hash_table
	support.
	(same_succ_htab): Adjust.
	(find_same_succ_bb): Likewise.
	(find_same_succ): Likewise.
	(update_worklist): Likewise.
	* tree-ssa-threadupdate.c (struct redirection_data): Add hash_table
	support.
	(redirection_data): Adjust.

From-SVN: r190471
parent c58c0d4c
2012-08-17 Richard Guenther <rguenther@suse.de>
* hash-table.h (class hash_table): Use a descriptor template
argument instead of decomposed element type and support
functions.
(struct pointer_hash): New generic typed pointer-hash.
(struct typed_free_remove, struct typed_noop_remove): Generic
hash_table support pieces.
* coverage.c (struct counts_entry): Add hash_table support
members.
* tree-ssa-ccp.c (gimple_htab): Use pointer_hash.
* tree-ssa-coalesce.c (struct ssa_name_var_hash): New generic
SSA name by SSA_NAME_VAR hash.
(coalesce_ssa_name): Use it.
* tree-ssa-pre.c (struct pre_expr_d): Add hash_table support.
(expression_to_id): Adjust.
(struct expr_pred_trans_d): Add hash_table support.
(phi_translate_table): Adjust.
(phi_trans_lookup): Likewise.
(phi_trans_add): Likewise.
(do_regular_insertion): Likewise.
* tree-ssa-tail-merge.c (struct same_succ_def): Add hash_table
support.
(same_succ_htab): Adjust.
(find_same_succ_bb): Likewise.
(find_same_succ): Likewise.
(update_worklist): Likewise.
* tree-ssa-threadupdate.c (struct redirection_data): Add hash_table
support.
(redirection_data): Adjust.
2012-08-17 Richard Guenther <rguenther@suse.de>
* params.def (integer-share-limit): Decrease from 256 to 251,
add rationale.
......
......@@ -77,6 +77,12 @@ typedef struct counts_entry
unsigned cfg_checksum;
gcov_type *counts;
struct gcov_ctr_summary summary;
/* hash_table support. */
typedef counts_entry T;
static inline hashval_t hash (const counts_entry *);
static int equal (const counts_entry *, const counts_entry *);
static void remove (counts_entry *);
} counts_entry_t;
static GTY(()) struct coverage_data *functions_head = 0;
......@@ -144,29 +150,27 @@ get_gcov_unsigned_t (void)
}
inline hashval_t
coverage_counts_entry_hash (const counts_entry_t *entry)
counts_entry::hash (const counts_entry_t *entry)
{
return entry->ident * GCOV_COUNTERS + entry->ctr;
}
inline int
coverage_counts_entry_eq (const counts_entry_t *entry1,
const counts_entry_t *entry2)
counts_entry::equal (const counts_entry_t *entry1,
const counts_entry_t *entry2)
{
return entry1->ident == entry2->ident && entry1->ctr == entry2->ctr;
}
inline void
coverage_counts_entry_del (counts_entry_t *entry)
counts_entry::remove (counts_entry_t *entry)
{
free (entry->counts);
free (entry);
}
/* Hash table of count data. */
static hash_table <counts_entry_t, coverage_counts_entry_hash,
coverage_counts_entry_eq, coverage_counts_entry_del>
counts_hash;
static hash_table <counts_entry> counts_hash;
/* Read in the counts file, if available. */
......
......@@ -1688,10 +1688,7 @@ evaluate_stmt (gimple stmt)
return val;
}
typedef hash_table <gimple_statement_d, typed_pointer_hash<gimple_statement_d>,
typed_pointer_equal<gimple_statement_d>,
typed_null_remove<gimple_statement_d> >
gimple_htab;
typedef hash_table <pointer_hash <gimple_statement_d> > gimple_htab;
/* Given a BUILT_IN_STACK_SAVE value SAVED_VAL, insert a clobber of VAR before
each matching BUILT_IN_STACK_RESTORE. Mark visited phis in VISITED. */
......
......@@ -1258,22 +1258,29 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl,
}
}
/* Returns a hash code for N. */
/* Hashtable support for storing SSA names hashed by their SSA_NAME_VAR. */
struct ssa_name_var_hash : typed_noop_remove <union tree_node>
{
typedef union tree_node T;
static inline hashval_t hash (const_tree);
static inline int equal (const_tree, const_tree);
};
inline hashval_t
hash_ssa_name_by_var (const_tree n)
ssa_name_var_hash::hash (const_tree n)
{
return (hashval_t) htab_hash_pointer (SSA_NAME_VAR (n));
return DECL_UID (SSA_NAME_VAR (n));
}
/* Returns nonzero if N1 and N2 are equal. */
inline int
eq_ssa_name_by_var (const_tree n1, const_tree n2)
ssa_name_var_hash::equal (const_tree n1, const_tree n2)
{
return SSA_NAME_VAR (n1) == SSA_NAME_VAR (n2);
}
/* Reduce the number of copies by coalescing variables in the function. Return
a partition map with the resulting coalesces. */
......@@ -1286,9 +1293,7 @@ coalesce_ssa_name (void)
bitmap used_in_copies = BITMAP_ALLOC (NULL);
var_map map;
unsigned int i;
static hash_table <tree_node, hash_ssa_name_by_var, eq_ssa_name_by_var,
typed_null_remove<tree_node> >
ssa_name_hash;
static hash_table <ssa_name_var_hash> ssa_name_hash;
cl = create_coalesce_list ();
map = create_outofssa_var_map (cl, used_in_copies);
......
......@@ -165,11 +165,16 @@ typedef union pre_expr_union_d
vn_reference_t reference;
} pre_expr_union;
typedef struct pre_expr_d
typedef struct pre_expr_d : typed_noop_remove <pre_expr_d>
{
enum pre_expr_kind kind;
unsigned int id;
pre_expr_union u;
/* hash_table support. */
typedef pre_expr_d T;
static inline hashval_t hash (const pre_expr_d *);
static inline int equal (const pre_expr_d *, const pre_expr_d *);
} *pre_expr;
#define PRE_EXPR_NAME(e) (e)->u.name
......@@ -180,7 +185,7 @@ typedef struct pre_expr_d
/* Compare E1 and E1 for equality. */
inline int
ssa_pre_expr_eq (const struct pre_expr_d *e1, const struct pre_expr_d *e2)
pre_expr_d::equal (const struct pre_expr_d *e1, const struct pre_expr_d *e2)
{
if (e1->kind != e2->kind)
return false;
......@@ -205,7 +210,7 @@ ssa_pre_expr_eq (const struct pre_expr_d *e1, const struct pre_expr_d *e2)
/* Hash E. */
inline hashval_t
ssa_pre_expr_hash (const struct pre_expr_d *e)
pre_expr_d::hash (const struct pre_expr_d *e)
{
switch (e->kind)
{
......@@ -229,9 +234,7 @@ static unsigned int next_expression_id;
DEF_VEC_P (pre_expr);
DEF_VEC_ALLOC_P (pre_expr, heap);
static VEC(pre_expr, heap) *expressions;
static hash_table <pre_expr_d, ssa_pre_expr_hash, ssa_pre_expr_eq,
typed_null_remove <pre_expr_d> >
expression_to_id;
static hash_table <pre_expr_d> expression_to_id;
static VEC(unsigned, heap) *name_to_id;
/* Allocate an expression id for EXPR. */
......@@ -483,7 +486,7 @@ static bitmap need_ab_cleanup;
/* A three tuple {e, pred, v} used to cache phi translations in the
phi_translate_table. */
typedef struct expr_pred_trans_d
typedef struct expr_pred_trans_d : typed_free_remove<expr_pred_trans_d>
{
/* The expression. */
pre_expr e;
......@@ -497,23 +500,23 @@ typedef struct expr_pred_trans_d
/* The hashcode for the expression, pred pair. This is cached for
speed reasons. */
hashval_t hashcode;
/* hash_table support. */
typedef expr_pred_trans_d T;
static inline hashval_t hash (const expr_pred_trans_d *);
static inline int equal (const expr_pred_trans_d *, const expr_pred_trans_d *);
} *expr_pred_trans_t;
typedef const struct expr_pred_trans_d *const_expr_pred_trans_t;
/* Return the hash value for a phi translation table entry. */
inline hashval_t
ssa_expr_pred_trans_hash (const expr_pred_trans_d *ve)
expr_pred_trans_d::hash (const expr_pred_trans_d *e)
{
return ve->hashcode;
return e->hashcode;
}
/* Return true if two phi translation table entries are the same.
P1 and P2 should point to the expr_pred_trans_t's to be compared.*/
inline int
ssa_expr_pred_trans_eq (const expr_pred_trans_d *ve1,
const expr_pred_trans_d *ve2)
expr_pred_trans_d::equal (const expr_pred_trans_d *ve1,
const expr_pred_trans_d *ve2)
{
basic_block b1 = ve1->pred;
basic_block b2 = ve2->pred;
......@@ -522,16 +525,12 @@ ssa_expr_pred_trans_eq (const expr_pred_trans_d *ve1,
be equal. */
if (b1 != b2)
return false;
return ssa_pre_expr_eq (ve1->e, ve2->e);
return pre_expr_d::equal (ve1->e, ve2->e);
}
/* The phi_translate_table caches phi translations for a given
expression and predecessor. */
static hash_table <expr_pred_trans_d, ssa_expr_pred_trans_hash,
ssa_expr_pred_trans_eq,
typed_free_remove <expr_pred_trans_d> >
phi_translate_table;
static hash_table <expr_pred_trans_d> phi_translate_table;
/* Search in the phi translation table for the translation of
expression E in basic block PRED.
......@@ -545,7 +544,7 @@ phi_trans_lookup (pre_expr e, basic_block pred)
ept.e = e;
ept.pred = pred;
ept.hashcode = iterative_hash_hashval_t (ssa_pre_expr_hash (e), pred->index);
ept.hashcode = iterative_hash_hashval_t (pre_expr_d::hash (e), pred->index);
slot = phi_translate_table.find_slot_with_hash (&ept, ept.hashcode,
NO_INSERT);
if (!slot)
......@@ -566,7 +565,7 @@ phi_trans_add (pre_expr e, pre_expr v, basic_block pred)
new_pair->e = e;
new_pair->pred = pred;
new_pair->v = v;
new_pair->hashcode = iterative_hash_hashval_t (ssa_pre_expr_hash (e),
new_pair->hashcode = iterative_hash_hashval_t (pre_expr_d::hash (e),
pred->index);
slot = phi_translate_table.find_slot_with_hash (new_pair,
......@@ -3495,7 +3494,7 @@ do_regular_insertion (basic_block block, basic_block dom)
do_insertion = true;
if (first_s == NULL)
first_s = edoubleprime;
else if (!ssa_pre_expr_eq (first_s, edoubleprime))
else if (!pre_expr_d::equal (first_s, edoubleprime))
all_same = false;
}
}
......
......@@ -224,10 +224,24 @@ struct same_succ_def
bool in_worklist;
/* The hash value of the struct. */
hashval_t hashval;
/* hash_table support. */
typedef same_succ_def T;
static inline hashval_t hash (const same_succ_def *);
static int equal (const same_succ_def *, const same_succ_def *);
static void remove (same_succ_def *);
};
typedef struct same_succ_def *same_succ;
typedef const struct same_succ_def *const_same_succ;
/* hash routine for hash_table support, returns hashval of E. */
inline hashval_t
same_succ_def::hash (const same_succ_def *e)
{
return e->hashval;
}
/* A group of bbs where 1 bb from bbs can replace the other bbs. */
struct bb_cluster_def
......@@ -415,8 +429,8 @@ stmt_update_dep_bb (gimple stmt)
/* Calculates hash value for same_succ VE. */
hashval_t
ssa_same_succ_hash (const_same_succ e)
static hashval_t
same_succ_hash (const_same_succ e)
{
hashval_t hashval = bitmap_hash (e->succs);
int flags;
......@@ -511,10 +525,10 @@ inverse_flags (const_same_succ e1, const_same_succ e2)
return (f1a & mask) == (f2a & mask) && (f1b & mask) == (f2b & mask);
}
/* Compares SAME_SUCCs VE1 and VE2. */
/* Compares SAME_SUCCs E1 and E2. */
int
ssa_same_succ_equal (const_same_succ e1, const_same_succ e2)
same_succ_def::equal (const_same_succ e1, const_same_succ e2)
{
unsigned int i, first1, first2;
gimple_stmt_iterator gsi1, gsi2;
......@@ -584,10 +598,10 @@ same_succ_alloc (void)
return same;
}
/* Delete same_succ VE. */
/* Delete same_succ E. */
inline void
ssa_same_succ_delete (same_succ e)
void
same_succ_def::remove (same_succ e)
{
BITMAP_FREE (e->bbs);
BITMAP_FREE (e->succs);
......@@ -608,11 +622,7 @@ same_succ_reset (same_succ same)
VEC_truncate (int, same->succ_flags, 0);
}
/* Hash table with all same_succ entries. */
static hash_table <struct same_succ_def, ssa_same_succ_hash,
ssa_same_succ_equal, ssa_same_succ_delete>
same_succ_htab;
static hash_table <same_succ_def> same_succ_htab;
/* Array that is used to store the edge flags for a successor. */
......@@ -692,7 +702,7 @@ find_same_succ_bb (basic_block bb, same_succ *same_p)
EXECUTE_IF_SET_IN_BITMAP (same->succs, 0, j, bj)
VEC_safe_push (int, heap, same->succ_flags, same_succ_edge_flags[j]);
same->hashval = ssa_same_succ_hash (same);
same->hashval = same_succ_hash (same);
slot = same_succ_htab.find_slot_with_hash (same, same->hashval, INSERT);
if (*slot == NULL)
......@@ -728,7 +738,7 @@ find_same_succ (void)
same = same_succ_alloc ();
}
ssa_same_succ_delete (same);
same_succ_def::remove (same);
}
/* Initializes worklist administration. */
......@@ -860,7 +870,7 @@ update_worklist (void)
if (same == NULL)
same = same_succ_alloc ();
}
ssa_same_succ_delete (same);
same_succ_def::remove (same);
bitmap_clear (deleted_bb_preds);
}
......
......@@ -110,7 +110,7 @@ struct el
may have many incoming edges threaded to the same outgoing edge. This
can be naturally implemented with a hash table. */
struct redirection_data
struct redirection_data : typed_free_remove<redirection_data>
{
/* A duplicate of B with the trailing control statement removed and which
targets a single successor of B. */
......@@ -125,8 +125,30 @@ struct redirection_data
/* A list of incoming edges which we want to thread to
OUTGOING_EDGE->dest. */
struct el *incoming_edges;
/* hash_table support. */
typedef redirection_data T;
static inline hashval_t hash (const redirection_data *);
static inline int equal (const redirection_data *, const redirection_data *);
};
inline hashval_t
redirection_data::hash (const redirection_data *p)
{
edge e = p->outgoing_edge;
return e->dest->index;
}
inline int
redirection_data::equal (const redirection_data *p1, const redirection_data *p2)
{
edge e1 = p1->outgoing_edge;
edge e2 = p2->outgoing_edge;
edge e3 = p1->intermediate_edge;
edge e4 = p2->intermediate_edge;
return e1 == e2 && e3 == e4;
}
/* Data structure of information to pass to hash table traversal routines. */
struct ssa_local_info_t
{
......@@ -217,32 +239,9 @@ create_block_for_threading (basic_block bb, struct redirection_data *rd)
rd->dup_block->count = 0;
}
/* Hashing and equality routines for our hash table. */
inline hashval_t
ssa_redirection_data_hash (const struct redirection_data *p)
{
edge e = p->outgoing_edge;
return e->dest->index;
}
inline int
ssa_redirection_data_eq (const struct redirection_data *p1,
const struct redirection_data *p2)
{
edge e1 = p1->outgoing_edge;
edge e2 = p2->outgoing_edge;
edge e3 = p1->intermediate_edge;
edge e4 = p2->intermediate_edge;
return e1 == e2 && e3 == e4;
}
/* Main data structure to hold information for duplicates of BB. */
static hash_table <struct redirection_data, ssa_redirection_data_hash,
ssa_redirection_data_eq,
typed_free_remove<struct redirection_data> >
redirection_data;
static hash_table <redirection_data> redirection_data;
/* Given an outgoing edge E lookup and return its entry in our hash table.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment