162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __ASM_BITREV_H 362306a36Sopenharmony_ci#define __ASM_BITREV_H 462306a36Sopenharmony_cistatic __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x) 562306a36Sopenharmony_ci{ 662306a36Sopenharmony_ci __asm__ ("rbit %w0, %w1" : "=r" (x) : "r" (x)); 762306a36Sopenharmony_ci return x; 862306a36Sopenharmony_ci} 962306a36Sopenharmony_ci 1062306a36Sopenharmony_cistatic __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x) 1162306a36Sopenharmony_ci{ 1262306a36Sopenharmony_ci return __arch_bitrev32((u32)x) >> 16; 1362306a36Sopenharmony_ci} 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cistatic __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) 1662306a36Sopenharmony_ci{ 1762306a36Sopenharmony_ci return __arch_bitrev32((u32)x) >> 24; 1862306a36Sopenharmony_ci} 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#endif 21