Re: [PATCH v3 2/2] riscv: introduce asm/swab.h
From: Ignacio Encinas
Date: Fri Apr 04 2025 - 13:54:41 EST
On 4/4/25 17:47, Ben Dooks wrote:
> I was having a look at this as well, using the alternatives macros.
>
> It would be nice to have a __zbb_swab defined so that you could do some
> time checks with this, because it would be interesting to see the
> benchmark of how much these improve byteswapping.
I get your point, but isn't what you propose equivalent to benchmarking
__arch_swab vs ___constant_swab?
> Also, I wonder if it is possible to say to the build system we must
> have ZBB therefore only emit ZBB for cases where you are building a
> kernel for an known ZBB system.
You can disable ZBB instructions if you do RISCV_ISA_ZBB=n.
config RISCV_ISA_ZBB
bool "Zbb extension support for bit manipulation instructions"
depends on TOOLCHAIN_HAS_ZBB
depends on RISCV_ALTERNATIVE
default y
help
Adds support to dynamically detect the presence of the ZBB
extension (basic bit manipulation) and enable its usage.
The Zbb extension provides instructions to accelerate a number
of bit-specific operations (count bit population, sign extending,
bitrotation, etc).
If you don't know what to do here, say Y.
However, statically assuming ZBB instruction support is another beast
and I don't really have an informed opinion about this. Perhaps in a few
years?
Thanks for the review!