public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Andrew Burgess <andrew.burgess@embecosm.com>, binutils@sourceware.org
Cc: Claudiu.Zissulescu@synopsys.com, Cupertino.Miranda@synopsys.com,
	       noamca@mellanox.com
Subject: Re: [PATCHv2 1/3] opcodes/arc: Move instruction length logic to new function
Date: Wed, 13 Apr 2016 13:32:00 -0000	[thread overview]
Message-ID: <570E4A76.5020504@redhat.com> (raw)
In-Reply-To: <cb64992909da171def628e036ee5f6cc94e71058.1460458691.git.andrew.burgess@embecosm.com>

Hi Andrew,

> opcodes/ChangeLog:
> 
> 	* arc-dis.c (arc_insn_length): New function.
> 	(print_insn_arc): Use arc_insn_length.

Approved - please apply, but ...

> +static int
> +arc_insn_length (bfd_byte msb, bfd_byte lsb ATTRIBUTE_UNUSED,
> +                 struct disassemble_info *info)

Would this function ever return a negative value ?  I assume not, so
it would make sense for its return type to be "unsigned int".

Also will the LSB parameter ever be used ?  I assume that it is there
for a future extension to this function which might need it, but if
that is only theoretical, then maybe the parameter can be dropped
entirely and the code simplified.

> +  switch (info->mach)
> +    {
> +    case bfd_mach_arc_nps400:
> +    case bfd_mach_arc_arc700:
> +    case bfd_mach_arc_arc600:
> +      len = (major_opcode > 0xb) ? 2 : 4;
> +      break;
> +
> +    case bfd_mach_arc_arcv2:
> +      len = (major_opcode > 0x7) ? 2 : 4;
> +      break;
> +
> +    default:
> +      abort ();
> +    }
> +
> +  return len;

Since len is always returned without any further processing you
could save a bit of space in the function by moving the return 
instruction into the switch statement.  eg:

  case bfd_mach_arc_arc600:
    return (major_opcode > 0xb) ? 2 : 4;

Cheers
  Nick

  parent reply	other threads:[~2016-04-13 13:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 11:00 [PATCHv2 0/3] ARC: Add another group of nps instructions Andrew Burgess
2016-04-07 11:05 ` [PATCH " Andrew Burgess
2016-04-07 11:05   ` [PATCH 2/3] bfd/arc: Rename enum entries to avoid conflicts Andrew Burgess
2016-04-07 11:20     ` Claudiu Zissulescu
2016-04-07 11:05   ` [PATCH 1/3] opcodes/arc: Compute insn lengths in disassembler Andrew Burgess
2016-04-07 11:27     ` Claudiu Zissulescu
2016-04-12  9:27     ` Claudiu Zissulescu
2016-04-07 11:05   ` [PATCH 3/3] arc/nps400 : New cmem instructions and associated relocation Andrew Burgess
2016-04-11 12:55     ` Cupertino Miranda
2016-04-12 11:00   ` [PATCHv2 2/3] bfd/arc: Rename enum entries to avoid conflicts Andrew Burgess
2016-04-13 13:34     ` Nick Clifton
2016-04-12 11:00   ` [PATCHv2 1/3] opcodes/arc: Move instruction length logic to new function Andrew Burgess
2016-04-12 12:27     ` Claudiu Zissulescu
2016-04-13 13:32     ` Nick Clifton [this message]
2016-04-13 14:41       ` Andrew Burgess
2016-04-13 15:30         ` Nick Clifton
2016-04-14 12:40           ` Andrew Burgess
2016-04-14 14:45             ` Nick Clifton
2016-04-12 11:00   ` [PATCHv2 3/3] arc/nps400 : New cmem instructions and associated relocation Andrew Burgess
2016-04-13 13:37     ` Nick Clifton

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=570E4A76.5020504@redhat.com \
    --to=nickc@redhat.com \
    --cc=Claudiu.Zissulescu@synopsys.com \
    --cc=Cupertino.Miranda@synopsys.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=binutils@sourceware.org \
    --cc=noamca@mellanox.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).