* [binutils-gdb] x86: corrections to CPU attribute/flags splitting
@ 2024-01-05 7:20 Jan Beulich
0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2024-01-05 7:20 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a12915cc7e2a6721678fc4efe7e6a1e9b970512e
commit a12915cc7e2a6721678fc4efe7e6a1e9b970512e
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Jan 5 08:20:23 2024 +0100
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.
Diff:
---
gas/config/tc-i386.c | 19 ++++++++++++++++---
opcodes/i386-gen.c | 11 ++++++++++-
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 172b05133ea..f4feca0518e 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1702,21 +1702,34 @@ static i386_cpu_flags cpu_flags_from_attr (i386_cpu_attr a)
const unsigned int bps = sizeof (a.array[0]) * CHAR_BIT;
i386_cpu_flags f = { .array[0] = 0 };
- switch (ARRAY_SIZE(a.array))
+ switch (ARRAY_SIZE (a.array))
{
case 1:
f.array[CpuAttrEnums / bps]
- |= (a.array[0] >> CpuIsaBits) << (CpuAttrEnums % bps);
- if (CpuAttrEnums % bps > CpuIsaBits)
+#ifndef WORDS_BIGENDIAN
+ |= (a.array[0] >> CpuIsaBits) << (CpuAttrEnums % bps);
+#else
+ |= (a.array[0] << CpuIsaBits) >> (CpuAttrEnums % bps);
+#endif
+ if (CpuMax / bps > CpuAttrEnums / bps)
f.array[CpuAttrEnums / bps + 1]
+#ifndef WORDS_BIGENDIAN
= (a.array[0] >> CpuIsaBits) >> (bps - CpuAttrEnums % bps);
+#else
+ = (a.array[0] << CpuIsaBits) << (bps - CpuAttrEnums % bps);
+#endif
break;
+
default:
abort ();
}
if (a.bitfield.isa)
+#ifndef WORDS_BIGENDIAN
f.array[(a.bitfield.isa - 1) / bps] |= 1u << ((a.bitfield.isa - 1) % bps);
+#else
+ f.array[(a.bitfield.isa - 1) / bps] |= 1u << (~(a.bitfield.isa - 1) % bps);
+#endif
return f;
}
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index 09b0ccce84d..a54635e1084 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-05 7:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05 7:20 [binutils-gdb] x86: corrections to CPU attribute/flags splitting Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).