summaryrefslogtreecommitdiff
path: root/opcodes/i386-gen.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2022-12-12 08:49:26 +0100
committerJan Beulich <jbeulich@suse.com>2022-12-12 08:49:26 +0100
commit65f440c8fb5fc1af9f5aaee181ac7e631573a7e1 (patch)
tree3949ce649e40e9b1c0a068519169827aa7dc5973 /opcodes/i386-gen.c
parentdaf15e3e96bf99ec5d3d8a610c3cf44bcc5b1cf1 (diff)
downloadbinutils-gdb-65f440c8fb5fc1af9f5aaee181ac7e631573a7e1.tar.gz
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 'opcodes/i386-gen.c')
-rw-r--r--opcodes/i386-gen.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index f14384231d6..5f68f933f15 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -1703,7 +1703,7 @@ process_i386_opcodes (FILE *table)
{
FILE *fp;
char buf[2048];
- unsigned int i, j;
+ unsigned int i, j, nr;
char *str, *p, *last, *name;
htab_t opcode_hash_table;
struct opcode_hash_entry **opcode_array = NULL;
@@ -1819,6 +1819,26 @@ process_i386_opcodes (FILE *table)
fclose (fp);
fprintf (table, "};\n");
+
+ /* Generate opcode sets array. */
+ fprintf (table, "\n/* i386 opcode sets table. */\n\n");
+ fprintf (table, "static const insn_template *const i386_op_sets[] =\n{\n");
+ fprintf (table, " i386_optab,\n");
+
+ for (nr = j = 0; j < i; j++)
+ {
+ struct opcode_hash_entry *next = opcode_array[j];
+
+ do
+ {
+ ++nr;
+ next = next->next;
+ }
+ while (next);
+ fprintf (table, " i386_optab + %u,\n", nr);
+ }
+
+ fprintf (table, "};\n");
}
static void