aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2022-03-17 11:04:41 +0100
committerJan Beulich <jbeulich@suse.com>2022-03-17 11:04:41 +0100
commitad9de929c3ef0b3b6c32db05cf3dc33ff3904990 (patch)
treecc8815e24abb964ae9d5a628123fc1adb0f78ba4 /opcodes
parentb1f8a900fdd64dee497912276c9f176169444219 (diff)
downloadgdb-ad9de929c3ef0b3b6c32db05cf3dc33ff3904990.zip
gdb-ad9de929c3ef0b3b6c32db05cf3dc33ff3904990.tar.gz
gdb-ad9de929c3ef0b3b6c32db05cf3dc33ff3904990.tar.bz2
x86: unify CPU flag on/off processing
There's no need for the arbitrary special "unknown" token: Simply recognize the leading ~ and process everything else the same, merely recording whether to set individual fields to 1 or 0. While there exclude CpuIAMCU from CPU_UNKNOWN_FLAGS - CPU_IAMCU_FLAGS override cpu_arch_flags anyway when -march=iamcu is passed, and there's no reason to have the stray flag set even if no insn actually is keyed to it.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/i386-gen.c31
-rw-r--r--opcodes/i386-init.h2
2 files changed, 11 insertions, 22 deletions
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index cdf06da..ae650d8 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -46,7 +46,7 @@ typedef struct initializer
static initializer cpu_flag_init[] =
{
{ "CPU_UNKNOWN_FLAGS",
- "unknown" },
+ "~CpuIAMCU" },
{ "CPU_GENERIC32_FLAGS",
"Cpu186|Cpu286|Cpu386" },
{ "CPU_GENERIC64_FLAGS",
@@ -1044,22 +1044,15 @@ process_i386_cpu_flag (FILE *table, char *flag, int macro,
const char *comma, const char *indent,
int lineno)
{
- char *str, *next, *last;
+ char *str, *next = flag, *last;
unsigned int i;
+ int value = 1;
bitfield flags [ARRAY_SIZE (cpu_flags)];
/* Copy the default cpu flags. */
memcpy (flags, cpu_flags, sizeof (cpu_flags));
- if (strcasecmp (flag, "unknown") == 0)
- {
- /* We turn on everything except for cpu64 in case of
- CPU_UNKNOWN_FLAGS. */
- for (i = 0; i < ARRAY_SIZE (flags); i++)
- if (flags[i].position != Cpu64)
- flags[i].value = 1;
- }
- else if (flag[0] == '~')
+ if (flag[0] == '~')
{
last = flag + strlen (flag);
@@ -1081,22 +1074,18 @@ process_i386_cpu_flag (FILE *table, char *flag, int macro,
flags[i].value = 1;
/* Turn off selective bits. */
- for (; next && next < last; )
- {
- str = next_field (next, '|', &next, last);
- if (str)
- set_bitfield (str, flags, 0, ARRAY_SIZE (flags), lineno);
- }
+ value = 0;
}
- else if (strcmp (flag, "0"))
+
+ if (strcmp (flag, "0"))
{
- /* Turn on selective bits. */
+ /* Turn on/off selective bits. */
last = flag + strlen (flag);
- for (next = flag; next && next < last; )
+ for (; next && next < last; )
{
str = next_field (next, '|', &next, last);
if (str)
- set_bitfield (str, flags, 1, ARRAY_SIZE (flags), lineno);
+ set_bitfield (str, flags, value, ARRAY_SIZE (flags), lineno);
}
}
diff --git a/opcodes/i386-init.h b/opcodes/i386-init.h
index e587cd6..393fdca 100644
--- a/opcodes/i386-init.h
+++ b/opcodes/i386-init.h
@@ -21,7 +21,7 @@
#define CPU_UNKNOWN_FLAGS \
{ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
+ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \