From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH] x86: move Q-suffix-to-REX.W translation logic
Date: Fri, 26 Jan 2024 13:29:11 +0100 [thread overview]
Message-ID: <bee88f75-3a6a-4be7-9a7e-f877cd5a8a2e@suse.com> (raw)
By pulling it ahead of the SHORT_MNEM_SUFFIX case label we can drop a
part of another conditional there. While moving, also drop a pointless
check: With QWORD_MNEM_SUFFIX, register operands of XCHG necessarily
have both been 64-bit ones.
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -9459,13 +9459,31 @@ process_suffix (void)
else
i.tm.base_opcode |= 1;
}
+
+ /* Set mode64 for an operand. */
+ if (i.suffix == QWORD_MNEM_SUFFIX)
+ {
+ if (flag_code == CODE_64BIT
+ && !i.tm.opcode_modifier.norex64
+ && !i.tm.opcode_modifier.vexw
+ /* Special case for xchg %rax,%rax. It is NOP and doesn't
+ need rex64. */
+ && ! (i.operands == 2
+ && i.tm.base_opcode == 0x90
+ && i.tm.opcode_space == SPACE_BASE
+ && i.types[0].bitfield.instance == Accum
+ && i.types[1].bitfield.instance == Accum))
+ i.rex |= REX_W;
+
+ break;
+ }
+
/* fall through */
case SHORT_MNEM_SUFFIX:
/* Now select between word & dword operations via the operand
size prefix, except for instructions that will ignore this
prefix anyway. */
- if (i.suffix != QWORD_MNEM_SUFFIX
- && i.tm.opcode_modifier.mnemonicsize != IGNORESIZE
+ if (i.tm.opcode_modifier.mnemonicsize != IGNORESIZE
&& !i.tm.opcode_modifier.floatmf
&& (!is_any_vex_encoding (&i.tm)
|| i.tm.opcode_space == SPACE_EVEXMAP4)
@@ -9489,21 +9507,6 @@ process_suffix (void)
return 0;
}
- /* Set mode64 for an operand. */
- if (i.suffix == QWORD_MNEM_SUFFIX
- && flag_code == CODE_64BIT
- && !i.tm.opcode_modifier.norex64
- && !i.tm.opcode_modifier.vexw
- /* Special case for xchg %rax,%rax. It is NOP and doesn't
- need rex64. */
- && ! (i.operands == 2
- && i.tm.base_opcode == 0x90
- && i.tm.opcode_space == SPACE_BASE
- && i.types[0].bitfield.instance == Accum
- && i.types[0].bitfield.qword
- && i.types[1].bitfield.instance == Accum))
- i.rex |= REX_W;
-
break;
case 0:
reply other threads:[~2024-01-26 12:29 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=bee88f75-3a6a-4be7-9a7e-f877cd5a8a2e@suse.com \
--to=jbeulich@suse.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/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).