From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Herring Date: Sat, 18 Dec 2010 11:12:07 -0600 Subject: [U-Boot] [PATCH] arm: Add armv6 and armv7 optimized swab functions In-Reply-To: References: <1292425994-24331-1-git-send-email-robherring2@gmail.com> Message-ID: <4D0CEB67.2040502@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 12/17/2010 03:27 PM, M?ns Rullg?rd wrote: > Rob Herring writes: > >> From: Rob Herring >> >> swab functions are heavily used by FDT code, so enable >> optimized assembly code for ARMv6 and later. >> >> Signed-off-by: Rob Herring >> --- >> arch/arm/include/asm/byteorder.h | 16 ++++++++++++++++ >> 1 files changed, 16 insertions(+), 0 deletions(-) >> >> diff --git a/arch/arm/include/asm/byteorder.h b/arch/arm/include/asm/byteorder.h >> index c3489f1..9df5844 100644 >> --- a/arch/arm/include/asm/byteorder.h >> +++ b/arch/arm/include/asm/byteorder.h >> @@ -23,6 +23,22 @@ >> # define __SWAB_64_THRU_32__ >> #endif >> >> +#if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_6__) >> +static inline __u16 __attribute__((const)) ___arch_swab16(__u16 x) >> +{ >> + __asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x)); >> + return x; >> +} > > Pay close attention to what gcc does with this as it is prone to add > unnecessary masking of the low halfword. If the callers are > well-behaved (argument having top halfword clear), making the > parameter and return types here plain unsigned (or u32) gives better > code. This straight from the Linux code and there are only a few users of swab16 (none in my build). Rob