blob: bc739a404ae37d29ba1ff83e4cada3c4053e31f1 [file] [log] [blame]
Paul Burton87321fd2016-05-06 13:35:03 +01001#ifndef __MIPS_ASM_BITREV_H__
2#define __MIPS_ASM_BITREV_H__
3
4#include <linux/swab.h>
5
6static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x)
7{
8 u32 ret;
9
10 asm("bitswap %0, %1" : "=r"(ret) : "r"(__swab32(x)));
11 return ret;
12}
13
14static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x)
15{
16 u16 ret;
17
18 asm("bitswap %0, %1" : "=r"(ret) : "r"(__swab16(x)));
19 return ret;
20}
21
22static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x)
23{
24 u8 ret;
25
26 asm("bitswap %0, %1" : "=r"(ret) : "r"(x));
27 return ret;
28}
29
30#endif /* __MIPS_ASM_BITREV_H__ */