diff options
author | Richard Guenther <rguenther@suse.de> | 2008-02-25 15:10:34 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-02-25 15:10:34 +0000 |
commit | 7660c722d9ed749ad84a919169ad55cf3b30f102 (patch) | |
tree | 3d477af05abfc59dd9e5d4b0fe342069f48c796f /gcc/tree.c | |
parent | 2e4e39f615dacf0dbc8b02db27b1046f849c731d (diff) | |
download | gcc-7660c722d9ed749ad84a919169ad55cf3b30f102.zip gcc-7660c722d9ed749ad84a919169ad55cf3b30f102.tar.gz gcc-7660c722d9ed749ad84a919169ad55cf3b30f102.tar.bz2 |
tree-flow.h (uid_decl_map_hash, [...]): Move ...
2008-02-25 Richard Guenther <rguenther@suse.de>
* tree-flow.h (uid_decl_map_hash, uid_decl_map_eq): Move ...
* tree.h (uid_decl_map_hash, uid_decl_map_eq): ... here.
(lookup_decl_from_uid): Declare.
* tree-ssa.c (uid_decl_map_eq, uid_decl_map_hash): Move ...
* tree.c (uid_decl_map_eq, uid_decl_map_hash): ... here.
(decl_for_uid_map): New global hashtable mapping DECL_UID
to the decl tree.
(init_ttree): Allocate it.
(insert_decl_to_uid_decl_map): New helper function.
(make_node_stat): Insert new decls into the map.
(copy_node_stat): Likewise.
(lookup_decl_from_uid): New function.
(print_decl_for_uid_map_statistics): New helper.
(dump_tree_statistics): Call it.
* tree-flow.h (struct gimple_df): Make referenced_vars a bitmap.
(referenced_var_iterator): Adjust.
(FOR_EACH_REFERENCED_VAR): Adjust.
(FOR_EACH_REFERENCED_VAR_IN_BITMAP): New iterator.
(num_referenced_vars): Adjust.
* tree-flow-inline.h (gimple_referenced_vars): Adjust.
(first_referenced_var): Remove.
(end_referenced_vars_p): Likewise.
(next_referenced_var): Likewise.
(referenced_var_iterator_set): New helper function.
* tree-dfa.c (referenced_var_lookup): Adjust.
(referenced_var_check_and_insert): Likewise.
(remove_referenced_var): Likewise.
* tree-ssa.c (verify_flow_insensitive_alias_info): Use
FOR_EACH_REFERENCED_VAR_IN_BITMAP.
(verify_call_clobbering): Likewise.
(verify_memory_partitions): Likewise.
(init_tree_ssa): Allocate bitmap instead of hashtable for
referenced_vars.
(delete_tree_ssa): Adjust.
* tree-ssa-alias.c (mark_aliases_call_clobbered): Use
FOR_EACH_REFERENCED_VAR_IN_BITMAP.
(compute_tag_properties): Likewise.
(set_initial_properties): Likewise.
(find_partition_for): Likewise.
(update_reference_counts): Likewise.
(dump_may_aliases_for): Likewise.
* tree-ssa-operands.c (add_virtual_operand): Likewise.
(add_call_clobber_ops): Likewise.
(add_call_read_ops): Likewise.
(get_asm_expr_operands): Likewise.
* tree-into-ssa.c (dump_decl_set): Likewise.
(update_ssa): Likewise.
* tree-sra.c (scan_function): Likewise.
(decide_instantiations): Likewise.
(scalarize_parms): Likewise.
* tree-ssa-alias-warnings.c (build_reference_table): Likewise.
(dsa_named_for): Likewise.
* tree-ssa-structalias.c (update_alias_info): Likewise.
(merge_smts_into): Likewise.
From-SVN: r132629
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 76 |
1 files changed, 76 insertions, 0 deletions
@@ -110,6 +110,12 @@ static GTY(()) int next_decl_uid; /* Unique id for next type created. */ static GTY(()) int next_type_uid = 1; +/* Mapping from unique DECL_UID to the decl tree node. */ +static GTY ((if_marked ("ggc_marked_p"), param_is (union tree_node))) + htab_t decl_for_uid_map; + +static void insert_decl_to_uid_decl_map (tree); + /* Since we cannot rehash a type after it is in the table, we have to keep the hash code. */ @@ -231,6 +237,9 @@ init_ttree (void) int_cst_node = make_node (INTEGER_CST); + decl_for_uid_map = htab_create_ggc (4093, uid_decl_map_hash, + uid_decl_map_eq, NULL); + tree_contains_struct[FUNCTION_DECL][TS_DECL_NON_COMMON] = 1; tree_contains_struct[TRANSLATION_UNIT_DECL][TS_DECL_NON_COMMON] = 1; tree_contains_struct[TYPE_DECL][TS_DECL_NON_COMMON] = 1; @@ -601,6 +610,7 @@ make_node_stat (enum tree_code code MEM_STAT_DECL) } DECL_SOURCE_LOCATION (t) = input_location; DECL_UID (t) = next_decl_uid++; + insert_decl_to_uid_decl_map (t); break; @@ -704,6 +714,7 @@ copy_node_stat (tree node MEM_STAT_DECL) SET_DECL_RESTRICT_BASE (t, DECL_GET_RESTRICT_BASE (node)); DECL_BASED_ON_RESTRICT_P (t) = 1; } + insert_decl_to_uid_decl_map (t); } else if (TREE_CODE_CLASS (code) == tcc_type) { @@ -3325,6 +3336,70 @@ build_nt_call_list (tree fn, tree arglist) return t; } +/* Return true if the DECL_UID in both trees are equal. */ + +int +uid_decl_map_eq (const void *va, const void *vb) +{ + const_tree a = (const_tree) va; + const_tree b = (const_tree) vb; + return (a->decl_minimal.uid == b->decl_minimal.uid); +} + +/* Hash a tree in a uid_decl_map. */ + +unsigned int +uid_decl_map_hash (const void *item) +{ + return ((const_tree)item)->decl_minimal.uid; +} + +/* Insert the declaration NODE into the map mapping its unique uid + back to the tree. */ + +static void +insert_decl_to_uid_decl_map (tree node) +{ + void **slot; + struct tree_decl_minimal key; + + key.uid = DECL_UID (node); + slot = htab_find_slot_with_hash (decl_for_uid_map, + &key, DECL_UID (node), INSERT); + + /* We should never try to re-insert a decl with the same uid. + ??? The C++ frontend breaks this invariant. Hopefully in a + non-fatal way, so just overwrite the slot in this case. */ +#if 0 + gcc_assert (!*slot); +#endif + + *(tree *)slot = node; +} + +/* Lookup the declaration tree from its unique DECL_UID UID. Returns + the tree node with DECL_UID UID or NULL, if this node was collected. */ + +tree +lookup_decl_from_uid (int uid) +{ + struct tree_decl_minimal key; + + key.uid = uid; + return (tree) htab_find_with_hash (decl_for_uid_map, &key, uid); +} + +/* Print out the statistics for the decl_for_uid_map hash table. */ + +static void +print_decl_for_uid_map_statistics (void) +{ + fprintf (stderr, "DECL_FOR_UID_MAP hash: size %ld, %ld elements, %f collisions\n", + (long) htab_size (decl_for_uid_map), + (long) htab_elements (decl_for_uid_map), + htab_collisions (decl_for_uid_map)); +} + /* Create a DECL_... node of code CODE, name NAME and data type TYPE. We do NOT enter this node in any sort of symbol table. @@ -6654,6 +6729,7 @@ dump_tree_statistics (void) print_debug_expr_statistics (); print_value_expr_statistics (); print_restrict_base_statistics (); + print_decl_for_uid_map_statistics (); lang_hooks.print_statistics (); } |