mirror of
https://github.com/seL4/seL4.git
synced 2026-03-27 10:29:57 +00:00
riscv: more efficient clz and ctz
For RISC-V platforms that do not provide machine instructions to count leading and trailing zeros, this commit includes more efficient library functions. For verification, we expose the bodies of the functions to the proofs. Kernel config options `CLZ_BUILTIN` and `CTZ_BUILTIN` allow selection of whether compiler builtin functions should be used. These are only supported on platforms where the builtin compiles to inline assembly. By default, the options are on for all platforms except RISC-V. Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
This commit is contained in:
42
config.cmake
42
config.cmake
@@ -462,4 +462,46 @@ config_string(
|
||||
DEPENDS "KernelIsMCS" UNDEF_DISABLED
|
||||
)
|
||||
|
||||
config_option(
|
||||
KernelClzlImpl CLZL_IMPL
|
||||
"Define a __clzdi2 function to count leading zeros for unsigned long arguments. \
|
||||
Only needed on platforms which lack a builtin instruction."
|
||||
DEFAULT OFF
|
||||
)
|
||||
|
||||
config_option(
|
||||
KernelClzllImpl CLZLL_IMPL
|
||||
"Define a __clzti2 function to count leading zeros for unsigned long long arguments. \
|
||||
Only needed on platforms which lack a builtin instruction."
|
||||
DEFAULT OFF
|
||||
)
|
||||
|
||||
config_option(
|
||||
KernelCtzlImpl CTZL_IMPL
|
||||
"Define a __ctzdi2 function to count trailing zeros for unsigned long arguments. \
|
||||
Only needed on platforms which lack a builtin instruction."
|
||||
DEFAULT OFF
|
||||
)
|
||||
|
||||
config_option(
|
||||
KernelCtzllImpl CTZLL_IMPL
|
||||
"Define a __ctzti2 function to count trailing zeros for unsigned long long arguments. \
|
||||
Only needed on platforms which lack a builtin instruction."
|
||||
DEFAULT OFF
|
||||
)
|
||||
|
||||
config_option(
|
||||
KernelClzNoBuiltin CLZ_NO_BUILTIN
|
||||
"Expose implementations of clzl and clzll to verification by avoiding the use \
|
||||
of __builtin_clzl and __builtin_clzll."
|
||||
DEFAULT OFF
|
||||
)
|
||||
|
||||
config_option(
|
||||
KernelCtzNoBuiltin CTZ_NO_BUILTIN
|
||||
"Expose implementations of ctzl and ctzll to verification by avoiding the use \
|
||||
of __builtin_ctzl and __builtin_ctzll."
|
||||
DEFAULT OFF
|
||||
)
|
||||
|
||||
add_config_library(kernel "${configure_string}")
|
||||
|
||||
Reference in New Issue
Block a user