aboutsummaryrefslogtreecommitdiff
path: root/gas/macro.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-07-07 08:37:10 +0930
committerAlan Modra <amodra@gmail.com>2022-07-09 21:21:36 +0930
commitbdcc1de1ecfabc7d2560aa56cbe5425cb43e9cac (patch)
tree052d9411ca4a306644e193dfbcd5dfee99049291 /gas/macro.h
parentd1cffdc3644b21187c3709ae3c9c757f9d59558e (diff)
downloadbinutils-bdcc1de1ecfabc7d2560aa56cbe5425cb43e9cac.zip
binutils-bdcc1de1ecfabc7d2560aa56cbe5425cb43e9cac.tar.gz
binutils-bdcc1de1ecfabc7d2560aa56cbe5425cb43e9cac.tar.bz2
macro.c: use string hash from hash.h for macro_hash
Another case of duplicated hash.h code, the only minor difference being that macro->format_hash was created with 7 entries vs. str_hash with 16 entries. * macro.c (macro_init, define_macro): Use str_htab_create. (do_formals, define_macro, macro_expand_body): Use str_hash_insert (macro_expand_body): Use str_hash_find and str_hash_delete. (delete_macro): Likewise. (sub_actual, macro_expand, check_macro): Use str_hash_find. (expand_irp): Use str_htab_create and str_hash_insert. * macro.h (struct macro_struct): Tidy. (struct macro_hash_entry, macro_hash_entry_t, hash_macro_entry), (eq_macro_entry, macro_entry_alloc, macro_entry_find), (struct formal_hash_entry, formal_hash_entry_t), (hash_formal_entry, eq_formal_entry, formal_entry_alloc), (formal_entry_find): Delete. * config/tc-iq2000.c (iq2000_add_macro): Use str_htab_create and str_hash_insert.
Diffstat (limited to 'gas/macro.h')
-rw-r--r--gas/macro.h98
1 files changed, 4 insertions, 94 deletions
diff --git a/gas/macro.h b/gas/macro.h
index 893b0c6..227c9cb 100644
--- a/gas/macro.h
+++ b/gas/macro.h
@@ -62,10 +62,10 @@ typedef struct macro_struct
{
sb sub; /* Substitution text. */
int formal_count; /* Number of formal args. */
- formal_entry *formals; /* Pointer to list of formal_structs. */
- struct htab *formal_hash; /* Hash table of formals. */
+ formal_entry *formals; /* List of formal_structs. */
+ htab_t formal_hash; /* Hash table of formals. */
const char *name; /* Macro name. */
- const char *file; /* File the macro was defined in. */
+ const char *file; /* File the macro was defined in. */
unsigned int line; /* Line number of definition. */
} macro_entry;
@@ -79,97 +79,7 @@ extern int macro_nest;
/* The macro hash table. */
-extern struct htab *macro_hash;
-
-struct macro_hash_entry
-{
- const char *name;
- macro_entry *macro;
-};
-
-typedef struct macro_hash_entry macro_hash_entry_t;
-
-/* Hash function for a macro_hash_entry. */
-
-static inline hashval_t
-hash_macro_entry (const void *e)
-{
- const macro_hash_entry_t *entry = (const macro_hash_entry_t *) e;
- return htab_hash_string (entry->name);
-}
-
-/* Equality function for a macro_hash_entry. */
-
-static inline int
-eq_macro_entry (const void *a, const void *b)
-{
- const macro_hash_entry_t *ea = (const macro_hash_entry_t *) a;
- const macro_hash_entry_t *eb = (const macro_hash_entry_t *) b;
-
- return strcmp (ea->name, eb->name) == 0;
-}
-
-static inline macro_hash_entry_t *
-macro_entry_alloc (const char *name, macro_entry *macro)
-{
- macro_hash_entry_t *entry = XNEW (macro_hash_entry_t);
- entry->name = name;
- entry->macro = macro;
- return entry;
-}
-
-static inline macro_entry *
-macro_entry_find (htab_t table, const char *name)
-{
- macro_hash_entry_t needle = { name, NULL };
- macro_hash_entry_t *entry = htab_find (table, &needle);
- return entry != NULL ? entry->macro : NULL;
-}
-
-struct formal_hash_entry
-{
- const char *name;
- formal_entry *formal;
-};
-
-typedef struct formal_hash_entry formal_hash_entry_t;
-
-/* Hash function for a macro_hash_entry. */
-
-static inline hashval_t
-hash_formal_entry (const void *e)
-{
- const formal_hash_entry_t *entry = (const formal_hash_entry_t *) e;
- return htab_hash_string (entry->name);
-}
-
-/* Equality function for a formal_hash_entry. */
-
-static inline int
-eq_formal_entry (const void *a, const void *b)
-{
- const formal_hash_entry_t *ea = (const formal_hash_entry_t *) a;
- const formal_hash_entry_t *eb = (const formal_hash_entry_t *) b;
-
- return strcmp (ea->name, eb->name) == 0;
-}
-
-static inline formal_hash_entry_t *
-formal_entry_alloc (const char *name, formal_entry *formal)
-{
- formal_hash_entry_t *entry = XNEW (formal_hash_entry_t);
- entry->name = name;
- entry->formal = formal;
- return entry;
-}
-
-static inline formal_entry *
-formal_entry_find (htab_t table, const char *name)
-{
- formal_hash_entry_t needle = { name, NULL };
- formal_hash_entry_t *entry = htab_find (table, &needle);
- return entry != NULL ? entry->formal : NULL;
-}
+extern htab_t macro_hash;
extern int buffer_and_nest (const char *, const char *, sb *,
size_t (*) (sb *));