summaryrefslogtreecommitdiffstats
path: root/gcc/tree.c
diff options
context:
space:
mode:
authordberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-01 00:39:49 +0000
committerdberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-01 00:39:49 +0000
commit8bc1e6ff529ff25196f82b854b7e7fe252d0d029 (patch)
tree916b04dcdacaf7602bfac6975c23a7d34d9b5870 /gcc/tree.c
parentcc46fb3056cb2f7fc79241a57bd1c9240327dc52 (diff)
downloadppe42-gcc-8bc1e6ff529ff25196f82b854b7e7fe252d0d029.tar.gz
ppe42-gcc-8bc1e6ff529ff25196f82b854b7e7fe252d0d029.zip
2005-05-30 Daniel Berlin <dberlin@dberlin.org>
* c-objc-common.c (c_tree_printer): Check flag before hashtable. Use DECL_DEBUG_EXPR and SET_DECL_DEBUG_EXPR. * dwarf2out.c (dwarf2out_var_location): Ditto. * toplev.c (default_tree_printer): Ditto. * tree-outof-ssa.c (create_temp): Ditto. * tree-sra.c (instantiate_element): Ditto. * var-tracking.c (track_expr_p): Ditto. * tree.c (struct tree_map): New structure. (debug_expr_for_decl): New. (tree_map_eq): New function. (tree_map_hash): Ditto. (tree_map_marked_p): Ditto. (print_debug_expr_statistics): Ditto. (decl_debug_expr_lookup): Ditto. (decl_debug_expr_insert): Ditto. (dump_tree_statistics): Dump debug_expr hashtable stats. * tree.h (DECL_DEBUG_EXPR): Change (SET_DECL_DEBUG_EXPR): Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100417 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 133feb89881..b34d07c548f 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -131,19 +131,36 @@ static GTY (()) tree int_cst_node;
static GTY ((if_marked ("ggc_marked_p"), param_is (union tree_node)))
htab_t int_cst_hash_table;
+/* General tree->tree mapping structure for use in hash tables. */
+
+struct tree_map GTY(())
+{
+ hashval_t hash;
+ tree from;
+ tree to;
+};
+
+static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map)))
+ htab_t debug_expr_for_decl;
+
static void set_type_quals (tree, int);
static int type_hash_eq (const void *, const void *);
static hashval_t type_hash_hash (const void *);
+static int tree_map_eq (const void *, const void *);
+static hashval_t tree_map_hash (const void *);
static hashval_t int_cst_hash_hash (const void *);
static int int_cst_hash_eq (const void *, const void *);
static void print_type_hash_statistics (void);
+static void print_debug_expr_statistics (void);
static tree make_vector_type (tree, int, enum machine_mode);
static int type_hash_marked_p (const void *);
+static int tree_map_marked_p (const void *);
static unsigned int type_hash_list (tree, hashval_t);
static unsigned int attribute_hash_list (tree, hashval_t);
tree global_trees[TI_MAX];
tree integer_types[itk_none];
+
/* Init tree.c. */
@@ -153,9 +170,15 @@ init_ttree (void)
/* Initialize the hash table of types. */
type_hash_table = htab_create_ggc (TYPE_HASH_INITIAL_SIZE, type_hash_hash,
type_hash_eq, 0);
+
+ debug_expr_for_decl = htab_create_ggc (512, tree_map_hash,
+ tree_map_eq, 0);
+
int_cst_hash_table = htab_create_ggc (1024, int_cst_hash_hash,
int_cst_hash_eq, NULL);
+
int_cst_node = make_node (INTEGER_CST);
+
}
@@ -3430,6 +3453,76 @@ build_variant_type_copy (tree type)
return t;
}
+/* Return true if the from tree in both tree maps are equal. */
+
+static int
+tree_map_eq (const void *va, const void *vb)
+{
+ const struct tree_map *a = va, *b = vb;
+ return (a->from == b->from);
+}
+
+/* Hash a from tree in a tree_map. */
+
+static hashval_t
+tree_map_hash (const void *item)
+{
+ return (((const struct tree_map *) item)->hash);
+}
+
+/* Return true if this tree map structure is marked for garbage collection
+ purposes. We simply return true if the from tree is marked, so that this
+ structure goes away when the from tree goes away. */
+
+static int
+tree_map_marked_p (const void *p)
+{
+ tree from = ((struct tree_map *) p)->from;
+
+ return ggc_marked_p (from);
+}
+
+/* Print out the statistics for the DECL_DEBUG_EXPR hash table. */
+
+static void
+print_debug_expr_statistics (void)
+{
+ fprintf (stderr, "DECL_DEBUG_EXPR hash: size %ld, %ld elements, %f collisions\n",
+ (long) htab_size (debug_expr_for_decl),
+ (long) htab_elements (debug_expr_for_decl),
+ htab_collisions (debug_expr_for_decl));
+}
+
+/* Lookup a debug expression for FROM, and return it if we find one. */
+
+tree
+decl_debug_expr_lookup (tree from)
+{
+ struct tree_map *h, in;
+ in.from = from;
+
+ h = htab_find_with_hash (debug_expr_for_decl, &in, htab_hash_pointer (from));
+ if (h)
+ return h->to;
+ return NULL_TREE;
+}
+
+/* Insert a mapping FROM->TO in the debug expression hashtable. */
+
+void
+decl_debug_expr_insert (tree from, tree to)
+{
+ struct tree_map *h;
+ void **loc;
+
+ h = ggc_alloc (sizeof (struct tree_map));
+ h->hash = htab_hash_pointer (from);
+ h->from = from;
+ h->to = to;
+ loc = htab_find_slot_with_hash (debug_expr_for_decl, h, h->hash, INSERT);
+ *(struct tree_map **) loc = h;
+}
+
/* Hashing of types so that we don't make duplicates.
The entry point is `type_hash_canon'. */
@@ -5261,6 +5354,7 @@ dump_tree_statistics (void)
fprintf (stderr, "(No per-node statistics)\n");
#endif
print_type_hash_statistics ();
+ print_debug_expr_statistics ();
lang_hooks.print_statistics ();
}
OpenPOWER on IntegriCloud