From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] x86: shrink op_riprel
Date: Wed, 18 May 2022 10:33:14 -0700 [thread overview]
Message-ID: <CAMe9rOq5r-TNiyM_JPvv2gSGufoFYnn+T9esYs5Ppj7S5GynTw@mail.gmail.com> (raw)
In-Reply-To: <242b89e7-dec9-f686-52c2-411ba1a4b77b@suse.com>
On Wed, May 4, 2022 at 2:03 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> It is only ever initialized from a boolean, so it as well as related
> variables' types can simply be bool and there's no masking to 32 bits
> needed in set_op().
>
> --- a/opcodes/i386-dis.c
> +++ b/opcodes/i386-dis.c
> @@ -59,7 +59,7 @@ static bfd_vma get64 (instr_info *);
> static bfd_signed_vma get32 (instr_info *);
> static bfd_signed_vma get32s (instr_info *);
> static int get16 (instr_info *);
> -static void set_op (instr_info *, bfd_vma, int);
> +static void set_op (instr_info *, bfd_vma, bool);
> static void OP_Skip_MODRM (instr_info *, int, int);
> static void OP_REG (instr_info *, int, int);
> static void OP_IMREG (instr_info *, int, int);
> @@ -227,9 +227,9 @@ struct instr_info
>
> unsigned char op_ad;
> signed char op_index[MAX_OPERANDS];
> + bool op_riprel[MAX_OPERANDS];
> char op_out[MAX_OPERANDS][100];
> bfd_vma op_address[MAX_OPERANDS];
> - bfd_vma op_riprel[MAX_OPERANDS];
> bfd_vma start_pc;
>
> /* On the 386's of 1988, the maximum length of an instruction is 15 bytes.
> @@ -9771,8 +9771,6 @@ print_insn (bfd_vma pc, instr_info *ins)
> order as the intel book; everything else is printed in reverse order. */
> if (ins->intel_syntax || ins->two_source_ops)
> {
> - bfd_vma riprel;
> -
> for (i = 0; i < MAX_OPERANDS; ++i)
> op_txt[i] = ins->op_out[i];
>
> @@ -9785,6 +9783,8 @@ print_insn (bfd_vma pc, instr_info *ins)
>
> for (i = 0; i < (MAX_OPERANDS >> 1); ++i)
> {
> + bool riprel;
> +
> ins->op_ad = ins->op_index[i];
> ins->op_index[i] = ins->op_index[MAX_OPERANDS - 1 - i];
> ins->op_index[MAX_OPERANDS - 1 - i] = ins->op_ad;
> @@ -11563,7 +11563,7 @@ OP_E_memory (instr_info *ins, int bytemo
> oappend (ins, ins->scratchbuf);
> if (riprel)
> {
> - set_op (ins, disp, 1);
> + set_op (ins, disp, true);
> oappend (ins, !addr32flag ? "(%rip)" : "(%eip)");
> }
> }
> @@ -11581,7 +11581,7 @@ OP_E_memory (instr_info *ins, int bytemo
> *ins->obufp++ = ins->open_char;
> if (ins->intel_syntax && riprel)
> {
> - set_op (ins, disp, 1);
> + set_op (ins, disp, true);
> oappend (ins, !addr32flag ? "rip" : "eip");
> }
> *ins->obufp = '\0';
> @@ -11943,20 +11943,14 @@ get16 (instr_info *ins)
> }
>
> static void
> -set_op (instr_info *ins, bfd_vma op, int riprel)
> +set_op (instr_info *ins, bfd_vma op, bool riprel)
> {
> ins->op_index[ins->op_ad] = ins->op_ad;
> if (ins->address_mode == mode_64bit)
> - {
> - ins->op_address[ins->op_ad] = op;
> - ins->op_riprel[ins->op_ad] = riprel;
> - }
> - else
> - {
> - /* Mask to get a 32-bit address. */
> - ins->op_address[ins->op_ad] = op & 0xffffffff;
> - ins->op_riprel[ins->op_ad] = riprel & 0xffffffff;
> - }
> + ins->op_address[ins->op_ad] = op;
> + else /* Mask to get a 32-bit address. */
> + ins->op_address[ins->op_ad] = op & 0xffffffff;
> + ins->op_riprel[ins->op_ad] = riprel;
> }
>
> static void
> @@ -12239,7 +12233,7 @@ OP_J (instr_info *ins, int bytemode, int
> }
> disp = ((ins->start_pc + (ins->codep - ins->start_codep) + disp) & mask)
> | segment;
> - set_op (ins, disp, 0);
> + set_op (ins, disp, false);
> print_operand_value (ins, ins->scratchbuf, 1, disp);
> oappend (ins, ins->scratchbuf);
> }
>
OK.
Thanks.
--
H.J.
prev parent reply other threads:[~2022-05-18 17:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 9:03 Jan Beulich
2022-05-18 17:33 ` 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=CAMe9rOq5r-TNiyM_JPvv2gSGufoFYnn+T9esYs5Ppj7S5GynTw@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).