diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-06 14:34:51 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-06 14:34:51 +0000 |
commit | b30a87157955484be66baebfecc08c680d721d93 (patch) | |
tree | 9ee2a06ba9a73c0dbf9a0d7de12bd0049f095cce /gcc/tree-cfg.c | |
parent | bfd211a3616f0c871ceecc126156dea9654c96e9 (diff) | |
download | gcc-b30a87157955484be66baebfecc08c680d721d93.tar.gz |
2006-02-06 Paolo Bonzini <bonzini@gnu.org>
* Makefile.in (tree-ssa-loop-ivopts.o): Add pointer-set.h dependency.
(tree-ssa-reassoc.o): Add pointer-set.h dependency.
(tree-cfg.o): Remove hashtab.h dependency.
* tree-ssa-loop-ivopts.c: Include pointer-set.h.
(struct ivopts_data): Change niters to pointer_map_t.
(struct nfe_cache_elt, nfe_hash, nfe_eq): Delete.
(niter_for_exit): Create pointer_map on demand. Change for
pointer_map API.
(tree_ssa_iv_optimize_init): Initialize data->niters to NULL.
(free_loop_data): Destroy data->niters if created and reset field.
(tree_ssa_iv_optimize_finalize): Don't delete data->niters here.
(tree_ssa_iv_optimize_loop): Check for presence of stale data.
* tree-ssa-reassoc.c: Include pointer-set.h.
(bb_rank): Change to long *.
(operand_rank): Change to pointer_map_t.
(find_operand_rank): Return long, -1 if not found. Declare as inline.
(insert_operand_rank): Accept long.
(operand_entry_hash, operand_entry_eq): Remove.
(get_rank): Return long. Adjust for changes above.
(init_reassoc): Change rank type to long. Adjust creation of bb_rank
and operand_rank.
(fini_reassoc): Delete operand_rank with pointer_map_destroy.
* tree-ssa-structalias.c (vi_for_tree): Change to pointer_map.
(struct tree_vi, tree_vi_t, tree_vi_hash, tree_vi_eq): Delete.
(insert_vi_for_tree): Rewrite for pointer_map API. Assert argument
is not NULL.
(lookup_vi_for_tree): Rewrite for pointer_map API. Return varinfo_t
directly since it cannot be NULL.
(get_vi_for_tree): Rewrite for pointer_map API.
(find_what_p_points_to): Adjust for change to lookup_vi_for_tree.
(init_alias_vars): Create vi_for_tree as pointer_map.
(delete_points_to_sets): Delete vi_for_tree using pointer_map_destroy.
* tree-cfg.c: Don't include hashtab.h.
(edge_to_cases): Declare as pointer_map.
(struct edge_to_cases_elt, edge_to_cases_hash, edge_to_cases_eq):
Delete.
(edge_to_cases_cleanup): Rewrite as pointer_map_traverse callback.
(start_recording_case_labels): Create edge_to_cases as pointer_map.
(end_recoding_case_labels): Cleanup edge_to_cases manually before
destroying it.
(record_switch_edge): Delete.
(get_cases_for_edge): Adjust for pointer_map API, inline
record_switch_edge (rewritten for new API), remove goto.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121648 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 120 |
1 files changed, 24 insertions, 96 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 6f492052501..d9794592cf6 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -44,7 +44,6 @@ Boston, MA 02110-1301, USA. */ #include "except.h" #include "cfgloop.h" #include "cfglayout.h" -#include "hashtab.h" #include "tree-ssa-propagate.h" #include "value-prof.h" #include "pointer-set.h" @@ -70,19 +69,7 @@ static const int initial_cfg_capacity = 20; more persistent. The key is getting notification of changes to the CFG (particularly edge removal, creation and redirection). */ -struct edge_to_cases_elt -{ - /* The edge itself. Necessary for hashing and equality tests. */ - edge e; - - /* The case labels associated with this edge. We link these up via - their TREE_CHAIN field, then we wipe out the TREE_CHAIN fields - when we destroy the hash table. This prevents problems when copying - SWITCH_EXPRs. */ - tree case_labels; -}; - -static htab_t edge_to_cases; +static struct pointer_map_t *edge_to_cases; /* CFG statistics. */ struct cfg_stats_d @@ -619,28 +606,6 @@ make_cond_expr_edges (basic_block bb) } } -/* Hashing routine for EDGE_TO_CASES. */ - -static hashval_t -edge_to_cases_hash (const void *p) -{ - edge e = ((struct edge_to_cases_elt *)p)->e; - - /* Hash on the edge itself (which is a pointer). */ - return htab_hash_pointer (e); -} - -/* Equality routine for EDGE_TO_CASES, edges are unique, so testing - for equality is just a pointer comparison. */ - -static int -edge_to_cases_eq (const void *p1, const void *p2) -{ - edge e1 = ((struct edge_to_cases_elt *)p1)->e; - edge e2 = ((struct edge_to_cases_elt *)p2)->e; - - return e1 == e2; -} /* Called for each element in the hash table (P) as we delete the edge to cases hash table. @@ -649,18 +614,20 @@ edge_to_cases_eq (const void *p1, const void *p2) SWITCH_EXPRs and structure sharing rules, then free the hash table element. */ -static void -edge_to_cases_cleanup (void *p) +static bool +edge_to_cases_cleanup (void *key ATTRIBUTE_UNUSED, void **value, + void *data ATTRIBUTE_UNUSED) { - struct edge_to_cases_elt *elt = (struct edge_to_cases_elt *) p; tree t, next; - for (t = elt->case_labels; t; t = next) + for (t = (tree) *value; t; t = next) { next = TREE_CHAIN (t); TREE_CHAIN (t) = NULL; } - free (p); + + *value = NULL; + return false; } /* Start recording information mapping edges to case labels. */ @@ -669,11 +636,7 @@ void start_recording_case_labels (void) { gcc_assert (edge_to_cases == NULL); - - edge_to_cases = htab_create (37, - edge_to_cases_hash, - edge_to_cases_eq, - edge_to_cases_cleanup); + edge_to_cases = pointer_map_create (); } /* Return nonzero if we are recording information for case labels. */ @@ -689,46 +652,11 @@ recording_case_labels_p (void) void end_recording_case_labels (void) { - htab_delete (edge_to_cases); + pointer_map_traverse (edge_to_cases, edge_to_cases_cleanup, NULL); + pointer_map_destroy (edge_to_cases); edge_to_cases = NULL; } -/* Record that CASE_LABEL (a CASE_LABEL_EXPR) references edge E. */ - -static void -record_switch_edge (edge e, tree case_label) -{ - struct edge_to_cases_elt *elt; - void **slot; - - /* Build a hash table element so we can see if E is already - in the table. */ - elt = XNEW (struct edge_to_cases_elt); - elt->e = e; - elt->case_labels = case_label; - - slot = htab_find_slot (edge_to_cases, elt, INSERT); - - if (*slot == NULL) - { - /* E was not in the hash table. Install E into the hash table. */ - *slot = (void *)elt; - } - else - { - /* E was already in the hash table. Free ELT as we do not need it - anymore. */ - free (elt); - - /* Get the entry stored in the hash table. */ - elt = (struct edge_to_cases_elt *) *slot; - - /* Add it to the chain of CASE_LABEL_EXPRs referencing E. */ - TREE_CHAIN (case_label) = elt->case_labels; - elt->case_labels = case_label; - } -} - /* If we are inside a {start,end}_recording_cases block, then return a chain of CASE_LABEL_EXPRs from T which reference E. @@ -737,7 +665,6 @@ record_switch_edge (edge e, tree case_label) static tree get_cases_for_edge (edge e, tree t) { - struct edge_to_cases_elt elt, *elt_p; void **slot; size_t i, n; tree vec; @@ -747,16 +674,9 @@ get_cases_for_edge (edge e, tree t) if (!recording_case_labels_p ()) return NULL; -restart: - elt.e = e; - elt.case_labels = NULL; - slot = htab_find_slot (edge_to_cases, &elt, NO_INSERT); - + slot = pointer_map_contains (edge_to_cases, e); if (slot) - { - elt_p = (struct edge_to_cases_elt *)*slot; - return elt_p->case_labels; - } + return (tree) *slot; /* If we did not find E in the hash table, then this must be the first time we have been queried for information about E & T. Add all the @@ -766,11 +686,19 @@ restart: n = TREE_VEC_LENGTH (vec); for (i = 0; i < n; i++) { - tree lab = CASE_LABEL (TREE_VEC_ELT (vec, i)); + tree elt = TREE_VEC_ELT (vec, i); + tree lab = CASE_LABEL (elt); basic_block label_bb = label_to_block (lab); - record_switch_edge (find_edge (e->src, label_bb), TREE_VEC_ELT (vec, i)); + edge this_edge = find_edge (e->src, label_bb); + + /* Add it to the chain of CASE_LABEL_EXPRs referencing E, or create + a new chain. */ + slot = pointer_map_insert (edge_to_cases, this_edge); + TREE_CHAIN (elt) = (tree) *slot; + *slot = elt; } - goto restart; + + return (tree) *pointer_map_contains (edge_to_cases, e); } /* Create the edges for a SWITCH_EXPR starting at block BB. |