^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __ASM_BITREV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __ASM_BITREV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) __asm__ ("rbit %w0, %w1" : "=r" (x) : "r" (x));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) return x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) return __arch_bitrev32((u32)x) >> 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) return __arch_bitrev32((u32)x) >> 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #endif