From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPbtJ-00053r-Ib for qemu-devel@nongnu.org; Wed, 12 Aug 2015 15:40:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPbtC-0008Lx-VK for qemu-devel@nongnu.org; Wed, 12 Aug 2015 15:40:49 -0400 Received: from mail-qg0-x22e.google.com ([2607:f8b0:400d:c04::22e]:36164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPbtC-0008Lr-IG for qemu-devel@nongnu.org; Wed, 12 Aug 2015 15:40:42 -0400 Received: by qgdd90 with SMTP id d90so17749183qgd.3 for ; Wed, 12 Aug 2015 12:40:42 -0700 (PDT) Sender: Richard Henderson References: <1439151229-27747-1-git-send-email-laurent@vivier.eu> <1439151229-27747-30-git-send-email-laurent@vivier.eu> From: Richard Henderson Message-ID: <55CBA136.5080500@twiddle.net> Date: Wed, 12 Aug 2015 12:40:38 -0700 MIME-Version: 1.0 In-Reply-To: <1439151229-27747-30-git-send-email-laurent@vivier.eu> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.5 29/30] m68k: add rol/rox/ror/roxr List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, Andreas Schwab , gerg@uclinux.org On 08/09/2015 01:13 PM, Laurent Vivier wrote: > Signed-off-by: Laurent Vivier > --- > target-m68k/helper.c | 212 ++++++++++++++++++++++++++++++++++++++++++++++++ > target-m68k/helper.h | 14 ++++ > target-m68k/translate.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 433 insertions(+) > > diff --git a/target-m68k/helper.c b/target-m68k/helper.c > index 16fca70..532f366 100644 > --- a/target-m68k/helper.c > +++ b/target-m68k/helper.c > @@ -25,6 +25,42 @@ > > #define SIGNBIT (1u << 31) > > +/* modulo 33 table */ > +const uint8_t rox32_table[64] = { > + 0, 1, 2, 3, 4, 5, 6, 7, > + 8, 9, 10, 11, 12, 13, 14, 15, > + 16, 17, 18, 19, 20, 21, 22, 23, > + 24, 25, 26, 27, 28, 29, 30, 31, > + 32, 0, 1, 2, 3, 4, 5, 6, > + 7, 8, 9, 10, 11, 12, 13, 14, > + 15, 16, 17, 18, 19, 20, 21, 22, > + 23, 24, 25, 26, 27, 28, 29, 30, > +}; > + > +/* modulo 17 table */ > +const uint8_t rox16_table[64] = { > + 0, 1, 2, 3, 4, 5, 6, 7, > + 8, 9, 10, 11, 12, 13, 14, 15, > + 16, 0, 1, 2, 3, 4, 5, 6, > + 7, 8, 9, 10, 11, 12, 13, 14, > + 15, 16, 0, 1, 2, 3, 4, 5, > + 6, 7, 8, 9, 10, 11, 12, 13, > + 14, 15, 16, 0, 1, 2, 3, 4, > + 5, 6, 7, 8, 9, 10, 11, 12, > +}; > + > +/* modulo 9 table */ > +const uint8_t rox8_table[64] = { > + 0, 1, 2, 3, 4, 5, 6, 7, > + 8, 0, 1, 2, 3, 4, 5, 6, > + 7, 8, 0, 1, 2, 3, 4, 5, > + 6, 7, 8, 0, 1, 2, 3, 4, > + 5, 6, 7, 8, 0, 1, 2, 3, > + 4, 5, 6, 7, 8, 0, 1, 2, > + 3, 4, 5, 6, 7, 8, 0, 1, > + 2, 3, 4, 5, 6, 7, 8, 0, > +}; Why would you have these tables as opposed to just using the C modulo operator? > +uint32_t HELPER(rol32)(uint32_t val, uint32_t shift) > +{ > + uint32_t result; > + if (shift == 0 || shift == 32) { > + return val; > + } > + result = (val << shift) | (val >> (32 - shift)); > + return result; > +} > + > +uint32_t HELPER(ror32)(uint32_t val, uint32_t shift) > +{ > + uint32_t result; > + if (shift == 0 || shift == 32) { > + return val; > + } > + result = (val >> shift) | (val << (32 - shift)); > + return result; > +} Easily done in tcg directly. But aren't these are actually unused? > +#define HELPER_ROXR(type, bits) \ > +uint32_t HELPER(glue(glue(roxr, bits), _cc))(CPUM68KState *env, \ > + uint32_t val, uint32_t shift) \ > +{ \ Again, I think perhaps a 64-bit shift type might help clean up these cases. Start by forming the 34-bit quantity (X : VAL : 0); end by extracting bits [32:1] as the result and bit 0 as X. > +DISAS_INSN(rotate_im) ... > +DISAS_INSN(rotate_reg) Again, surely you can share code. r~