mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-10 07:04:27 +08:00
5e0c54e514
* hashtable.h (struct ht_identifier): Add data member "hash_value". * hashtable.c (ht_lookup): Use it when searching, remember. (ht_expand): Do not recompute. * tree.h (IDENTIFIER_HASH_VALUE): New macro. cp/ * cp-tree.h (struct lang_type_class): Replace data member tags with hash-table nested_udts. (CLASSTYPE_NESTED_UTDS): Rename from CLASSTYPE_TAGS. * class.c (unreverse_member_declarations): Don't touch CLASSTYPE_TAGS. (pushclass): Use cxx_remember_type_decls. * decl.c (struct cp_binding_level): Replace data member tags with hash-table type_decls. (pop_binding_level): Handle level->type_decls. (kept_level_p): Adjust. (poplevel): Remove unused local variable. (bt_print_entry): New function. (print_binding_level): Use it. (push_namespace): Build current_binding_level->type_decls. (maybe_process_template_type_declaration): Adjust. (pushtag): Likewise. (clear_anon_tags): Use binding_table_remove_anonymous_types. (gettags): Remove. (cxx_remember_type_decls): Rename from storetags. Adjust. (lookup_tag): Use binding_table_find_anon_type. Tidy. (lookup_tag_reverse): Use binding_table_reverse_maybe_remap. (cxx_init_decl_processing): Build global_binding_level->type_decls. (store_parm_decls): Remove pointless code. * name-lookup.c (free_binding_entry): New variable. (ENTRY_INDEX): New macro. (struct binding_table_s): New datatype. (binding_entry_make): New function. (binding_entry_free): Likewise. (binding_table_construct): Likewise. (binding_table_free): Likewise. (binding_table_new): Likewise. (binding_table_expand): Likewise. (binding_table_insert): Likewise. (binding_table_find): Likewise. (binding_table_find_anon_type): Likewise. (binding_table_reverse_maybe_remap): Likewise. (binding_table_remove_anonymous_types): Likewise. (binding_table_foreach): Likewise. * name-lookup.h (binding_table): New type. (binding_entry): Likewise. (bt_foreach_proc): Likewise. (struct binding_entry_s): New datatype. (SCOPE_DEFAULT_HT_SIZE): New macro. (CLASS_SCOPE_HT_SIZE): Likewise. (NAMESPACE_ORDINARY_HT_SIZE): Likewise. (NAMESPACE_STD_HT_SIZE): Likewise. (GLOBAL_SCOPE_HT_SIZE): Likewise. (binding_table_new): Declare. (binding_table_free): Likewise. (binding_table_insert): Likewise. (binding_table_find_anon_type): Likewise. (binding_table_reverse_maybe_remap): Likewise. (binding_table_remove_anonymous_types): Likewise. (binding_table_foreach): Likewise. (binding_table_find): Likewise. (cxx_remember_type_decls): Likewise. * pt.c (bt_instantiate_type_proc): New function. (do_type_instantiation): Use it. * search.c (lookup_field_r): Use binding_table_find. From-SVN: r66930
85 lines
2.7 KiB
C
85 lines
2.7 KiB
C
/* Hash tables.
|
|
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
#ifndef GCC_HASHTABLE_H
|
|
#define GCC_HASHTABLE_H
|
|
|
|
#include "obstack.h"
|
|
|
|
/* This is what each hash table entry points to. It may be embedded
|
|
deeply within another object. */
|
|
typedef struct ht_identifier ht_identifier;
|
|
struct ht_identifier GTY(())
|
|
{
|
|
const unsigned char *str;
|
|
unsigned int len;
|
|
unsigned int hash_value;
|
|
};
|
|
|
|
#define HT_LEN(NODE) ((NODE)->len)
|
|
#define HT_STR(NODE) ((NODE)->str)
|
|
|
|
typedef struct ht hash_table;
|
|
typedef struct ht_identifier *hashnode;
|
|
|
|
enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC, HT_ALLOCED};
|
|
|
|
/* An identifier hash table for cpplib and the front ends. */
|
|
struct ht
|
|
{
|
|
/* Identifiers are allocated from here. */
|
|
struct obstack stack;
|
|
|
|
hashnode *entries;
|
|
/* Call back. */
|
|
hashnode (*alloc_node) PARAMS ((hash_table *));
|
|
|
|
unsigned int nslots; /* Total slots in the entries array. */
|
|
unsigned int nelements; /* Number of live elements. */
|
|
|
|
/* Link to reader, if any. For the benefit of cpplib. */
|
|
struct cpp_reader *pfile;
|
|
|
|
/* Table usage statistics. */
|
|
unsigned int searches;
|
|
unsigned int collisions;
|
|
};
|
|
|
|
/* Initialize the hashtable with 2 ^ order entries. */
|
|
extern hash_table *ht_create PARAMS ((unsigned int order));
|
|
|
|
/* Frees all memory associated with a hash table. */
|
|
extern void ht_destroy PARAMS ((hash_table *));
|
|
|
|
extern hashnode ht_lookup PARAMS ((hash_table *, const unsigned char *,
|
|
unsigned int, enum ht_lookup_option));
|
|
|
|
/* For all nodes in TABLE, make a callback. The callback takes
|
|
TABLE->PFILE, the node, and a PTR, and the callback sequence stops
|
|
if the callback returns zero. */
|
|
typedef int (*ht_cb) PARAMS ((struct cpp_reader *, hashnode, const void *));
|
|
extern void ht_forall PARAMS ((hash_table *, ht_cb, const void *));
|
|
|
|
/* Dump allocation statistics to stderr. */
|
|
extern void ht_dump_statistics PARAMS ((hash_table *));
|
|
|
|
/* Approximate positive square root of a host double. This is for
|
|
statistical reports, not code generation. */
|
|
extern double approx_sqrt PARAMS ((double));
|
|
|
|
#endif /* GCC_HASHTABLE_H */
|