aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2001-09-20 15:12:54 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2001-09-20 11:12:54 -0400
commit4c160717caf980303ced3d3f17ad0bfd7381f3b2 (patch)
tree9f82325d87e923ce9de88e1e1f44c7643f7d9c53 /gcc/tree.c
parentc762ab6ebb62bc1e1d93b6d81b83737e39df2c01 (diff)
downloadgcc-4c160717caf980303ced3d3f17ad0bfd7381f3b2.zip
gcc-4c160717caf980303ced3d3f17ad0bfd7381f3b2.tar.gz
gcc-4c160717caf980303ced3d3f17ad0bfd7381f3b2.tar.bz2
fold-const.c (hashtab.h): Include.
* fold-const.c (hashtab.h): Include. (int_const_binop): Remove FORSIZE arg and compute from type; all callers changed. Call size_int_type_wide for all single-word constants. (size_htab_hash, size_htab_eq): New functions. (size_int_type_wide): Rework to use hash table. * ggc-common.c (hashtab.h): Include. (struct d_htab_root): New struct. (d_htab_roots): New variable. (ggc_add_deletable_htab, ggc_htab_delete): New functions (ggc_mark_roots): Handle deletable htabs. * ggc-page.c (ggc_marked_p): New function. * ggc-simple.c (ggc_marked_p): Likewise. * ggc.h: Reformatting throughout. (ggc_marked_p, ggc_add_deletable_htab): New declarations. * tree.c (init_obstacks): Make type_hash_table a deletable root. (type_hash_add): Allocate struct type_hash from GC memory. (mark_hash_entry, mark_type_hash): Deleted. (type_hash_marked_p, type_hash_mark): New functions. * Makefile.in (ggc-common.o, fold-const.o): Include hashtab.h. From-SVN: r45710
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 14d4807..731791c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -158,12 +158,12 @@ htab_t type_hash_table;
static void build_real_from_int_cst_1 PARAMS ((PTR));
static void set_type_quals PARAMS ((tree, int));
static void append_random_chars PARAMS ((char *));
-static void mark_type_hash PARAMS ((void *));
static int type_hash_eq PARAMS ((const void*, const void*));
static unsigned int type_hash_hash PARAMS ((const void*));
static void print_type_hash_statistics PARAMS((void));
-static int mark_hash_entry PARAMS((void **, void *));
static void finish_vector_type PARAMS((tree));
+static int type_hash_marked_p PARAMS ((const void *));
+static void type_hash_mark PARAMS ((const void *));
static int mark_tree_hashtable_entry PARAMS((void **, void *));
/* If non-null, these are language-specific helper functions for
@@ -225,7 +225,8 @@ init_obstacks ()
/* Initialize the hash table of types. */
type_hash_table = htab_create (TYPE_HASH_INITIAL_SIZE, type_hash_hash,
type_hash_eq, 0);
- ggc_add_root (&type_hash_table, 1, sizeof type_hash_table, mark_type_hash);
+ ggc_add_deletable_htab (type_hash_table, type_hash_marked_p,
+ type_hash_mark);
ggc_add_tree_root (global_trees, TI_MAX);
ggc_add_tree_root (integer_types, itk_none);
@@ -3186,7 +3187,7 @@ type_hash_add (hashcode, type)
struct type_hash *h;
void **loc;
- h = (struct type_hash *) permalloc (sizeof (struct type_hash));
+ h = (struct type_hash *) ggc_alloc (sizeof (struct type_hash));
h->hash = hashcode;
h->type = type;
loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT);
@@ -3217,6 +3218,8 @@ type_hash_canon (hashcode, type)
if (debug_no_type_hash)
return type;
+ /* See if the type is in the hash table already. If so, return it.
+ Otherwise, add the type. */
t1 = type_hash_lookup (hashcode, type);
if (t1 != 0)
{
@@ -3226,37 +3229,29 @@ type_hash_canon (hashcode, type)
#endif
return t1;
}
-
- /* If this is a permanent type, record it for later reuse. */
- type_hash_add (hashcode, type);
-
- return type;
+ else
+ {
+ type_hash_add (hashcode, type);
+ return type;
+ }
}
-/* Callback function for htab_traverse. */
+/* See if the data pointed to by the type hash table is marked. */
static int
-mark_hash_entry (entry, param)
- void **entry;
- void *param ATTRIBUTE_UNUSED;
+type_hash_marked_p (p)
+ const void *p;
{
- struct type_hash *p = *(struct type_hash **) entry;
-
- ggc_mark_tree (p->type);
-
- /* Continue scan. */
- return 1;
+ return ggc_marked_p (((struct type_hash *) p)->type);
}
-/* Mark ARG (which is really a htab_t *) for GC. */
+/* Mark the entry in the type hash table the type it points to is marked. */
static void
-mark_type_hash (arg)
- void *arg;
+type_hash_mark (p)
+ const void *p;
{
- htab_t t = *(htab_t *) arg;
-
- htab_traverse (t, mark_hash_entry, 0);
+ ggc_mark (p);
}
/* Mark the hashtable slot pointed to by ENTRY (which is really a