From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754157AbcEYJD5 (ORCPT ); Wed, 25 May 2016 05:03:57 -0400 Received: from smtp2.macqel.be ([109.135.2.61]:49400 "EHLO smtp2.macqel.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753001AbcEYJD4 (ORCPT ); Wed, 25 May 2016 05:03:56 -0400 X-Greylist: delayed 418 seconds by postgrey-1.27 at vger.kernel.org; Wed, 25 May 2016 05:03:55 EDT Date: Wed, 25 May 2016 10:56:53 +0200 From: Philippe De Muyter To: George Spelvin Cc: geert@linux-m68k.org, gerg@linux-m68k.org, linux-kernel@vger.kernel.org, linux-m68k@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de Subject: Re: [PATCH 08/10] m68k: Add Message-ID: <20160525085653.GA9917@frolo.macqel> References: <20160525073455.5709.qmail@ns.sciencehorizons.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160525073455.5709.qmail@ns.sciencehorizons.net> User-Agent: Mutt/1.5.16 (2007-06-09) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 25, 2016 at 03:34:55AM -0400, George Spelvin wrote: > +static inline u32 __attribute_const__ __hash_32(u32 x) > +{ > + u32 a, b; > + > + asm( "move.l %2,%0" /* 0x0001 */ > + "\n lsl.l #2,%0" /* 0x0004 */ > + "\n move.l %0,%1" > + "\n lsl.l #7,%0" /* 0x0200 */ > + "\n add.l %2,%0" /* 0x0201 */ > + "\n add.l %0,%1" /* 0x0205 */ > + "\n add.l %0,%0" /* 0x0402 */ > + "\n add.l %0,%1" /* 0x0607 */ > + "\n lsl.l #5,%0" /* 0x8040 */ > + /* 0x8647 */ There is no standard way to write asm in the kernel, but I prefer a simple semicolon after each insn asm("move.l %2,%0;" /* 0x0001 */ "lsl.l #2,%0;" /* 0x0004 */ "move.l %0,%1;" "lsl.l #7,%0;" /* 0x0200 */ "add.l %2,%0;" /* 0x0201 */ "add.l %0,%1;" /* 0x0205 */ "add.l %0,%0;" /* 0x0402 */ "add.l %0,%1;" /* 0x0607 */ "lsl.l #5,%0" /* 0x8040 */ /* 0x8647 */ Also, it took me some time to understand the hexadecimal constants in the comments (and the last one predicts a future event :)). > + : "=&d" (a), "=&r" (b) > + : "g" (x)); > + > + return ((u16)(x*0x61c8) << 16) + a + b; > +} Just my two cents Philippe From mboxrd@z Thu Jan 1 00:00:00 1970 From: Philippe De Muyter Subject: Re: [PATCH 08/10] m68k: Add Date: Wed, 25 May 2016 10:56:53 +0200 Message-ID: <20160525085653.GA9917@frolo.macqel> References: <20160525073455.5709.qmail@ns.sciencehorizons.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20160525073455.5709.qmail@ns.sciencehorizons.net> Sender: linux-m68k-owner@vger.kernel.org List-Id: linux-m68k@vger.kernel.org To: George Spelvin Cc: geert@linux-m68k.org, gerg@linux-m68k.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, torvalds@linux-foundation.org, tglx@linutronix.de On Wed, May 25, 2016 at 03:34:55AM -0400, George Spelvin wrote: > +static inline u32 __attribute_const__ __hash_32(u32 x) > +{ > + u32 a, b; > + > + asm( "move.l %2,%0" /* 0x0001 */ > + "\n lsl.l #2,%0" /* 0x0004 */ > + "\n move.l %0,%1" > + "\n lsl.l #7,%0" /* 0x0200 */ > + "\n add.l %2,%0" /* 0x0201 */ > + "\n add.l %0,%1" /* 0x0205 */ > + "\n add.l %0,%0" /* 0x0402 */ > + "\n add.l %0,%1" /* 0x0607 */ > + "\n lsl.l #5,%0" /* 0x8040 */ > + /* 0x8647 */ There is no standard way to write asm in the kernel, but I prefer a simple semicolon after each insn asm("move.l %2,%0;" /* 0x0001 */ "lsl.l #2,%0;" /* 0x0004 */ "move.l %0,%1;" "lsl.l #7,%0;" /* 0x0200 */ "add.l %2,%0;" /* 0x0201 */ "add.l %0,%1;" /* 0x0205 */ "add.l %0,%0;" /* 0x0402 */ "add.l %0,%1;" /* 0x0607 */ "lsl.l #5,%0" /* 0x8040 */ /* 0x8647 */ Also, it took me some time to understand the hexadecimal constants in the comments (and the last one predicts a future event :)). > + : "=&d" (a), "=&r" (b) > + : "g" (x)); > + > + return ((u16)(x*0x61c8) << 16) + a + b; > +} Just my two cents Philippe