From patchwork Tue Mar 13 17:01:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 146448 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C8422B6EF1 for ; Wed, 14 Mar 2012 04:01:50 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332262911; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:To:Subject:Message-Id:Date: From:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=9/fOPR6 Bf2dq9uKPXRrOgOy46Gc=; b=LQLMuZy8dCpt2kMouT4g6QtEZQaZ287ucSazOqM N/M0G0N4gwAJJrhkdNFRIVhYulPhNL0PC8ioAqdgHg3NxH+62wevVcH6Ld/yTcGz 3aX1yi9EUWwIuVQljvjuZyjHpgEMaPh1aUu+eh1j/E2pSU+iYGGjL+Vv8qP/gLN3 Ilmk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:Received:Received:To:Subject:Message-Id:Date:From:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=MAOC7FKDTfyh94VBNBlzRjymesBgVLCcX7lZM0ltwClRalYcnhTnhXrIBYx15k 3FMdjdW6WslvqIxJz/ffbkqV71l/Ytp5krNIWHTFvLtzosu+vX8CLAYrqPoLzW6z Ua8ROeONCuqFnXY4eGa2P8ADVdqMunzSQYddBJOgPQZRs=; Received: (qmail 23572 invoked by alias); 13 Mar 2012 17:01:43 -0000 Received: (qmail 23232 invoked by uid 22791); 13 Mar 2012 17:01:38 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, TW_SV, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yx0-f201.google.com (HELO mail-yx0-f201.google.com) (209.85.213.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Mar 2012 17:01:22 +0000 Received: by yenm6 with SMTP id m6so111385yen.2 for ; Tue, 13 Mar 2012 10:01:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=l1MyAiWjdXztT/QCQuddT0nnx5du2e4+1HbJ6LBUefU=; b=Pd3LCZgROCbGa3OT24udrQ30MzFxWJOo6AnqwPn8G0Qy549Q2+JVW4sB+MqKp2RLvX ZRtn7AYxrdTs6UxcPvtRd0h6e/6xJKoOhSo6nEJI5tkiWWzxKYQR51hqvOqa9f9E+LFn 9HbVQE8phaDz+MD0BLHRBW8GH/djKOP0+LNZMdKCkCsEewRR/TKyF5xGRgODXlakCcuI DZJErxt4q9BwHNhuBsAI9LOPgyp9TL8L4nXpgSNXGGIv54LuGgso3n49x5Iv1IOxH9S+ HlBGwx/WvC8955DdxIQF3wZtZnor6zA0+3AGsw4RlutgKpGX+F1eiMgaNjf/C/yfqGfV Wp7w== Received: by 10.101.136.30 with SMTP id o30mr4049628ann.14.1331658082141; Tue, 13 Mar 2012 10:01:22 -0700 (PDT) Received: by 10.101.136.30 with SMTP id o30mr4049612ann.14.1331658081963; Tue, 13 Mar 2012 10:01:21 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id b7si598142yhm.1.2012.03.13.10.01.21 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 13 Mar 2012 10:01:21 -0700 (PDT) Received: from tobiano.tor.corp.google.com (tobiano.tor.corp.google.com [172.29.41.6]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id BDD581E004D; Tue, 13 Mar 2012 10:01:21 -0700 (PDT) Received: by tobiano.tor.corp.google.com (Postfix, from userid 54752) id 18F19AE1E4; Tue, 13 Mar 2012 13:01:20 -0400 (EDT) To: reply@codereview.appspotmail.com, crowl@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Do not emit callgraph nodes to PPH images [1/2] (issue5803043) Message-Id: <20120313170121.18F19AE1E4@tobiano.tor.corp.google.com> Date: Tue, 13 Mar 2012 13:01:20 -0400 (EDT) From: dnovillo@google.com (Diego Novillo) X-Gm-Message-State: ALoCoQnnf9m9AgDjIaOFdoSoCBv9FUw7uBgzVv7gwIIgPYsmW8SA35hx3mhIyHuIclU0FBiU/hKuDfut6Gju5aemdJBI04OfLxOpRJskEVk0byW9CvHg4UUWNzw0DQFcSH94KfvXZMqKgMc7LdbtPMpqfi8mciwYS3ILOO/ppuILnpS7zIoEuDs= X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Part 1: Add more trees to the preloaded tree cache. This prevents more common trees, built at compiler initialization time, to be streamed out to PPH images. These trees are in: - type_hash_table: The private hash table used in tree.c to record canonical types. To avoid exposing this table out of tree.c, I added a traversal routine with a callback argument (type_hash_table_traverse). - Builtin types registered with record_builtin_type. I added a routine pph_register_builtin_type that is called for every builtin type. We later record those types in pph_cache_preload. Another piece of private state that needs to be written out is canonical_template_parms and nonstandard_integer_type_cache. I added writer and reader routines to pt.c to do deal with canonical_template_parms and traversal+callback iterators in tree.c to deal with nonstandard_integer_type_cache (to avoid middle-end routines to have to know about PPH). 2012-03-13 Diego Novillo cp/ChangeLog.pph * decl.c (record_builtin_type): Call pph_register_builtin_type. * pph-core.c (pph_cache_add_full_tree_r): New. (pph_cache_add_full_tree): New. (nitc_callback): New. (pph_builtin_types): Declare. (pph_register_builtin_type): New. (pph_cache_add_builtin_types): New. (pph_cache_add_canonical_type): New. (pph_cache_preload): Call pph_cache_add_full_tree instead of pph_cache_add. Call traverse_nonstandard_integer_type_cache with nitc_callback. Call pph_cache_add_builtin_types. Call type_hash_table_traverse. * pph-in.c (pph_in_tcc_type): Read TYP_NEXT_PTR_TO for POINTER_TYPE types. (pph_read_file_1): Call pph_in_canonical_template_parms. * pph-out.c (pph_out_tcc_type): Write TYPE_NEXT_PTR_TO for POINTER_TYPE types. (pph_write_file): Call pph_out_canonical_template_parms. * pph.h (pph_register_builtin_type): Declare. (pph_out_canonical_template_parms): Declare. (pph_in_canonical_template_parms): Declare. * pt.c (pph_out_canonical_template_parms): New. (pph_in_canonical_template_parms): New. ChangeLog.pph * tree.c (type_hash_traverse): Declare. (type_hash_table_retrieve_entry): New. (type_hash_table_traverse): New. (type_hash_table_length): New. (CACHED_PREC_LEN): Factor out of ... (nonstandard_integer_type_cache): ... here. (traverse_nonstandard_integer_type_cache): New. * tree.h (type_hash_table_traverse): Declare. (type_hash_table_length): Declare. (traverse_nonstandard_integer_type_cache): Declare. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@185344 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.pph | 13 ++++++ gcc/cp/ChangeLog.pph | 27 +++++++++++++ gcc/cp/decl.c | 6 +++ gcc/cp/pph-core.c | 106 +++++++++++++++++++++++++++++++++++++++++++------- gcc/cp/pph-in.c | 14 +++++-- gcc/cp/pph-out.c | 12 ++++- gcc/cp/pph.h | 5 ++ gcc/cp/pt.c | 31 +++++++++++++++ gcc/tree.c | 67 +++++++++++++++++++++++++++++++- gcc/tree.h | 4 ++ 10 files changed, 263 insertions(+), 22 deletions(-) diff --git a/gcc/ChangeLog.pph b/gcc/ChangeLog.pph index d95c153..2bf6c9a 100644 --- a/gcc/ChangeLog.pph +++ b/gcc/ChangeLog.pph @@ -1,5 +1,18 @@ 2012-03-04 Diego Novillo + * tree.c (type_hash_traverse): Declare. + (type_hash_table_retrieve_entry): New. + (type_hash_table_traverse): New. + (type_hash_table_length): New. + (CACHED_PREC_LEN): Factor out of ... + (nonstandard_integer_type_cache): ... here. + (traverse_nonstandard_integer_type_cache): New. + * tree.h (type_hash_table_traverse): Declare. + (type_hash_table_length): Declare. + (traverse_nonstandard_integer_type_cache): Declare. + +2012-03-04 Diego Novillo + Merge from trunk rev 184817. BASE-VER: Update to 4.8.0-pph. diff --git a/gcc/cp/ChangeLog.pph b/gcc/cp/ChangeLog.pph index c867ca3..697ae2b 100644 --- a/gcc/cp/ChangeLog.pph +++ b/gcc/cp/ChangeLog.pph @@ -1,3 +1,30 @@ +2012-03-13 Diego Novillo + + * decl.c (record_builtin_type): Call pph_register_builtin_type. + * pph-core.c (pph_cache_add_full_tree_r): New. + (pph_cache_add_full_tree): New. + (nitc_callback): New. + (pph_builtin_types): Declare. + (pph_register_builtin_type): New. + (pph_cache_add_builtin_types): New. + (pph_cache_add_canonical_type): New. + (pph_cache_preload): Call pph_cache_add_full_tree instead of + pph_cache_add. + Call traverse_nonstandard_integer_type_cache with nitc_callback. + Call pph_cache_add_builtin_types. + Call type_hash_table_traverse. + * pph-in.c (pph_in_tcc_type): Read TYP_NEXT_PTR_TO for + POINTER_TYPE types. + (pph_read_file_1): Call pph_in_canonical_template_parms. + * pph-out.c (pph_out_tcc_type): Write TYPE_NEXT_PTR_TO for + POINTER_TYPE types. + (pph_write_file): Call pph_out_canonical_template_parms. + * pph.h (pph_register_builtin_type): Declare. + (pph_out_canonical_template_parms): Declare. + (pph_in_canonical_template_parms): Declare. + * pt.c (pph_out_canonical_template_parms): New. + (pph_in_canonical_template_parms): New. + 2012-03-09 Lawrence Crowl * name-lookup.c (pph_out_binding_table): Correct comment. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 279a9ab..ab2b7d2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3436,6 +3436,12 @@ record_builtin_type (enum rid rid_index, if (tdecl) debug_hooks->type_decl (tdecl, 0); + + /* When using pre-parsed headers, we register builtin types in the PPH + pickle cache to avoid writing a physical representation of these types + and make sure that all references resolve to the same pre-built type. */ + if (pph_enabled_p ()) + pph_register_builtin_type (type); } /* Record one of the standard Java types. diff --git a/gcc/cp/pph-core.c b/gcc/cp/pph-core.c index 464f39f..8c79017 100644 --- a/gcc/cp/pph-core.c +++ b/gcc/cp/pph-core.c @@ -472,6 +472,82 @@ pph_cache_init (pph_cache *cache) static pph_cache *pph_preloaded_cache; +/* Callback for cp_walk_tree. Called from pph_cache_add_full_tree. + Add the sub-tree *TP to the cache pointed to by DATA. Always set + WALK_SUBTREES to 1 to traverse every sub-tree. */ + +static tree +pph_cache_add_full_tree_r (tree *tp, int *walk_subtrees, void *data) +{ + pph_cache *cache = (pph_cache *) data; + pph_cache_add (cache, *tp, NULL, pph_tree_code_to_tag (*tp)); + *walk_subtrees = 1; + return NULL; +} + + +/* Add tree T and all its children into CACHE. */ + +static void +pph_cache_add_full_tree (pph_cache *cache, tree t) +{ + cp_walk_tree (&t, pph_cache_add_full_tree_r, cache, NULL); +} + + +/* Callback for traverse_nonstandard_integer_type_cache. Add the + full tree TYPE to the cache pointed by DATA. */ + +static bool +nitc_callback (tree type, void *data) +{ + pph_cache *cache = (pph_cache *) data; + pph_cache_add_full_tree (cache, type); + return true; +} + +/* Vector of builtin types to register in the preloaded cache. */ +static VEC(tree,gc) *pph_builtin_types; + + +/* Register a builtin type to be preloaded when we are setting up the + pickle cache. This is called from record_builtin_type. */ + +void +pph_register_builtin_type (tree type) +{ + VEC_safe_push (tree, gc, pph_builtin_types, type); +} + + +/* Pre-load all the builtin types declared by the compiler. */ + +static void +pph_cache_add_builtin_types (pph_cache *cache) +{ + unsigned i; + tree type; + + FOR_EACH_VEC_ELT (tree, pph_builtin_types, i, type) + pph_cache_add_full_tree (cache, type); +} + + +/* Callback for type_hash_table_traverse. DATA points to the cache + where we are preloading trees built by the front end on startup. + TYPE is the type to preload. Always return true, so we visit the + whole table. */ + +static bool +pph_cache_add_canonical_type (unsigned long h ATTRIBUTE_UNUSED, tree type, + void *data) +{ + pph_cache *cache = (pph_cache *) data; + pph_cache_add_full_tree (cache, type); + return true; +} + + /* Pre-load common tree nodes into CACHE. These nodes are always built by the front end, so there is no need to pickle them. */ @@ -481,24 +557,20 @@ pph_cache_preload (pph_cache *cache) unsigned i; for (i = itk_char; i < itk_none; i++) - pph_cache_add (cache, integer_types[i], NULL, - pph_tree_code_to_tag (integer_types[i])); + pph_cache_add_full_tree (cache, integer_types[i]); for (i = 0; i < TYPE_KIND_LAST; i++) - pph_cache_add (cache, sizetype_tab[i], NULL, - pph_tree_code_to_tag (sizetype_tab[i])); + pph_cache_add_full_tree (cache, sizetype_tab[i]); /* global_trees[] can have NULL entries in it. Skip them. */ for (i = 0; i < TI_MAX; i++) if (global_trees[i]) - pph_cache_add (cache, global_trees[i], NULL, - pph_tree_code_to_tag (global_trees[i])); + pph_cache_add_full_tree (cache, global_trees[i]); /* c_global_trees[] can have NULL entries in it. Skip them. */ for (i = 0; i < CTI_MAX; i++) if (c_global_trees[i]) - pph_cache_add (cache, c_global_trees[i], NULL, - pph_tree_code_to_tag (c_global_trees[i])); + pph_cache_add_full_tree (cache, c_global_trees[i]); /* cp_global_trees[] can have NULL entries in it. Skip them. */ for (i = 0; i < CPTI_MAX; i++) @@ -508,16 +580,22 @@ pph_cache_preload (pph_cache *cache) continue; if (cp_global_trees[i]) - pph_cache_add (cache, cp_global_trees[i], NULL, - pph_tree_code_to_tag (cp_global_trees[i])); + pph_cache_add_full_tree (cache, cp_global_trees[i]); } + /* Pre-load the table of nonstandard integer types. */ + traverse_nonstandard_integer_type_cache (nitc_callback, (void *) cache); + + /* Pre-load all the builtin types. */ + pph_cache_add_builtin_types (cache); + + /* Pre-load the table of canonical types. */ + type_hash_table_traverse (pph_cache_add_canonical_type, cache); + /* Add other well-known nodes that should always be taken from the current compilation context. */ - pph_cache_add (cache, global_namespace, NULL, - pph_tree_code_to_tag (global_namespace)); - pph_cache_add (cache, DECL_CONTEXT (global_namespace), NULL, - pph_tree_code_to_tag (DECL_CONTEXT (global_namespace))); + pph_cache_add_full_tree (cache, global_namespace); + pph_cache_add_full_tree (cache, DECL_CONTEXT (global_namespace)); } diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index caa90c8..12685a9 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -1959,12 +1959,13 @@ pph_in_tcc_type (pph_stream *stream, tree type) { TYPE_LANG_SPECIFIC (type) = pph_in_lang_type (stream); TYPE_POINTER_TO (type) = pph_in_tree (stream); + if (TREE_CODE (type) == POINTER_TYPE) + TYPE_NEXT_PTR_TO (type) = pph_in_tree (stream); TYPE_REFERENCE_TO (type) = pph_in_tree (stream); TYPE_NEXT_VARIANT (type) = pph_in_tree (stream); SET_TYPE_MODE (type, pph_in_machine_mode (stream)); - /* FIXME pph - Streaming TYPE_CANONICAL generates many type comparison - failures. Why? */ - /* FIXME pph: apparently redundant. */ + /* We do not read TYPE_CANONICAL. Instead, we emit the table of + canonical types and re-instantiate it on read. */ TREE_CHAIN (type) = pph_in_tree (stream); /* The type values cache is built as constants are instantiated, @@ -3255,7 +3256,12 @@ pph_read_file_1 (pph_stream *stream) static_aggregates = chainon (file_static_aggregates, static_aggregates); pph_in_decl2_hidden_state (stream); - /* Read and process the symbol table. */ + pph_in_canonical_template_parms (stream); + + /* Read and process the symbol table. This must be done at the end + because we have symbols coming in from children PPH images which + must be instantiated in the same order they were instantiated by + the original parser. */ pph_in_symtab (stream); if (flag_pph_dump_tree) diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c index 3a56b93..c817f22 100644 --- a/gcc/cp/pph-out.c +++ b/gcc/cp/pph-out.c @@ -1859,11 +1859,13 @@ pph_out_tcc_type (pph_stream *stream, tree type) { pph_out_lang_type (stream, type); pph_out_tree (stream, TYPE_POINTER_TO (type)); + if (TREE_CODE (type) == POINTER_TYPE) + pph_out_tree (stream, TYPE_NEXT_PTR_TO (type)); pph_out_tree (stream, TYPE_REFERENCE_TO (type)); pph_out_tree (stream, TYPE_NEXT_VARIANT (type)); pph_out_machine_mode (stream, TYPE_MODE (type)); - /* FIXME pph - Streaming TYPE_CANONICAL generates many type comparison - failures. Why? */ + /* We do not write TYPE_CANONICAL. Instead, we emit the table of + canonical types and re-instantiate it on read. */ pph_out_tree (stream, TREE_CHAIN (type)); /* The type values cache is built as constants are instantiated, @@ -2721,7 +2723,11 @@ pph_write_file (pph_stream *stream) pph_out_tree (stream, static_aggregates); pph_out_decl2_hidden_state (stream); - /* Emit the symbol table. */ + pph_out_canonical_template_parms (stream); + + /* Emit the symbol table. The symbol table must be emitted at the + end because all the symbols read from children PPH images are not + known in advance when we start reading this file in the reader. */ pph_out_symtab (stream); if (flag_pph_dump_tree) diff --git a/gcc/cp/pph.h b/gcc/cp/pph.h index e864978..c6ec227 100644 --- a/gcc/cp/pph.h +++ b/gcc/cp/pph.h @@ -147,6 +147,7 @@ extern void pph_dump_tree_name (FILE *file, tree t, int flags); extern void pph_dump_vec_tree (FILE *file, VEC(tree,gc) *v); extern void pph_init_include_tree (void); extern void pph_dump_includes (FILE *, pph_stream *, unsigned); +extern void pph_register_builtin_type (tree); /* In pph-out.c. */ extern void pph_out_uint (pph_stream *stream, unsigned int value); @@ -189,6 +190,10 @@ extern void pph_out_merge_key_template_state (pph_stream *); extern void pph_out_merge_body_template_state (pph_stream *); extern void pph_in_merge_key_template_state (pph_stream *); extern void pph_in_merge_body_template_state (pph_stream *); +extern void pph_out_spec_entry_tables (pph_stream *); +extern void pph_in_spec_entry_tables (pph_stream *); +extern void pph_out_canonical_template_parms (pph_stream *); +extern void pph_in_canonical_template_parms (pph_stream *); /* FIXME pph: These functions should be moved to tree.c on merge. */ extern VEC(tree,heap) *chain2vec (tree chain); /* In pph-out.c. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9018237..7758dfe25 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3472,6 +3472,37 @@ canonical_type_parameter (tree type) } } + +/* Write the canonical type parameter table to STREAM. */ + +void +pph_out_canonical_template_parms (pph_stream *stream) +{ + tree type; + unsigned i; + + pph_out_uint (stream, VEC_length (tree, canonical_template_parms)); + FOR_EACH_VEC_ELT (tree, canonical_template_parms, i, type) + pph_out_tree (stream, type); +} + + +/* Read the canonical type parameter table from STREAM. */ + +void +pph_in_canonical_template_parms (pph_stream *stream) +{ + unsigned i, len; + + len = pph_in_uint (stream); + for (i = 0; i < len; i++) + { + tree parm = pph_in_tree (stream); + VEC_safe_push (tree, gc, canonical_template_parms, parm); + } +} + + /* Return a TEMPLATE_PARM_INDEX, similar to INDEX, but whose TEMPLATE_PARM_LEVEL has been decreased by LEVELS. If such a TEMPLATE_PARM_INDEX already exists, it is returned; otherwise, a diff --git a/gcc/tree.c b/gcc/tree.c index 2eac37b..89bb013 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -6293,6 +6293,52 @@ type_hash_canon (unsigned int hashcode, tree type) } } +/* Data structure used to pass data to the htab_traverse callback used + in type_hash_table_traverse. */ +struct type_hash_traverse { + bool (*callback) (unsigned long, tree, void *); + void *data; +}; + +/* Helper for type_hash_table_traverse. Retrieve a type hash table element and + call FN with it. Pass DATA as an argument to FN. If FN returns false, + traversal is stopped. */ + +static int +type_hash_table_retrieve_entry (void **slot, void *data) +{ + struct type_hash *h = (struct type_hash *) *slot; + struct type_hash_traverse *e = (struct type_hash_traverse *) data; + return (e->callback (h->hash, h->type, e->data)) ? 1 : 0; +} + + +/* Walk the type hash table, calling function CALLBACK with every element. + CALLBACK receives three arguments: + unsigned long representing the hash value + tree the type with that hash value + data a void * to arbitrary data used by CALLBACK. */ + +void +type_hash_table_traverse (bool (*callback) (unsigned long, tree, void *), + void *data) +{ + struct type_hash_traverse e; + e.callback = callback; + e.data = data; + htab_traverse (type_hash_table, type_hash_table_retrieve_entry, &e); +} + + +/* Return the number of types in the type hash table. */ + +size_t +type_hash_table_length (void) +{ + return htab_elements (type_hash_table); +} + + /* See if the data pointed to by the type hash table is marked. We consider it marked if the type is marked or if a debug type number or symbol table entry has been made for the type. */ @@ -7212,7 +7258,8 @@ build_type_no_quals (tree t) #define MAX_INT_CACHED_PREC \ (HOST_BITS_PER_WIDE_INT > 64 ? HOST_BITS_PER_WIDE_INT : 64) -static GTY(()) tree nonstandard_integer_type_cache[2 * MAX_INT_CACHED_PREC + 2]; +#define CACHED_PREC_LEN (2 * MAX_INT_CACHED_PREC + 2) +static GTY(()) tree nonstandard_integer_type_cache[CACHED_PREC_LEN]; /* Builds a signed or unsigned integer type of precision PRECISION. Used for C bitfields whose precision does not match that of @@ -7250,6 +7297,24 @@ build_nonstandard_integer_type (unsigned HOST_WIDE_INT precision, return ret; } + +/* Walk nonstandard_integer_type_cache, calling CALLBACK on every non-NULL + entry. CALLBACK is called with the current tree and DATA. If + CALLBACK returns false, the walk is aborted. */ + +void +traverse_nonstandard_integer_type_cache (bool (*callback) (tree, void *), + void *data) +{ + size_t i; + + for (i = 0; i < CACHED_PREC_LEN; i++) + if (nonstandard_integer_type_cache[i]) + if (!callback (nonstandard_integer_type_cache[i], data)) + return; +} + + /* Create a range of some discrete type TYPE (an INTEGER_TYPE, ENUMERAL_TYPE or BOOLEAN_TYPE) with low bound LOWVAL and high bound HIGHVAL. If SHARED is true, reuse such a type that has already been constructed. */ diff --git a/gcc/tree.h b/gcc/tree.h index b269ee4..5e61992 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -5190,6 +5190,10 @@ extern void assign_assembler_name_if_neeeded (tree); extern void warn_deprecated_use (tree, tree); enum tree_node_structure_enum tree_node_structure_for_code (enum tree_code); void mark_ts_structures_for (enum tree_code, enum tree_node_structure_enum); +void type_hash_table_traverse (bool (*) (unsigned long, tree, void *), void *); +size_t type_hash_table_length (void); +void traverse_nonstandard_integer_type_cache (bool (*callback) (tree, void *), + void *); /* In cgraph.c */