diff options
author | Paul Burton <paul.burton@imgtec.com> | 2016-05-06 13:35:03 +0100 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2016-05-13 14:02:17 +0200 |
commit | 87321fddaeb8706a91293dc244408697a0a24ece (patch) | |
tree | 4a3de3864e8ccbaaa15417001e7a8fd2d5d7edcb /arch/mips | |
parent | 015aa05f534adabff2e4380f5ae6ea0fe20ec321 (diff) | |
download | talos-obmc-linux-87321fddaeb8706a91293dc244408697a0a24ece.tar.gz talos-obmc-linux-87321fddaeb8706a91293dc244408697a0a24ece.zip |
MIPS: Implement __arch_bitrev* using bitswap for MIPSr6
Release 6 of the MIPS architecture introduced the bitswap instruction,
which reverses the bits within each byte of a word. Make use of this
instruction to implement the __arch_bitrev* functions, which should be
faster for most MIPSr6 CPUs, reduces code size slightly and allows us to
avoid the lookup table used by the generic implementation, saving 256
bytes in the kernel binary by dropping that.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/13204/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/Kconfig | 1 | ||||
-rw-r--r-- | arch/mips/include/asm/bitrev.h | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 2b7af9014cce..95f05826a16f 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2000,6 +2000,7 @@ config CPU_MIPSR2 config CPU_MIPSR6 bool default y if CPU_MIPS32_R6 || CPU_MIPS64_R6 + select HAVE_ARCH_BITREVERSE select MIPS_SPRAM config EVA diff --git a/arch/mips/include/asm/bitrev.h b/arch/mips/include/asm/bitrev.h new file mode 100644 index 000000000000..bc739a404ae3 --- /dev/null +++ b/arch/mips/include/asm/bitrev.h @@ -0,0 +1,30 @@ +#ifndef __MIPS_ASM_BITREV_H__ +#define __MIPS_ASM_BITREV_H__ + +#include <linux/swab.h> + +static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x) +{ + u32 ret; + + asm("bitswap %0, %1" : "=r"(ret) : "r"(__swab32(x))); + return ret; +} + +static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x) +{ + u16 ret; + + asm("bitswap %0, %1" : "=r"(ret) : "r"(__swab16(x))); + return ret; +} + +static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) +{ + u8 ret; + + asm("bitswap %0, %1" : "=r"(ret) : "r"(x)); + return ret; +} + +#endif /* __MIPS_ASM_BITREV_H__ */ |