public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@orcam.me.uk>
To: Andrew Burgess <aburgess@redhat.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH 1/2] opcodes/mips: use .word/.short for undefined instructions
Date: Fri, 27 Jan 2023 11:57:20 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2301270155510.8022@angie.orcam.me.uk> (raw)
In-Reply-To: <87a62hfoa5.fsf@redhat.com>

On Tue, 17 Jan 2023, Andrew Burgess wrote:

> Sorry for the time taken to prepare this patch.  Let me know if you're
> happy for my to push the below, or if there's anything else that's
> needed.

 This is mostly OK, thank you, but see below.

> diff --git a/binutils/testsuite/binutils-all/mips/mips.exp b/binutils/testsuite/binutils-all/mips/mips.exp
> index 6a0ec25a06f..f43109a75b8 100644
> --- a/binutils/testsuite/binutils-all/mips/mips.exp
> +++ b/binutils/testsuite/binutils-all/mips/mips.exp
> @@ -266,3 +266,7 @@ run_dump_test_n64 "global-local-symtab-sort-n64${tmips}"
>  run_dump_test_o32 "global-local-symtab-final-o32" useld
>  run_dump_test_n32 "global-local-symtab-final-n32" useld
>  run_dump_test_n64 "global-local-symtab-final-n64" useld
> +
> +run_dump_test_o32 "micromips-reserved-enc"
> +run_dump_test_n32 "micromips-reserved-enc"
> +run_dump_test_n64 "micromips-reserved-enc"

 Our convention has been not to have duplicate test names, so please 
create separate .d files for each of these three tests (we have no better 
way at the moment, although one could envisage appending the ABI name 
automatically).  See e.g. global-local-symtab-sort-n32.d in the same 
directory and the `source' and `dump' keywords within for how you can 
avoid duplicating identical sources and dumps.

> diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
> index 6a513cd8946..80c35f4a5e0 100644
> --- a/opcodes/mips-dis.c
> +++ b/opcodes/mips-dis.c
> @@ -2601,11 +2601,19 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info)
>      }
>  
>    if (length == 2)
> -    infprintf (is, dis_style_assembler_directive, ".short");
> +    {
> +      infprintf (is, dis_style_assembler_directive, ".short");
> +      infprintf (is, dis_style_text, "\t");
> +      infprintf (is, dis_style_immediate, "0x%x", insn);
> +    }
>    else
> -    infprintf (is, dis_style_assembler_directive, ".word");
> -  infprintf (is, dis_style_text, "\t");
> -  infprintf (is, dis_style_immediate, "0x%x", insn);
> +    {
> +      infprintf (is, dis_style_assembler_directive, ".short");
> +      infprintf (is, dis_style_text, "\t");
> +      infprintf (is, dis_style_immediate, "0x%x", (insn >> 16) & 0xffff);
> +      infprintf (is, dis_style_text, ", ");
> +      infprintf (is, dis_style_immediate, "0x%x", (insn & 0xffff));
> +    }

 Now that I have looked at it again I've been wondering if:

  infprintf (is, dis_style_assembler_directive, ".short");
  infprintf (is, dis_style_text, "\t");
  if (length != 2)
    {
      infprintf (is, dis_style_immediate, "0x%x", (insn >> 16) & 0xffff);
      infprintf (is, dis_style_text, ", ");
    }
  infprintf (is, dis_style_immediate, "0x%x", (insn & 0xffff));

might be more desirably avoiding some code duplication, but I'll leave it 
up to you to decide if to keep your original proposal or whether to switch 
to this alternative.

  Maciej

  reply	other threads:[~2023-01-27 11:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 13:58 [PATCH 0/2] MIPS disassembler styling Andrew Burgess
2022-11-03 13:58 ` [PATCH 1/2] opcodes/mips: use .word/.short for undefined instructions Andrew Burgess
2023-01-06 15:58   ` Maciej W. Rozycki
2023-01-06 16:40     ` Andrew Burgess
2023-01-08 16:05       ` Maciej W. Rozycki
2023-01-17 10:28         ` Andrew Burgess
2023-01-27 11:57           ` Maciej W. Rozycki [this message]
2023-01-30  9:34             ` Andrew Burgess
2023-02-01 10:40               ` Maciej W. Rozycki
2023-02-01 15:32                 ` Andrew Burgess
2023-02-02  9:48                   ` Maciej W. Rozycki
2023-02-03  9:31                 ` Andrew Burgess
2023-02-13 12:07                   ` Andrew Burgess
2023-02-14  4:43                     ` Maciej W. Rozycki
2022-11-03 13:58 ` [PATCH 2/2] libopcodes/mips: add support for disassembler styling Andrew Burgess
2022-11-28 17:15 ` [PATCH 0/2] MIPS " Andrew Burgess
2022-11-30 16:50   ` Nick Clifton
2022-12-05 10:08     ` Andrew Burgess

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=alpine.DEB.2.21.2301270155510.8022@angie.orcam.me.uk \
    --to=macro@orcam.me.uk \
    --cc=aburgess@redhat.com \
    --cc=binutils@sourceware.org \
    /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).