Add some insn names for (neg (abs)) code
[official-gcc.git] / gcc / hash.h
blob5a3838c5aceea0f48be411ccb40a97000c8962cc
1 /* Header file for generic hash table support.
2 Copyright (C) 1993, 94 Free Software Foundation, Inc.
3 Written by Steve Chamberlain <sac@cygnus.com>
5 This file was lifted from BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #ifdef IN_GCC
23 /* Add prototype support. */
24 #ifndef PROTO
25 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
26 #define PROTO(ARGS) ARGS
27 #else
28 #define PROTO(ARGS) ()
29 #endif
30 #endif
32 #define PARAMS(ARGS) PROTO(ARGS)
34 #ifdef __STDC__
35 #define PTR void *
36 #else
37 #ifndef const
38 #define const
39 #endif
40 #define PTR char *
41 #endif
43 #else /* ! IN_GCC */
44 #include <ansidecl.h>
45 #endif /* IN_GCC */
47 #include "obstack.h"
49 typedef enum {false, true} boolean;
51 /* Hash table routines. There is no way to free up a hash table. */
53 /* An element in the hash table. Most uses will actually use a larger
54 structure, and an instance of this will be the first field. */
56 struct hash_entry
58 /* Next entry for this hash code. */
59 struct hash_entry *next;
60 /* String being hashed. */
61 const char *string;
62 /* Hash code. This is the full hash code, not the index into the
63 table. */
64 unsigned long hash;
67 /* A hash table. */
69 struct hash_table
71 /* The hash array. */
72 struct hash_entry **table;
73 /* The number of slots in the hash table. */
74 unsigned int size;
75 /* A function used to create new elements in the hash table. The
76 first entry is itself a pointer to an element. When this
77 function is first invoked, this pointer will be NULL. However,
78 having the pointer permits a hierarchy of method functions to be
79 built each of which calls the function in the superclass. Thus
80 each function should be written to allocate a new block of memory
81 only if the argument is NULL. */
82 struct hash_entry *(*newfunc) PARAMS ((struct hash_entry *,
83 struct hash_table *,
84 const char *));
85 /* An obstack for this hash table. */
86 struct obstack memory;
89 /* Initialize a hash table. */
90 extern boolean hash_table_init
91 PARAMS ((struct hash_table *,
92 struct hash_entry *(*) (struct hash_entry *,
93 struct hash_table *,
94 const char *)));
96 /* Initialize a hash table specifying a size. */
97 extern boolean hash_table_init_n
98 PARAMS ((struct hash_table *,
99 struct hash_entry *(*) (struct hash_entry *,
100 struct hash_table *,
101 const char *),
102 unsigned int size));
104 /* Free up a hash table. */
105 extern void hash_table_free PARAMS ((struct hash_table *));
107 /* Look up a string in a hash table. If CREATE is true, a new entry
108 will be created for this string if one does not already exist. The
109 COPY argument must be true if this routine should copy the string
110 into newly allocated memory when adding an entry. */
111 extern struct hash_entry *hash_lookup
112 PARAMS ((struct hash_table *, const char *, boolean create,
113 boolean copy));
115 /* Base method for creating a hash table entry. */
116 extern struct hash_entry *hash_newfunc
117 PARAMS ((struct hash_entry *, struct hash_table *,
118 const char *));
120 /* Grab some space for a hash table entry. */
121 extern PTR hash_allocate PARAMS ((struct hash_table *,
122 unsigned int));
124 /* Traverse a hash table in a random order, calling a function on each
125 element. If the function returns false, the traversal stops. The
126 INFO argument is passed to the function. */
127 extern void hash_traverse PARAMS ((struct hash_table *,
128 boolean (*) (struct hash_entry *,
129 PTR),
130 PTR info));