Received: from eggs.gnu.org ([2001:4830:134:3::10]:51054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9Jsu-0004wv-DB for qemu-devel@nongnu.org; Sat, 04 Jun 2016 18:17:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9Jsr-0007aC-7I for qemu-devel@nongnu.org; Sat, 04 Jun 2016 18:17:36 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:33787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9Jsq-0007a8-Vz for qemu-devel@nongnu.org; Sat, 04 Jun 2016 18:17:33 -0400 Received: by mail-pf0-x242.google.com with SMTP id b124so14660198pfb.0 for ; Sat, 04 Jun 2016 15:17:32 -0700 (PDT) Sender: Richard Henderson References: <1464898022-97990-1-git-send-email-rolnik@amazon.com> <1464898022-97990-4-git-send-email-rolnik@amazon.com> From: Richard Henderson Message-ID: <8d992369-e239-d290-8f51-5846739eb7f1@twiddle.net> Date: Sat, 4 Jun 2016 15:17:29 -0700 MIME-Version: 1.0 In-Reply-To: <1464898022-97990-4-git-send-email-rolnik@amazon.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 04/10] target-avr: adding instructions encodings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Rolnik , qemu-devel@nongnu.org Cc: Michael Rolnik On 06/02/2016 01:06 PM, Michael Rolnik wrote: > Signed-off-by: Michael Rolnik > --- > target-avr/translate-inst.h | 838 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 838 insertions(+) > create mode 100644 target-avr/translate-inst.h > > diff --git a/target-avr/translate-inst.h b/target-avr/translate-inst.h > new file mode 100644 > index 0000000..6bd180d > --- /dev/null > +++ b/target-avr/translate-inst.h > @@ -0,0 +1,838 @@ > + > +#ifndef AVR_TRANSLATE_INST_H_ > +#define AVR_TRANSLATE_INST_H_ > + > +typedef struct DisasContext DisasContext; > + > +int avr_translate_NOP(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); > + > +int avr_translate_MOVW(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); > +static inline uint32_t MOVW_Rr(uint32_t opcode) > +{ > + return extract32(opcode, 0, 4); > +} > +static inline uint32_t MOVW_Rd(uint32_t opcode) > +{ > + return extract32(opcode, 4, 4); > +} > + > +int avr_translate_MULS(CPUAVRState *env, DisasContext* ctx, uint32_t opcode); > +static inline uint32_t MULS_Rr(uint32_t opcode) > +{ > + return extract32(opcode, 0, 4); > +} > +static inline uint32_t MULS_Rd(uint32_t opcode) > +{ > + return extract32(opcode, 4, 4); > +} Any particular reason you're replicating all this logic for every instruction, as opposed to finding some commonalty between them? There aren't *that* many different operand field types. Glancing through the binutils source, I count 13. Although I might have missed a handful, it's still an order of magnitude less than your 159 functions. > +static inline uint32_t CPC_lRr(uint32_t opcode) > +{ > + return extract32(opcode, 0, 4); > +} ... > +static inline uint32_t CPC_hRr(uint32_t opcode) > +{ > + return extract32(opcode, 9, 1); > +} Any reason you're not simplifying the logic elsewhere by extracting the logical value, as opposed to the parts of the split value. I.e. (extract32(opcode, 9, 1) << 4) | extract32(opcode, 0, 4) r~