From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66963 invoked by alias); 13 Apr 2016 13:32:50 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 66902 invoked by uid 89); 13 Apr 2016 13:32:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1281 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 13 Apr 2016 13:32:42 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAAE2C04B312; Wed, 13 Apr 2016 13:32:40 +0000 (UTC) Received: from [10.36.6.221] (vpn1-6-221.ams2.redhat.com [10.36.6.221]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3DDWcMG027747 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Apr 2016 09:32:39 -0400 Subject: Re: [PATCHv2 1/3] opcodes/arc: Move instruction length logic to new function To: Andrew Burgess , binutils@sourceware.org References: Cc: Claudiu.Zissulescu@synopsys.com, Cupertino.Miranda@synopsys.com, noamca@mellanox.com From: Nick Clifton Message-ID: <570E4A76.5020504@redhat.com> Date: Wed, 13 Apr 2016 13:32:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00197.txt.bz2 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