Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / loongarch / include / asm / bitrev.h
blob46f275b9cdf7566726383e0adeab14a9b87afc5c
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
4 */
5 #ifndef __LOONGARCH_ASM_BITREV_H__
6 #define __LOONGARCH_ASM_BITREV_H__
8 #include <linux/swab.h>
10 static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x)
12 u32 ret;
14 asm("bitrev.4b %0, %1" : "=r"(ret) : "r"(__swab32(x)));
15 return ret;
18 static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x)
20 u16 ret;
22 asm("bitrev.4b %0, %1" : "=r"(ret) : "r"(__swab16(x)));
23 return ret;
26 static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x)
28 u8 ret;
30 asm("bitrev.4b %0, %1" : "=r"(ret) : "r"(x));
31 return ret;
34 #endif /* __LOONGARCH_ASM_BITREV_H__ */