diff options
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 96 |
1 files changed, 71 insertions, 25 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index a76d9ae..d5dde5f 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -256,6 +256,7 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" +#include "hash-table.h" #include "gimple-pretty-print.h" #include "tree-flow.h" #include "cfgloop.h" @@ -317,7 +318,7 @@ new_scev_info_str (basic_block instantiated_below, tree var) /* Computes a hash function for database element ELT. */ -static hashval_t +static inline hashval_t hash_scev_info (const void *elt) { return SSA_NAME_VERSION (((const struct scev_info_str *) elt)->var); @@ -325,7 +326,7 @@ hash_scev_info (const void *elt) /* Compares database elements E1 and E2. */ -static int +static inline int eq_scev_info (const void *e1, const void *e2) { const struct scev_info_str *elt1 = (const struct scev_info_str *) e1; @@ -343,6 +344,39 @@ del_scev_info (void *e) ggc_free (e); } +/* Hashtable helpers. */ + +struct scev_info_hasher +{ + typedef scev_info_str value_type; + typedef scev_info_str compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); + static inline void remove (value_type *); +}; + +inline hashval_t +scev_info_hasher::hash (const value_type *elt) +{ + return hash_scev_info (elt); +} + +inline bool +scev_info_hasher::equal (const value_type *elt1, const compare_type *elt2) +{ + return eq_scev_info (elt1, elt2); +} + +/* Deletes database element E. */ + +inline void +scev_info_hasher::remove (value_type *e) +{ + del_scev_info (e); +} + +typedef hash_table <scev_info_hasher> scev_info_hash_table_type; + /* Get the scalar evolution of VAR for INSTANTIATED_BELOW basic block. A first query on VAR returns chrec_not_analyzed_yet. */ @@ -2048,14 +2082,14 @@ analyze_scalar_evolution_in_loop (struct loop *wrto_loop, struct loop *use_loop, INSTANTIATED_BELOW block. */ static tree -get_instantiated_value (htab_t cache, basic_block instantiated_below, - tree version) +get_instantiated_value (scev_info_hash_table_type cache, + basic_block instantiated_below, tree version) { struct scev_info_str *info, pattern; pattern.var = version; pattern.instantiated_below = instantiated_below; - info = (struct scev_info_str *) htab_find (cache, &pattern); + info = cache.find (&pattern); if (info) return info->chrec; @@ -2067,19 +2101,19 @@ get_instantiated_value (htab_t cache, basic_block instantiated_below, INSTANTIATED_BELOW to VAL. */ static void -set_instantiated_value (htab_t cache, basic_block instantiated_below, - tree version, tree val) +set_instantiated_value (scev_info_hash_table_type cache, + basic_block instantiated_below, tree version, tree val) { struct scev_info_str *info, pattern; - PTR *slot; + scev_info_str **slot; pattern.var = version; pattern.instantiated_below = instantiated_below; - slot = htab_find_slot (cache, &pattern, INSERT); + slot = cache.find_slot (&pattern, INSERT); if (!*slot) *slot = new_scev_info_str (instantiated_below, version); - info = (struct scev_info_str *) *slot; + info = *slot; info->chrec = val; } @@ -2114,7 +2148,7 @@ loop_closed_phi_def (tree var) } static tree instantiate_scev_r (basic_block, struct loop *, struct loop *, - tree, bool, htab_t, int); + tree, bool, scev_info_hash_table_type, int); /* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW and EVOLUTION_LOOP, that were left under a symbolic form. @@ -2134,7 +2168,8 @@ static tree instantiate_scev_name (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree res; struct loop *def_loop; @@ -2236,7 +2271,8 @@ static tree instantiate_scev_poly (basic_block instantiate_below, struct loop *evolution_loop, struct loop *, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree op1; tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, @@ -2282,7 +2318,8 @@ instantiate_scev_binary (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, enum tree_code code, tree type, tree c0, tree c1, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree op1; tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, inner_loop, @@ -2341,7 +2378,8 @@ static tree instantiate_array_ref (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree res; tree index = TREE_OPERAND (chrec, 1); @@ -2380,7 +2418,8 @@ instantiate_scev_convert (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, tree type, tree op, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, + scev_info_hash_table_type cache, int size_expr) { tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, inner_loop, op, @@ -2429,7 +2468,8 @@ instantiate_scev_not (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, enum tree_code code, tree type, tree op, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, inner_loop, op, @@ -2478,7 +2518,8 @@ static tree instantiate_scev_3 (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree op1, op2; tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, @@ -2526,7 +2567,8 @@ static tree instantiate_scev_2 (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree op1; tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, @@ -2566,7 +2608,8 @@ static tree instantiate_scev_1 (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { tree op0 = instantiate_scev_r (instantiate_below, evolution_loop, inner_loop, TREE_OPERAND (chrec, 0), @@ -2599,7 +2642,8 @@ static tree instantiate_scev_r (basic_block instantiate_below, struct loop *evolution_loop, struct loop *inner_loop, tree chrec, - bool fold_conversions, htab_t cache, int size_expr) + bool fold_conversions, scev_info_hash_table_type cache, + int size_expr) { /* Give up if the expression is larger than the MAX that we allow. */ if (size_expr++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE)) @@ -2705,7 +2749,8 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop, tree chrec) { tree res; - htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info); + scev_info_hash_table_type cache; + cache.create (10); if (dump_file && (dump_flags & TDF_SCEV)) { @@ -2727,7 +2772,7 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop, fprintf (dump_file, "))\n"); } - htab_delete (cache); + cache.dispose (); return res; } @@ -2740,10 +2785,11 @@ instantiate_scev (basic_block instantiate_below, struct loop *evolution_loop, tree resolve_mixers (struct loop *loop, tree chrec) { - htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info); + scev_info_hash_table_type cache; + cache.create (10); tree ret = instantiate_scev_r (block_before_loop (loop), loop, NULL, chrec, true, cache, 0); - htab_delete (cache); + cache.dispose (); return ret; } |