Re: [PATCH v2 2/2] riscv: introduce asm/swab.h

From: Eric Biggers
Date: Thu Mar 20 2025 - 23:39:09 EST


On Wed, Mar 19, 2025 at 10:09:46PM +0100, Ignacio Encinas wrote:
> +#define ARCH_SWAB(size) \
> +static __always_inline unsigned long __arch_swab##size(__u##size value) \
> +{ \
> + unsigned long x = value; \
> + \
> + asm goto(ALTERNATIVE("j %l[legacy]", "nop", 0, \
> + RISCV_ISA_EXT_ZBB, 1) \
> + :::: legacy); \

Is there a reason to use this instead of
riscv_has_extension_likely(RISCV_ISA_EXT_ZBB) which seems to do the same thing,
including using a static branch?

- Eric