From 65f440c8fb5fc1af9f5aaee181ac7e631573a7e1 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 12 Dec 2022 08:49:26 +0100 Subject: 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. --- opcodes/i386-gen.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'opcodes/i386-gen.c') 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 -- cgit v1.2.1