xref: /openbmc/linux/arch/mips/include/asm/bitrev.h (revision 2f164822)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __MIPS_ASM_BITREV_H__
3 #define __MIPS_ASM_BITREV_H__
4 
5 #include <linux/swab.h>
6 
7 static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x)
8 {
9 	u32 ret;
10 
11 	asm("bitswap	%0, %1" : "=r"(ret) : "r"(__swab32(x)));
12 	return ret;
13 }
14 
15 static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x)
16 {
17 	u16 ret;
18 
19 	asm("bitswap	%0, %1" : "=r"(ret) : "r"(__swab16(x)));
20 	return ret;
21 }
22 
23 static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x)
24 {
25 	u8 ret;
26 
27 	asm("bitswap	%0, %1" : "=r"(ret) : "r"(x));
28 	return ret;
29 }
30 
31 #endif /* __MIPS_ASM_BITREV_H__ */
32