aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Martin <dave.martin@linaro.org>2011-11-24 06:23:18 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-12-06 06:15:26 -0500
commitdf0e74da6df1568e3722466f85f2f08324bc767e (patch)
treeb32cad089d75d0d40d6ef96a0d610d668dc33580
parent7dbaa466780a754154531b44c2086f6618cee3a8 (diff)
ARM: 7173/1: Add optimised swahb32() byteswap helper for v6 and above
ARMv6 and later processors have the REV16 instruction, which swaps the bytes within each halfword of a register value. This is already used to implement swab16(), but since the native operation performaed by REV16 is actually swahb32(), this patch renames the existing swab16() helper accordingly and defines __arch_swab16() in terms of it. This allows calls to both swab16() and swahb32() to be optimised. The compiler's generated code might improve someday, but as of 4.5.2 the code generated for pure C implementing these 16-bit bytesswaps remains pessimal. swahb32() is useful for converting 32-bit Thumb instructions between integer and memory representation on BE8 platforms (among other uses). Signed-off-by: Dave Martin <dave.martin@linaro.org> Reviewed-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/include/asm/swab.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm/include/asm/swab.h b/arch/arm/include/asm/swab.h
index 9997ad20eff1..32ee164a2f6b 100644
--- a/arch/arm/include/asm/swab.h
+++ b/arch/arm/include/asm/swab.h
@@ -24,12 +24,13 @@
24 24
25#if defined(__KERNEL__) && __LINUX_ARM_ARCH__ >= 6 25#if defined(__KERNEL__) && __LINUX_ARM_ARCH__ >= 6
26 26
27static inline __attribute_const__ __u16 __arch_swab16(__u16 x) 27static inline __attribute_const__ __u32 __arch_swahb32(__u32 x)
28{ 28{
29 __asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x)); 29 __asm__ ("rev16 %0, %1" : "=r" (x) : "r" (x));
30 return x; 30 return x;
31} 31}
32#define __arch_swab16 __arch_swab16 32#define __arch_swahb32 __arch_swahb32
33#define __arch_swab16(x) ((__u16)__arch_swahb32(x))
33 34
34static inline __attribute_const__ __u32 __arch_swab32(__u32 x) 35static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
35{ 36{