From: Jan Beulich <jbeulich@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] x86: parse special opcode modifiers for .insn
Date: Fri, 31 Mar 2023 06:23:01 +0000 (GMT) [thread overview]
Message-ID: <20230331062301.9E9C03858404@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=393fbe8d81ed4e26c66493bba5ac98b0bdae5f27
commit 393fbe8d81ed4e26c66493bba5ac98b0bdae5f27
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Mar 31 08:20:22 2023 +0200
x86: parse special opcode modifiers for .insn
So called "short form" encoding is specified by a trailing "+r", whereas
a possible extension opcode is specified by the usual "/<digit>". Take
these off the expression before handing it to get_absolute_expression().
Note that on targets where / starts a comment, --divide needs passing to
gas in order to make use of the extension opcode functionality.
Diff:
---
gas/config/tc-i386.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index fa6d65c11ed..d901ef9d39f 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -10552,7 +10552,7 @@ signed_cons (int size)
static void
s_insn (int dummy ATTRIBUTE_UNUSED)
{
- char mnemonic[MAX_MNEM_SIZE], *line = input_line_pointer;
+ char mnemonic[MAX_MNEM_SIZE], *line = input_line_pointer, *ptr;
char *saved_ilp = find_end_of_line (line, false), saved_char;
const char *end;
unsigned int j;
@@ -10578,6 +10578,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
current_templates = &tt;
i.tm.mnem_off = MN__insn;
+ i.tm.extension_opcode = None;
if (startswith (line, "VEX")
&& (line[3] == '.' || is_space_char (line[3])))
@@ -10804,10 +10805,46 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
goto done;
}
+ /* Before processing the opcode expression, find trailing "+r" or
+ "/<digit>" specifiers. */
+ for (ptr = line; ; ++ptr)
+ {
+ unsigned long n;
+ char *e;
+
+ ptr = strpbrk (ptr, "+/,");
+ if (ptr == NULL || *ptr == ',')
+ break;
+
+ if (*ptr == '+' && ptr[1] == 'r'
+ && (ptr[2] == ',' || (is_space_char (ptr[2]) && ptr[3] == ',')))
+ {
+ *ptr = ' ';
+ ptr[1] = ' ';
+ i.short_form = true;
+ break;
+ }
+
+ if (*ptr == '/' && ISDIGIT (ptr[1])
+ && (n = strtoul (ptr + 1, &e, 8)) < 8
+ && e == ptr + 2
+ && (ptr[2] == ',' || (is_space_char (ptr[2]) && ptr[3] == ',')))
+ {
+ *ptr = ' ';
+ ptr[1] = ' ';
+ i.tm.extension_opcode = n;
+ i.tm.opcode_modifier.modrm = 1;
+ break;
+ }
+ }
+
input_line_pointer = line;
val = get_absolute_expression ();
line = input_line_pointer;
+ if (i.short_form && (val & 7))
+ as_warn ("`+r' assumes low three opcode bits to be clear");
+
for (j = 1; j < sizeof(val); ++j)
if (!(val >> (j * 8)))
break;
reply other threads:[~2023-03-31 6:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230331062301.9E9C03858404@sourceware.org \
--to=jbeulich@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).