From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH v2] x86: re-order insn template fields
Date: Fri, 15 Jul 2022 10:47:34 -0700 [thread overview]
Message-ID: <CAMe9rOq0Y68G6dhhuK5R9fssnbihsuQSCOTBZhB0YAi9nQF==g@mail.gmail.com> (raw)
In-Reply-To: <72168667-58cd-1a90-ad26-a89e085e679e@suse.com>
On Fri, Jul 15, 2022 at 5:57 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> This saves quite a number of shift instructions: The "operands" field
> can now be retrieved by just masking (no shift), and extracting the
> "extension_opcode" field now only requires a (signed) right shift, with
> no prereq left one. (Of course there may be architectures where, in a
> cross build, there might be no difference at all, e.g. when there are
> suitable bitfield extraction insns.)
> ---
> v2: Add comment to struct insn_template.
>
> --- a/opcodes/i386-gen.c
> +++ b/opcodes/i386-gen.c
> @@ -1444,8 +1444,8 @@ output_i386_opcode (FILE *table, const c
> fail (_("%s:%d: %s: residual opcode (0x%0*llx) too large\n"),
> filename, lineno, name, 2 * length, opcode);
>
> - fprintf (table, " { \"%s\", 0x%0*llx%s, %s, %lu,\n",
> - name, 2 * (int)length, opcode, end, extension_opcode, i);
> + fprintf (table, " { \"%s\", 0x%0*llx%s, %lu, %s,\n",
> + name, 2 * (int)length, opcode, end, i, extension_opcode);
>
> process_i386_opcode_modifier (table, opcode_modifier, space, prefix,
> operand_types, lineno);
> --- a/opcodes/i386-opc.h
> +++ b/opcodes/i386-opc.h
> @@ -915,6 +915,11 @@ typedef struct insn_template
> /* instruction name sans width suffix ("mov" for movl insns) */
> char *name;
>
> + /* Bitfield arrangement is such that individual fields can be easily
> + extracted (in native builds at least) - either by at most a masking
> + operation (base_opcode, operands), or by just a (signed) right shift
> + (extension_opcode). Please try to maintain this property. */
> +
> /* base_opcode is the fundamental opcode byte without optional
> prefix(es). */
> unsigned int base_opcode:16;
> @@ -929,6 +934,12 @@ typedef struct insn_template
> from all other values above. */
> #define Opcode_VexW 0xf /* Operand order controlled by VEX.W. */
>
> + /* how many operands */
> + unsigned int operands:3;
> +
> + /* spare bits */
> + unsigned int :4;
> +
> /* (Fake) base opcode value for pseudo prefixes. */
> #define PSEUDO_PREFIX 0
>
> @@ -952,9 +963,6 @@ typedef struct insn_template
> #define Prefix_REX 8 /* {rex} */
> #define Prefix_NoOptimize 9 /* {nooptimize} */
>
> - /* how many operands */
> - unsigned int operands:3;
> -
> /* the bits in opcode_modifier are used to generate the final opcode from
> the base_opcode. These bits also are used to detect alternate forms of
> the same instruction */
OK.
Thanks.
--
H.J.
prev parent reply other threads:[~2022-07-15 17:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 12:57 Jan Beulich
2022-07-15 17:47 ` H.J. Lu [this message]
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='CAMe9rOq0Y68G6dhhuK5R9fssnbihsuQSCOTBZhB0YAi9nQF==g@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=jbeulich@suse.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).