Expand description
Fast and efficient architecture-tuned bit operations.
By default, bit_arch uses a static target_feature approach. You can enable the dynamic
feature but it might be a little bit slower. It is highly recommended that you compile your
binary with the exact feature flags your target supports. Otherwise, you will be paying for a
runtime feature check every time you use a function.
bit_arch also supports complete no_std (and no_alloc) environments. It doesn’t need an
operating system to run (unless you use the dynamic feature).
All operations have x86_64-optimized paths and generic fallback paths. More architectures and
features may be added in the future. Currently supports BMI 1/2, TBM, and ABM on x86_64.
Modules§
- arch
- Low-level
u32andu64operations.
Functions§
- clear_
lowest_ set - Extracts and clears the lowest set bit from
x. Replacesx & (x - 1). - complement_
lowest_ set - Clears the least significant set bit and sets the rest. Replaces
!x | x.wrapping_sub(1). - count_
ones - Counts all one bits of
x. - deposit
- Scatters (deposits) lower bits of
xinto all set bits ofmask. - extract
- Extracts bits of
xmasked bymaskinto lower contiguous bits of output. - extract_
bitfield - Extracts a bitfield at index
startof sizelenof `x``. - from_
lowest_ set - Sets all bits below the least significant one. Replaces
x | x.wrapping_sub(1). - inverted_
and - Performs a bitwise logical
!a & b. - isolate_
lowest_ clear - Extracts and isolates the lowest clear bit from
x``. Replacesx | !x.wrapping_add(1)`. - leading_
zeros - Counts leading zero bits of
x. - set_
lowest_ clear - Sets the least significant zero bit and clears the rest. Replaces
!x & x.wrapping_add(1). - set_
lowest_ zero - Sets the least significant zero bit from
x. Replacesx | x.wrapping_add(1). - through_
lowest_ set - Mask up to the lowest set bit from
x. Replacesx ^ (x - 1). - trailing_
one_ mask - Inverse mask from trailing ones of
x. Replaces!x | x.wrapping_add(1). - trailing_
zero_ mask - Mask from trailing zeros of x. Replaces
!x & x.wrapping_sub(1). - trailing_
zeros - Counts trailing zero bits of
x. - zero_
upper - Zeros all bits of
xabove the specified index.