From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] x86: simplify expressions in update_imm()
Date: Mon, 31 Oct 2022 11:58:01 -0700 [thread overview]
Message-ID: <CAMe9rOp9K7iGmJYUgUT_rwmQpZ_+HjTHoiORZd3eGtZ5=XbsTQ@mail.gmail.com> (raw)
In-Reply-To: <c8d25b29-37fe-9623-a799-e67e1f991743@suse.com>
On Mon, Oct 31, 2022 at 10:01 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> Comparing the sum of the relevant .imm<N> fields against a constant imo
> makes more obvious what is actually meant. It allows dropping of two
> static variables, with a 3rd drop requiring two more minor adjustments
> elsewhere, utilizing that "i" is zeroed first thing in md_assemble().
> This also increases the chances of the compiler doing the calculations
> all in registers.
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -1908,12 +1908,9 @@ operand_type_xor (i386_operand_type x, i
> static const i386_operand_type disp16_32 = OPERAND_TYPE_DISP16_32;
> static const i386_operand_type anydisp = OPERAND_TYPE_ANYDISP;
> static const i386_operand_type regxmm = OPERAND_TYPE_REGXMM;
> -static const i386_operand_type imm8 = OPERAND_TYPE_IMM8;
> -static const i386_operand_type imm8s = OPERAND_TYPE_IMM8S;
> static const i386_operand_type imm16 = OPERAND_TYPE_IMM16;
> static const i386_operand_type imm32 = OPERAND_TYPE_IMM32;
> static const i386_operand_type imm32s = OPERAND_TYPE_IMM32S;
> -static const i386_operand_type imm64 = OPERAND_TYPE_IMM64;
> static const i386_operand_type imm16_32 = OPERAND_TYPE_IMM16_32;
> static const i386_operand_type imm16_32s = OPERAND_TYPE_IMM16_32S;
> static const i386_operand_type imm16_32_32s = OPERAND_TYPE_IMM16_32_32S;
> @@ -3976,7 +3973,7 @@ process_immext (void)
>
> exp = &im_expressions[i.imm_operands++];
> i.op[i.operands].imms = exp;
> - i.types[i.operands] = imm8;
> + i.types[i.operands].bitfield.imm8 = 1;
> i.operands++;
> exp->X_op = O_constant;
> exp->X_add_number = i.tm.extension_opcode;
> @@ -7652,18 +7649,12 @@ static int
> update_imm (unsigned int j)
> {
> i386_operand_type overlap = i.types[j];
> - if ((overlap.bitfield.imm8
> - || overlap.bitfield.imm8s
> - || overlap.bitfield.imm16
> - || overlap.bitfield.imm32
> - || overlap.bitfield.imm32s
> - || overlap.bitfield.imm64)
> - && !operand_type_equal (&overlap, &imm8)
> - && !operand_type_equal (&overlap, &imm8s)
> - && !operand_type_equal (&overlap, &imm16)
> - && !operand_type_equal (&overlap, &imm32)
> - && !operand_type_equal (&overlap, &imm32s)
> - && !operand_type_equal (&overlap, &imm64))
> + if (overlap.bitfield.imm8
> + + overlap.bitfield.imm8s
> + + overlap.bitfield.imm16
> + + overlap.bitfield.imm32
> + + overlap.bitfield.imm32s
> + + overlap.bitfield.imm64 > 1)
> {
> if (i.suffix)
> {
> @@ -7700,12 +7691,12 @@ update_imm (unsigned int j)
> else if (i.prefix[DATA_PREFIX])
> overlap = operand_type_and (overlap,
> flag_code != CODE_16BIT ? imm16 : imm32);
> - if (!operand_type_equal (&overlap, &imm8)
> - && !operand_type_equal (&overlap, &imm8s)
> - && !operand_type_equal (&overlap, &imm16)
> - && !operand_type_equal (&overlap, &imm32)
> - && !operand_type_equal (&overlap, &imm32s)
> - && !operand_type_equal (&overlap, &imm64))
> + if (overlap.bitfield.imm8
> + + overlap.bitfield.imm8s
> + + overlap.bitfield.imm16
> + + overlap.bitfield.imm32
> + + overlap.bitfield.imm32s
> + + overlap.bitfield.imm64 != 1)
> {
> as_bad (_("no instruction mnemonic suffix given; "
> "can't determine immediate size"));
> @@ -8064,7 +8055,7 @@ build_modrm_byte (void)
> immediate operand to encode the first operand. */
> exp = &im_expressions[i.imm_operands++];
> i.op[i.operands].imms = exp;
> - i.types[i.operands] = imm8;
> + i.types[i.operands].bitfield.imm8 = 1;
> i.operands++;
>
> gas_assert (i.tm.operand_types[reg_slot].bitfield.class == RegSIMD);
OK.
Thanks.
--
H.J.
prev parent reply other threads:[~2022-10-31 18:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 17:00 Jan Beulich
2022-10-31 18:58 ` 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='CAMe9rOp9K7iGmJYUgUT_rwmQpZ_+HjTHoiORZd3eGtZ5=XbsTQ@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).