diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-05-20 06:26:45 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-05-20 06:26:45 +0000 |
commit | 0d086e18124f6c6bed14a62f84d5a4265f1c7d9b (patch) | |
tree | 31a2cc3c54959e2908bad78e488472f5e3ce3d69 /gcc/hashtable.h | |
parent | b92c85dcf12a7c7474590b5d3b085c3b875ca36f (diff) | |
download | gcc-0d086e18124f6c6bed14a62f84d5a4265f1c7d9b.tar.gz |
* Makefile.in (OBJS, LIBCPP_OBJS, LIBCPP_DEPS,
cpplib.o, cpphash.o, fix-header): Update.
(hashtable.o): New target.
* c-common.h: Include cpplib.h. Define C_RID_CODE and
struct c_common_identifier here.
* c-lang.c (c_init_options): Update. Call set_identifier_size.
* c-lex.c (c_lex): Update.
* c-pragma.h: Update.
* c-tree.h (struct lang_identifier): Contain c_common_identifier.
Delete rid_code.
(C_RID_CODE): Delete.
* cpphash.c: Rewrite to use hashtable.c.
* cpphash.h: Update include guards.
(struct cpp_reader): Remove hashtab.
hash_ob and buffer_ob are no longer pointers. Add hash_table
and our_hashtable.
(HASHSTEP, _cpp_init_hashtable, _cpp_lookup_with_hash): Delete.
(_cpp_cleanup_hashtable): Rename _cpp_destroy_hashtable.
(_cpp_cleanup_stacks): Rename _cpp_init_directives.
* cppinit.c (cpp_create_reader): Update.
* cpplex.c (cpp_ideq, parse_identifier, cpp_output_token): Update.
(cpp_interpret_charconst): Eliminate warning.
* cpplib.c (do_pragma, do_endif, push_conditional,
cpp_push_buffer, cpp_pop_buffer): Update.
(_cpp_init_stacks): Rename cpp_init_directives.
(_cpp_cleanup_stacks): Remove.
* cpplib.h: Update include guards. Include tree-core.h and c-rid.h.
(cpp_hashnode, cpp_token, NODE_LEN, NODE_NAME,
cpp_forall_identifiers, cpp_create_reader): Update.
(C_RID_CODE, cpp_make_node): New.
(c_common_identifier): New identifier node for C front ends.
* cppmain.c (main): Update.
* fix-header.c (read_scan_file): Update.
* flags.h (id_clash_len): Make unsigned.
* ggc.h (ggc_mark_nonnull_tree): New.
* hashtable.c: New.
* hashtable.h: New.
* stringpool.c: Update comments and copyright. Update to use
hashtable.c.
* toplev.c (approx_sqrt): Move to hashtable.c.
(id_clash_len): Make unsigned.
* toplev.h (ident_hash): New.
* tree.c (gcc_obstack_init): Move to hashtable.c.
* tree.h: Include hashtable.h.
(IDENTIFIER_POINTER, IDENTIFIER_LENGTH): Update.
(GCC_IDENT_TO_HT_IDENT, HT_IDENT_TO_GCC_IDENT): New.
(struct tree_identifier): Update.
(make_identifier): New.
cp:
* cp-tree.h (struct lang_identifier, C_RID_YYCODE): Update.
(C_RID_CODE): Remove.
* lex.c (cxx_init_options): Call set_identifier_size. Update.
(init_parse): Don't do it here.
objc:
* objc-act.c (objc_init_options): Call set_identifier_size. Update.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42334 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/hashtable.h')
-rw-r--r-- | gcc/hashtable.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gcc/hashtable.h b/gcc/hashtable.h new file mode 100644 index 00000000000..5b08fde25b6 --- /dev/null +++ b/gcc/hashtable.h @@ -0,0 +1,85 @@ +/* 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 +{ + unsigned int len; + const unsigned char *str; +}; + +#define HT_LEN(NODE) ((NODE)->len) +#define HT_STR(NODE) ((NODE)->str) + +/* We want code outside cpplib, such as the compiler front-ends, to be + able to include this header, and to be able to link with + cpphashtbl.o without pulling in any other parts of cpplib. */ + +struct cpp_reader; +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; +}; + +extern void gcc_obstack_init PARAMS ((struct obstack *)); +/* Initialise the hashtable with 2 ^ order entries. */ +extern hash_table *ht_create PARAMS ((unsigned int order)); +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 */ |