code wiki / (root) / nx_bits.nx

nx_bits.nx

buildroot/runtime/nx_bits.nx

10783 B335 linesdepth 3pulls 3 transitivereach 1954 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_bits.nx -- bit-manipulation primitives, dispatching to hardware intrinsics on supported backends with portable software fallbacks. Inspired by Hacker's Delight (Henry S. Warren Jr.) -- the canonical reference for bit-twiddling. Every soft path is BRANCHLESS or minimally-branched, FIXED-CYCLE, and CROSS-ARCH PORTABLE. Dispatch model: nx_bits_popcount64 / nx_bits_clz32 / nx_bits_ctz32 -> backend intrinsic on x86_64 (popcntq/bsrl+xor/bsfl) and rv64 with Zbb (cpop/clzw/ctzw). One machine instruction. Used by hot paths (sketches, hashing, bitmap iteration). nx_bits_popcount64_soft / nx_bits_clz32_soft / nx_bits_ctz32_soft -- pure-NishiLang SWAR + binary-search variants. Cross-arch portable to backends without bit-count opcodes. Used by paired correctness oracles and any caller targeting an exotic ISA. Substrate "get off C" trajectory: this module is pure NishiLang.

dependencies 1 imports · 39 importers

syscalls.nx nx_bits.nx _bits_rotr64_kat.nx _nx_bits_bswap_oracle.nx _nx_bits_bswap_speed_fast.nx _nx_bits_bswap_speed_soft.nx _nx_bits_clz64_oracle.nx _nx_bits_clz64_speed_fast.nx _nx_bits_clz64_speed_soft.nx _nx_bits_fast_vs_soft.nx _nx_bits_rotate_oracle.nx _nx_bits_rotate_speed_fast.nx

diagram shows first 10 each side; +0 more imports, +29 more importers in the complete lists below.

imports: syscalls.nx

imported by: _bits_rotr64_kat.nx_nx_bits_bswap_oracle.nx_nx_bits_bswap_speed_fast.nx_nx_bits_bswap_speed_soft.nx_nx_bits_clz64_oracle.nx_nx_bits_clz64_speed_fast.nx_nx_bits_clz64_speed_soft.nx_nx_bits_fast_vs_soft.nx_nx_bits_rotate_oracle.nx_nx_bits_rotate_speed_fast.nx_nx_bits_rotate_speed_soft.nx_nx_bits_speed_fast.nx_nx_bits_speed_paired.nx_nx_bits_speed_soft.nx_scalar_bitops_kat.nx_sha512_kernel_fast.nx_sha512_kernel_soft.nxchacha20.nxnx_bit.nxnx_bitops.nxnx_bits_test.nxnx_chacha20.nxnx_classical_unpatented.nxnx_classical_unpatented_2.nxnx_essentials.nxnx_sha256.nxnx_sha3.nxnx_sha512.nxnx_simhash.nxnx_sketch_cpc.nxnx_sketch_cpc_dense.nxnx_sketch_hll.nxnx_xoshiro.nxsha3.nxsha512.nxsketch_cpc.nxsketch_cpc_dense.nxsketch_hll.nxxoshiro.nx

structs

none

consts

none

functions

25func nx_bits_popcount64(x: i64) -> i64
29func nx_bits_popcount32(x: i64) -> i64
called by 2: nx_popcount32main
38func nx_bits_clz32(x: i64) -> i64
42func nx_bits_ctz32(x: i64) -> i64
51func nx_bits_clz64(x: i64) -> i64
57func nx_bits_ctz64(x: i64) -> i64
70func nx_bits_rotl64(x: i64, n: i64) -> i64
74func nx_bits_rotr64(x: i64, n: i64) -> i64
84func nx_bits_rotl32(x: i64, n: i64) -> i64
91func nx_bits_rotr32(x: i64, n: i64) -> i64
103func nx_bits_bswap64(x: i64) -> i64
112func nx_bits_bswap32(x: i64) -> i64
called by 2: mainnx_bswap32
118func nx_bits_popcount64_soft(x: i64) -> i64
126func nx_bits_popcount32_soft(x: i64) -> i64
134func nx_bits_clz32_soft(x: i64) -> i64
called by 1: main
156func nx_bits_rotl64_soft(x: i64, n: i64) -> i64
called by 2: mainmain
163func nx_bits_rotr64_soft(x: i64, n: i64) -> i64
called by 3: mainmainmain
173func nx_bits_bswap64_soft(x: i64) -> i64
called by 2: mainmain
181func nx_bits_bswap32_soft(x: i64) -> i64
called by 1: main
193func nx_bits_rotl32_soft(x: i64, n: i64) -> i64
calls 1: nx_bits_rotl32
196func nx_bits_rotr32_soft(x: i64, n: i64) -> i64
calls 1: nx_bits_rotr32
203func nx_bits_clz64_soft(x: i64) -> i64
called by 1: main
220func nx_bits_ctz64_soft(x: i64) -> i64
236func nx_bits_ctz32_soft(x: i64) -> i64
called by 1: main
258func nx_bits_lowest(x: i64) -> i64
called by 1: main
268func nx_bits_clear_lowest(x: i64) -> i64
called by 1: main
276func nx_bits_is_pow2(x: i64) -> i64
called by 1: main
287func nx_bits_next_pow2_32(x: i64) -> i64
called by 1: main
303func nx_bits_parity64(x: i64) -> i64
called by 1: main
316func nx_bits_floor_log2(x: i64) -> i64
called by 1: main calls 1: nx_bits_clz32
330func nx_bits_bextr(x: i64, start: i64, len: i64) -> i64
called by 1: main