summaryrefslogtreecommitdiffstats
path: root/arch/mips/lib/bswapsi.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2015-09-29 12:19:48 +0200
committerRalf Baechle <ralf@linux-mips.org>2015-10-26 09:49:43 +0100
commit1ee3630a3e57f38f688a6f0a5f9edbd8a0d7201f (patch)
tree3326b59ffb2650bff622642700981bf5541a1b04 /arch/mips/lib/bswapsi.c
parentd478b088a2f74fc8f34af7ceed86fa7640ca8610 (diff)
downloadlinux-1ee3630a3e57f38f688a6f0a5f9edbd8a0d7201f.tar.gz
linux-1ee3630a3e57f38f688a6f0a5f9edbd8a0d7201f.tar.bz2
linux-1ee3630a3e57f38f688a6f0a5f9edbd8a0d7201f.zip
MIPS: Use ARCH_USE_BUILTIN_BSWAP.
ARCH_USE_BUILTIN_BSWAP will use __builtin_bswap16(), __builtin_bswap32() and __builtin_bswap64() where available. This allows better instruction scheduling. On pre-R2 processors it will result in 32 bit and 64 bit swapping being performed in a call to a __bswapsi2() rsp. __bswapdi2() functions, so we add these, too. For a 4.2 kernel with GCC 4.9 this yields the following kernel sizes: text data bss dec hex filename 3996071 155804 88992 4240867 40b5e3 vmlinux ip22 baseline 3985687 159900 88992 4234579 409d53 vmlinux ip22 + bswap patch 6913157 378552 251024 7542733 7317cd vmlinux ip27 baseline 6878581 378552 251024 7508157 7290bd vmlinux ip27 + bswap patch 5773777 268752 187424 6229953 5f0fc1 vmlinux malta baseline 5773401 268752 187424 6229577 5f0e49 vmlinux malta + bswap patch Presumably the code size improvments yield better cache hit rate thus better performance compensating for the extra function call but this will still need to be benchmarked. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/lib/bswapsi.c')
-rw-r--r--arch/mips/lib/bswapsi.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/mips/lib/bswapsi.c b/arch/mips/lib/bswapsi.c
new file mode 100644
index 000000000000..2b302ff121d2
--- /dev/null
+++ b/arch/mips/lib/bswapsi.c
@@ -0,0 +1,11 @@
+#include <linux/module.h>
+
+unsigned int __bswapsi2(unsigned int u)
+{
+ return (((u) & 0xff000000) >> 24) |
+ (((u) & 0x00ff0000) >> 8) |
+ (((u) & 0x0000ff00) << 8) |
+ (((u) & 0x000000ff) << 24);
+}
+
+EXPORT_SYMBOL(__bswapsi2);