]> git.ipfire.org Git - thirdparty/u-boot.git/commit
arm: Use builtins for ffs/fls
authorSean Anderson <sean.anderson@seco.com>
Mon, 31 Jul 2023 21:27:33 +0000 (17:27 -0400)
committerTom Rini <trini@konsulko.com>
Thu, 17 Aug 2023 20:39:20 +0000 (16:39 -0400)
commit726a802fdaf1ffb4ca95ebf6910a738781137ef5
tree7d2df62ee83092d7b8b6032f48a980b2a212df8c
parent14ba0a8bbc342a677982acc787ae542b84ed7993
arm: Use builtins for ffs/fls

Since ARMv5, the clz instruction allows for efficient implementation of
ffs/fls with builtins. Until ARMv7 (with Thumb-2), this instruction is
only available in ARM mode. LTO makes it difficult to force specific
functions to be in ARM mode, as it is effectively a form of very
aggressive inlining. To work around this, fls/ffs are implemented in
assembly for ARMv5 and ARMv6 when compiling U-Boot in Thumb mode.
Overall, this saves around 75 bytes per call.

This code is synced with v5.15 of the Linux kernel.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
arch/arm/include/asm/bitops.h
arch/arm/lib/Makefile
arch/arm/lib/bitops.S [new file with mode: 0644]
include/asm-generic/bitops/builtin-__ffs.h [new file with mode: 0644]
include/asm-generic/bitops/builtin-__fls.h [new file with mode: 0644]
include/asm-generic/bitops/builtin-ffs.h [new file with mode: 0644]
include/asm-generic/bitops/builtin-fls.h [new file with mode: 0644]