ARM: 7877/1: use built-in byte swap function
authorKim Phillips <kim.phillips@freescale.com>
Wed, 6 Nov 2013 04:15:24 +0000 (05:15 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 29 Dec 2013 12:32:45 +0000 (12:32 +0000)
Enable the compiler intrinsic for byte swapping on arch ARM. This
allows the compiler to detect and be able to optimize out byte
swappings, and has a very modest benefit on vmlinux size (Linaro gcc
4.8):

text data bss dec hex filename
2840310 123932 61960 3026202 2e2d1a vmlinux-lart #orig
2840152 123932 61960 3026044 2e2c7c vmlinux-lart #builtin-bswap

6473120 314840 5616016 12403976 bd4508 vmlinux-mxs #orig
6472586 314848 5616016 12403450 bd42fa vmlinux-mxs #builtin-bswap

7419872 318372 379556 8117800 7bde28 vmlinux-imx_v6_v7 #orig
7419170 318364 379556 8117090 7bdb62 vmlinux-imx_v6_v7 #builtin-bswap

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/Kconfig
arch/arm/boot/compressed/Makefile
arch/arm/kernel/armksyms.c
arch/arm/lib/Makefile
arch/arm/lib/bswapsdi2.S [new file with mode: 0644]

index c1f1a7eee953de4378b1f74bd4907c969f96dceb..75597213c5b8e477b44ad291ca72fee12e40bc53 100644 (file)
@@ -6,6 +6,7 @@ config ARM
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_HAVE_CUSTOM_GPIO_H
        select ARCH_MIGHT_HAVE_PC_PARPORT
+       select ARCH_USE_BUILTIN_BSWAP
        select ARCH_USE_CMPXCHG_LOCKREF
        select ARCH_WANT_IPC_PARSE_VERSION
        select BUILDTIME_EXTABLE_SORT if MMU
index e7190bb5998e149906a4763e815712953c7421f5..4bb86d9a749d42826776886a261a07c18e16d516 100644 (file)
@@ -108,12 +108,12 @@ endif
 
 targets       := vmlinux vmlinux.lds \
                 piggy.$(suffix_y) piggy.$(suffix_y).o \
-                lib1funcs.o lib1funcs.S ashldi3.o ashldi3.S \
-                font.o font.c head.o misc.o $(OBJS)
+                lib1funcs.o lib1funcs.S ashldi3.o ashldi3.S bswapsdi2.o \
+                bswapsdi2.S font.o font.c head.o misc.o $(OBJS)
 
 # Make sure files are removed during clean
 extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern piggy.lz4 \
-                lib1funcs.S ashldi3.S $(libfdt) $(libfdt_hdrs) \
+                lib1funcs.S ashldi3.S bswapsdi2.S $(libfdt) $(libfdt_hdrs) \
                 hyp-stub.S
 
 ifeq ($(CONFIG_FUNCTION_TRACER),y)
@@ -156,6 +156,12 @@ ashldi3 = $(obj)/ashldi3.o
 $(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
        $(call cmd,shipped)
 
+# For __bswapsi2, __bswapdi2
+bswapsdi2 = $(obj)/bswapsdi2.o
+
+$(obj)/bswapsdi2.S: $(srctree)/arch/$(SRCARCH)/lib/bswapsdi2.S
+       $(call cmd,shipped)
+
 # We need to prevent any GOTOFF relocs being used with references
 # to symbols in the .bss section since we cannot relocate them
 # independently from the rest at run time.  This can be achieved by
@@ -177,7 +183,8 @@ if [ $(words $(ZRELADDR)) -gt 1 -a "$(CONFIG_AUTO_ZRELADDR)" = "" ]; then \
 fi
 
 $(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
-               $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) FORCE
+               $(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) \
+               $(bswapsdi2) FORCE
        @$(check_for_multiple_zreladdr)
        $(call if_changed,ld)
        @$(check_for_bad_syms)
index 1f031ddd0667a3e842317a90c59db3acc2284894..85e664b6a5f19be5e92d5f2fc5047dd2567ce09f 100644 (file)
@@ -35,6 +35,8 @@ extern void __ucmpdi2(void);
 extern void __udivsi3(void);
 extern void __umodsi3(void);
 extern void __do_div64(void);
+extern void __bswapsi2(void);
+extern void __bswapdi2(void);
 
 extern void __aeabi_idiv(void);
 extern void __aeabi_idivmod(void);
@@ -114,6 +116,8 @@ EXPORT_SYMBOL(__ucmpdi2);
 EXPORT_SYMBOL(__udivsi3);
 EXPORT_SYMBOL(__umodsi3);
 EXPORT_SYMBOL(__do_div64);
+EXPORT_SYMBOL(__bswapsi2);
+EXPORT_SYMBOL(__bswapdi2);
 
 #ifdef CONFIG_AEABI
 EXPORT_SYMBOL(__aeabi_idiv);
index 47d7338561de3c93c19a1345226e7078f779b6c6..0573faab96ad2cb815a4fcf26f678864dfcd80c5 100644 (file)
@@ -13,7 +13,7 @@ lib-y         := backtrace.o changebit.o csumipv6.o csumpartial.o   \
                   ashldi3.o ashrdi3.o lshrdi3.o muldi3.o             \
                   ucmpdi2.o lib1funcs.o div64.o                      \
                   io-readsb.o io-writesb.o io-readsl.o io-writesl.o  \
-                  call_with_stack.o
+                  call_with_stack.o bswapsdi2.o
 
 mmu-y  := clear_user.o copy_page.o getuser.o putuser.o
 
diff --git a/arch/arm/lib/bswapsdi2.S b/arch/arm/lib/bswapsdi2.S
new file mode 100644 (file)
index 0000000..9fcdd15
--- /dev/null
@@ -0,0 +1,36 @@
+#include <linux/linkage.h>
+
+#if __LINUX_ARM_ARCH__ >= 6
+ENTRY(__bswapsi2)
+       rev r0, r0
+       bx lr
+ENDPROC(__bswapsi2)
+
+ENTRY(__bswapdi2)
+       rev r3, r0
+       rev r0, r1
+       mov r1, r3
+       bx lr
+ENDPROC(__bswapdi2)
+#else
+ENTRY(__bswapsi2)
+       eor r3, r0, r0, ror #16
+       mov r3, r3, lsr #8
+       bic r3, r3, #0xff00
+       eor r0, r3, r0, ror #8
+       mov pc, lr
+ENDPROC(__bswapsi2)
+
+ENTRY(__bswapdi2)
+       mov ip, r1
+       eor r3, ip, ip, ror #16
+       eor r1, r0, r0, ror #16
+       mov r1, r1, lsr #8
+       mov r3, r3, lsr #8
+       bic r3, r3, #0xff00
+       bic r1, r1, #0xff00
+       eor r1, r1, r0, ror #8
+       eor r0, r3, ip, ror #8
+       mov pc, lr
+ENDPROC(__bswapdi2)
+#endif