From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 87330385626D for ; Wed, 18 May 2022 17:33:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 87330385626D Received: by mail-pl1-x62d.google.com with SMTP id n8so2454837plh.1 for ; Wed, 18 May 2022 10:33:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fn1w8ZZpuSlXVN3Z4SHhKrSs5HVhs33HkGEv7ou6uo0=; b=QzJ+n4izw77YgCNaWKrEEa4tu8gyeSlN+Gl7bFOCiGMayIY0hTBHcKfTUrosJKLaVI L64L+9s7zSwZD+B0EvWVv31A6Vikv/RqFyqzNHuA6jYHypTjqT7x470oUpM70hTrAtjj sCsdxRmcnvfxfq5cmG7ENhyR179QoD62Yxn4FYQuZr/sNWnrQq9iaLKsBzTnVWnqsGnN S0LBm6HZjLuSJwFSzlpa5aEWInCUwGgp3paCwY6cSE3FgN0d4T6MilFwdsTBba6imMkR ii/W2ypMB+CrfyS7jnJTzGxAcnPMfSMWRYdVWVA3HYVHUS6QrI+Rc81VzsEXLduPs3J/ yR6A== X-Gm-Message-State: AOAM53158Cz4kZt1tUVV+Rca8vLNuyZ8H5234PPX9lo6dT5+pLD22l1E gVOu/4Vyloboa2fyH8SBuEs9gyXZDD4YHA8I0RU= X-Google-Smtp-Source: ABdhPJxc03ZXnfgT9tSGSudJz2JPhIybvUM4LxBHaVfzeQHVR04J2sZHGYy1lOmhAcPPg5d3669DVUai+Yw74xgvpPg= X-Received: by 2002:a17:902:988e:b0:161:8750:480b with SMTP id s14-20020a170902988e00b001618750480bmr480314plp.154.1652895230580; Wed, 18 May 2022 10:33:50 -0700 (PDT) MIME-Version: 1.0 References: <242b89e7-dec9-f686-52c2-411ba1a4b77b@suse.com> In-Reply-To: <242b89e7-dec9-f686-52c2-411ba1a4b77b@suse.com> From: "H.J. Lu" Date: Wed, 18 May 2022 10:33:14 -0700 Message-ID: Subject: Re: [PATCH] x86: shrink op_riprel To: Jan Beulich Cc: Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3019.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2022 17:33:53 -0000 On Wed, May 4, 2022 at 2:03 AM Jan Beulich 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.