diff options
author | Jan Beulich <jbeulich@suse.com> | 2022-12-12 08:49:26 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2022-12-12 08:49:26 +0100 |
commit | 65f440c8fb5fc1af9f5aaee181ac7e631573a7e1 (patch) | |
tree | 3949ce649e40e9b1c0a068519169827aa7dc5973 /gas | |
parent | daf15e3e96bf99ec5d3d8a610c3cf44bcc5b1cf1 (diff) | |
download | fsf-binutils-gdb-65f440c8fb5fc1af9f5aaee181ac7e631573a7e1.zip fsf-binutils-gdb-65f440c8fb5fc1af9f5aaee181ac7e631573a7e1.tar.gz fsf-binutils-gdb-65f440c8fb5fc1af9f5aaee181ac7e631573a7e1.tar.bz2 |
x86: generate template sets data at build time
Speed up gas startup by avoiding runtime allocation of the instances of
type "templates". At the same time cut the memory requirement to just
very little over half (not even accounting for any overhead
notes_alloc() may incur) by reusing the "end" slot of a preceding entry
for the "start" slot of the subsequent one.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-i386.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index fce8631..6758c58 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -2973,21 +2973,16 @@ md_begin (void) op_hash = str_htab_create (); { - const insn_template *optab = i386_optab; - const insn_template *end = optab + ARRAY_SIZE (i386_optab); - - while (optab < end) - { - templates *core_optab = notes_alloc (sizeof (*core_optab)); - - core_optab->start = optab; - while (++optab < end) - if (strcmp (optab->name, optab[-1].name) != 0) - break; - core_optab->end = optab; - if (str_hash_insert (op_hash, optab[-1].name, core_optab, 0)) - as_fatal (_("duplicate %s"), optab[-1].name); - } + const insn_template *const *sets = i386_op_sets; + const insn_template *const *end = sets + ARRAY_SIZE (i386_op_sets) - 1; + + /* Type checks to compensate for the conversion through void * which + occurs during hash table insertion / lookup. */ + (void)(sets == ¤t_templates->start); + (void)(end == ¤t_templates->end); + for (; sets < end; ++sets) + if (str_hash_insert (op_hash, (*sets)->name, sets, 0)) + as_fatal (_("duplicate %s"), (*sets)->name); } /* Initialize reg_hash hash table. */ |