From a12915cc7e2a6721678fc4efe7e6a1e9b970512e Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 5 Jan 2024 08:20:23 +0100 Subject: x86: corrections to CPU attribute/flags splitting There are a number of issues with 734dfd1cc966 ("x86: pack CPU flags in opcode table"): - the condition when two array slots need writing wasn't correct (with enough new Cpu* added an out of bounds array access would validly have been complained about by the compiler), - table generation didn't take into account CpuAttrUnused and CpuUnused being independent, and hence there not always (not) being an "unused" bitfield member in both structures, - cpu_flags_from_attr() wasn't ready for use on big-endian hosts, - there were two style violations. --- opcodes/i386-gen.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'opcodes/i386-gen.c') diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c index 09b0ccc..a54635e 100644 --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -856,7 +856,16 @@ output_cpu_flags (FILE *table, bitfield *flags, unsigned int size, active_cpu_flags.array[i / 32] |= 1U << (i % 32); } - fprintf (table, "%d } }%s\n", flags[i].value, comma); +#if defined(CpuAttrUnused) != defined(CpuUnused) + if (mode <= 0) +# ifdef CpuUnused + fprintf (table, " } }%s\n", comma); +# else + fprintf (table, "%d, 0 } }%s\n", flags[i].value, comma); +# endif + else +#endif + fprintf (table, "%d } }%s\n", flags[i].value, comma); } static void -- cgit v1.1