use crate::arch::*;
#[doc(hidden)]
pub trait BitIntrinsics: Copy {
type Half;
fn inverted_and(a: Self, b: Self) -> Self;
fn extract_bitfield(x: Self, start: u32, len: u32) -> Self;
fn isolate_lowest_clear(x: Self) -> Self;
fn set_lowest_zero(x: Self) -> Self;
fn set_lowest_clear(x: Self) -> Self;
fn from_lowest_set(x: Self) -> Self;
fn complement_lowest_set(x: Self) -> Self;
fn through_lowest_set(x: Self) -> Self;
fn clear_lowest_set(x: Self) -> Self;
fn zero_upper(x: Self, index: u32) -> Self;
fn leading_zeros(x: Self) -> Self;
fn deposit(x: Self, mask: Self) -> Self;
fn extract(x: Self, mask: Self) -> Self;
fn trailing_one_mask(x: Self) -> Self;
fn trailing_zeros(x: Self) -> Self;
fn trailing_zero_mask(x: Self) -> Self;
fn count_ones(x: Self) -> Self::Half;
}
impl BitIntrinsics for u32 {
type Half = u32;
#[inline(always)]
fn clear_lowest_set(x: Self) -> Self {
clear_lowest_set_u32(x)
}
#[inline(always)]
fn complement_lowest_set(x: Self) -> Self {
complement_lowest_set_u32(x)
}
#[inline(always)]
fn deposit(x: Self, mask: Self) -> Self {
deposit_u32(x, mask)
}
#[inline(always)]
fn extract(x: Self, mask: Self) -> Self {
extract_u32(x, mask)
}
#[inline(always)]
fn extract_bitfield(x: Self, start: u32, len: u32) -> Self {
extract_bitfield_u32(x, start, len)
}
#[inline(always)]
fn from_lowest_set(x: Self) -> Self {
from_lowest_set_u32(x)
}
#[inline(always)]
fn inverted_and(a: Self, b: Self) -> Self {
inverted_and_u32(a, b)
}
#[inline(always)]
fn isolate_lowest_clear(x: Self) -> Self {
isolate_lowest_clear_u32(x)
}
#[inline(always)]
fn leading_zeros(x: Self) -> Self {
leading_zeros_u32(x)
}
#[inline(always)]
fn set_lowest_clear(x: Self) -> Self {
set_lowest_clear_u32(x)
}
#[inline(always)]
fn set_lowest_zero(x: Self) -> Self {
set_lowest_zero_u32(x)
}
#[inline(always)]
fn through_lowest_set(x: Self) -> Self {
through_lowest_set_u32(x)
}
#[inline(always)]
fn trailing_one_mask(x: Self) -> Self {
trailing_one_mask_u32(x)
}
#[inline(always)]
fn trailing_zero_mask(x: Self) -> Self {
trailing_zero_mask_u32(x)
}
#[inline(always)]
fn trailing_zeros(x: Self) -> Self {
trailing_zeros_u32(x)
}
#[inline(always)]
fn zero_upper(x: Self, index: u32) -> Self {
zero_upper_u32(x, index)
}
#[inline(always)]
fn count_ones(x: Self) -> Self::Half {
count_ones_u32(x)
}
}
impl BitIntrinsics for u64 {
type Half = u64;
#[inline(always)]
fn clear_lowest_set(x: Self) -> Self {
clear_lowest_set_u64(x)
}
#[inline(always)]
fn complement_lowest_set(x: Self) -> Self {
complement_lowest_set_u64(x)
}
#[inline(always)]
fn deposit(x: Self, mask: Self) -> Self {
deposit_u64(x, mask)
}
#[inline(always)]
fn extract(x: Self, mask: Self) -> Self {
extract_u64(x, mask)
}
#[inline(always)]
fn extract_bitfield(x: Self, start: u32, len: u32) -> Self {
extract_bitfield_u64(x, start, len)
}
#[inline(always)]
fn from_lowest_set(x: Self) -> Self {
from_lowest_set_u64(x)
}
#[inline(always)]
fn inverted_and(a: Self, b: Self) -> Self {
inverted_and_u64(a, b)
}
#[inline(always)]
fn isolate_lowest_clear(x: Self) -> Self {
isolate_lowest_clear_u64(x)
}
#[inline(always)]
fn leading_zeros(x: Self) -> Self {
leading_zeros_u64(x)
}
#[inline(always)]
fn set_lowest_clear(x: Self) -> Self {
set_lowest_clear_u64(x)
}
#[inline(always)]
fn set_lowest_zero(x: Self) -> Self {
set_lowest_zero_u64(x)
}
#[inline(always)]
fn through_lowest_set(x: Self) -> Self {
through_lowest_set_u64(x)
}
#[inline(always)]
fn trailing_one_mask(x: Self) -> Self {
trailing_one_mask_u64(x)
}
#[inline(always)]
fn trailing_zero_mask(x: Self) -> Self {
trailing_zero_mask_u64(x)
}
#[inline(always)]
fn trailing_zeros(x: Self) -> Self {
trailing_zeros_u64(x)
}
#[inline(always)]
fn zero_upper(x: Self, index: u32) -> Self {
zero_upper_u64(x, index)
}
#[inline(always)]
fn count_ones(x: Self) -> Self::Half {
count_ones_u64(x)
}
}
impl BitIntrinsics for i32 {
type Half = i32;
#[inline(always)]
fn clear_lowest_set(x: Self) -> Self {
clear_lowest_set_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn complement_lowest_set(x: Self) -> Self {
complement_lowest_set_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn deposit(x: Self, mask: Self) -> Self {
deposit_u32(x.cast_unsigned(), mask.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn extract(x: Self, mask: Self) -> Self {
extract_u32(x.cast_unsigned(), mask.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn extract_bitfield(x: Self, start: u32, len: u32) -> Self {
extract_bitfield_u32(x.cast_unsigned(), start, len).cast_signed()
}
#[inline(always)]
fn from_lowest_set(x: Self) -> Self {
from_lowest_set_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn inverted_and(a: Self, b: Self) -> Self {
inverted_and_u32(a.cast_unsigned(), b.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn isolate_lowest_clear(x: Self) -> Self {
isolate_lowest_clear_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn leading_zeros(x: Self) -> Self {
leading_zeros_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn set_lowest_clear(x: Self) -> Self {
set_lowest_clear_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn set_lowest_zero(x: Self) -> Self {
set_lowest_zero_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn through_lowest_set(x: Self) -> Self {
through_lowest_set_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn trailing_one_mask(x: Self) -> Self {
trailing_one_mask_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn trailing_zero_mask(x: Self) -> Self {
trailing_zero_mask_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn trailing_zeros(x: Self) -> Self {
trailing_zeros_u32(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn zero_upper(x: Self, index: u32) -> Self {
zero_upper_u32(x.cast_unsigned(), index).cast_signed()
}
#[inline(always)]
fn count_ones(x: Self) -> Self {
count_ones_i32(x)
}
}
impl BitIntrinsics for i64 {
type Half = i32;
#[inline(always)]
fn clear_lowest_set(x: Self) -> Self {
clear_lowest_set_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn complement_lowest_set(x: Self) -> Self {
complement_lowest_set_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn deposit(x: Self, mask: Self) -> Self {
deposit_u64(x.cast_unsigned(), mask.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn extract(x: Self, mask: Self) -> Self {
extract_u64(x.cast_unsigned(), mask.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn extract_bitfield(x: Self, start: u32, len: u32) -> Self {
extract_bitfield_u64(x.cast_unsigned(), start, len).cast_signed()
}
#[inline(always)]
fn from_lowest_set(x: Self) -> Self {
from_lowest_set_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn inverted_and(a: Self, b: Self) -> Self {
inverted_and_u64(a.cast_unsigned(), b.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn isolate_lowest_clear(x: Self) -> Self {
isolate_lowest_clear_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn leading_zeros(x: Self) -> Self {
leading_zeros_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn set_lowest_clear(x: Self) -> Self {
set_lowest_clear_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn set_lowest_zero(x: Self) -> Self {
set_lowest_zero_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn through_lowest_set(x: Self) -> Self {
through_lowest_set_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn trailing_one_mask(x: Self) -> Self {
trailing_one_mask_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn trailing_zero_mask(x: Self) -> Self {
trailing_zero_mask_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn trailing_zeros(x: Self) -> Self {
trailing_zeros_u64(x.cast_unsigned()).cast_signed()
}
#[inline(always)]
fn zero_upper(x: Self, index: u32) -> Self {
zero_upper_u64(x.cast_unsigned(), index).cast_signed()
}
#[inline(always)]
fn count_ones(x: Self) -> Self::Half {
count_ones_i64(x)
}
}