[PATCH] x86: imply all No_*Suf when none is set in a template
Jan Beulich
jbeulich@suse.com
Thu Nov 14 08:51:00 GMT 2019
Since no template would ever allow for none of them to be set, reduce
table size and improve readability and hence maintainability by implying
all of them to be set when a template specifies none.
opcodes/
2019-11-XX Jan Beulich <jbeulich@suse.com>
* i386-gen.c (process_i386_opcode_modifier): Widen scope of
bwlq_suf. New local variable other_suf. Emit warning when all
No_*Suf are set. Set all No_*Suf when none are set.
* i386-opc.tbl: Drop No_bSuf, No_wSuf, No_lSuf, No_sSuf,
No_qSuf, and No_ldSuf when they're all specified at the same
time.
---
Full patch (including entirely mechanical i386-opc.tbl changes)
attached in compressed form, for size reasons. There's no change
to any of the generated files.
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -1089,6 +1089,7 @@ static void
process_i386_opcode_modifier (FILE *table, char *mod, char **opnd, int lineno)
{
char *str, *next, *last;
+ unsigned int bwlq_suf = 0xf, other_suf = 3;
bitfield modifiers [ARRAY_SIZE (opcode_modifiers)];
active_isstring = 0;
@@ -1098,7 +1099,7 @@ process_i386_opcode_modifier (FILE *tabl
if (strcmp (mod, "0"))
{
- unsigned int have_w = 0, bwlq_suf = 0xf;
+ unsigned int have_w = 0;
last = mod + strlen (mod);
for (next = mod; next && next < last; )
@@ -1125,6 +1126,10 @@ process_i386_opcode_modifier (FILE *tabl
bwlq_suf &= ~4;
if (strcasecmp(str, "No_qSuf") == 0)
bwlq_suf &= ~8;
+ if (strcasecmp(str, "No_sSuf") == 0)
+ other_suf &= ~1;
+ if (strcasecmp(str, "No_ldSuf") == 0)
+ other_suf &= ~2;
}
}
@@ -1137,7 +1142,26 @@ process_i386_opcode_modifier (FILE *tabl
fprintf (stderr,
"%s: %d: W modifier without Word/Dword/Qword operand(s)\n",
filename, lineno);
+ if (!bwlq_suf && !other_suf)
+ fprintf (stderr, "%s: %d: pointless specification of all No_*Suf\n",
+ filename, lineno);
+ }
+
+ /* Absence of any No_*Suf specification at all is taken to mean all of
+ these attributes to be set, as no template possibly permits for all
+ of them. */
+ if (opnd && bwlq_suf == 0xf && other_suf == 3)
+ {
+ unsigned int i;
+
+ static_assert (No_lSuf > No_bSuf && No_lSuf < No_ldSuf);
+ static_assert (No_qSuf > No_bSuf && No_qSuf < No_ldSuf);
+ static_assert (No_sSuf > No_bSuf && No_sSuf < No_ldSuf);
+ static_assert (No_wSuf > No_bSuf && No_wSuf < No_ldSuf);
+ for (i = No_bSuf; i <= No_ldSuf; ++i)
+ modifiers[i].value = 1;
}
+
output_opcode_modifier (table, modifiers, ARRAY_SIZE (modifiers));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-master-x86-no-suffix.patch.bz2
Type: application/octet-stream
Size: 40766 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20191114/f8c2eeb7/attachment.obj>
More information about the Binutils
mailing list