summaryrefslogtreecommitdiff
path: root/opcodes/i386-gen.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2017-12-18 09:34:00 +0100
committerJan Beulich <jbeulich@suse.com>2017-12-18 09:34:00 +0100
commitdc821c5f9ae5208ad1ec438718f75e224f856deb (patch)
tree2c8c7c089e3196e1956fbb30a7088d6172a08104 /opcodes/i386-gen.c
parenteccab96d54a9455557d3c4d5bff431f6e526d0b7 (diff)
downloadbinutils-gdb-dc821c5f9ae5208ad1ec438718f75e224f856deb.tar.gz
x86: replace Reg8, Reg16, Reg32, and Reg64
Use a combination of a single new Reg bit and Byte, Word, Dword, or Qword instead. Besides shrinking the number of operand type bits this has the benefit of making register handling more similar to accumulator handling (a generic flag is being accompanied by a "size qualifier"). It requires, however, to split a few insn templates, as it is no longer correct to have combinations like Reg32|Reg64|Byte. This slight growth in size will hopefully be outweighed by this change paving the road for folding a presumably much larger number of templates later on.
Diffstat (limited to 'opcodes/i386-gen.c')
-rw-r--r--opcodes/i386-gen.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index dba076c85ef..92681e21842 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -335,6 +335,14 @@ static initializer cpu_flag_init[] =
"CpuAVX512_BITALG" },
};
+static const initializer operand_type_shorthands[] =
+{
+ { "Reg8", "Reg|Byte" },
+ { "Reg16", "Reg|Word" },
+ { "Reg32", "Reg|Dword" },
+ { "Reg64", "Reg|Qword" },
+};
+
static initializer operand_type_init[] =
{
{ "OPERAND_TYPE_NONE",
@@ -631,10 +639,7 @@ static bitfield opcode_modifiers[] =
static bitfield operand_types[] =
{
- BITFIELD (Reg8),
- BITFIELD (Reg16),
- BITFIELD (Reg32),
- BITFIELD (Reg64),
+ BITFIELD (Reg),
BITFIELD (FloatReg),
BITFIELD (RegMMX),
BITFIELD (RegXMM),
@@ -789,9 +794,8 @@ next_field (char *str, char sep, char **next, char *last)
static void set_bitfield (char *, bitfield *, int, unsigned int, int);
static int
-set_bitfield_from_cpu_flag_init (char *f, bitfield *array,
- int value, unsigned int size,
- int lineno)
+set_bitfield_from_shorthand (char *f, bitfield *array, unsigned int size,
+ int lineno)
{
char *str, *next, *last;
unsigned int i;
@@ -812,6 +816,22 @@ set_bitfield_from_cpu_flag_init (char *f, bitfield *array,
return 0;
}
+ for (i = 0; i < ARRAY_SIZE (operand_type_shorthands); i++)
+ if (strcmp (operand_type_shorthands[i].name, f) == 0)
+ {
+ /* Turn on selective bits. */
+ char *init = xstrdup (operand_type_shorthands[i].init);
+ last = init + strlen (init);
+ for (next = init; next && next < last; )
+ {
+ str = next_field (next, '|', &next, last);
+ if (str)
+ set_bitfield (str, array, 1, size, lineno);
+ }
+ free (init);
+ return 0;
+ }
+
return -1;
}
@@ -862,8 +882,8 @@ set_bitfield (char *f, bitfield *array, int value,
}
}
- /* Handle CPU_XXX_FLAGS. */
- if (!set_bitfield_from_cpu_flag_init (f, array, value, size, lineno))
+ /* Handle shorthands. */
+ if (value == 1 && !set_bitfield_from_shorthand (f, array, size, lineno))
return;
if (lineno != -1)