Skip to main content

KnownBits

Struct KnownBits 

Source
pub struct KnownBits { /* private fields */ }
Expand description

Per-bit knowledge about a W-bit value: bits in zero are certainly 0, bits in one are certainly 1, and the two masks are disjoint. The concretization is every value v with v & zero == 0 and v & one == one.

Implementations§

Source§

impl KnownBits

Source

pub fn unknown(width: Width) -> Self

Nothing known.

Source

pub fn constant(v: &BitVec) -> Self

Every bit known.

Source

pub fn new(zero: BitVec, one: BitVec) -> Option<Self>

From masks of known-zero and known-one bits; None unless the widths are equal and the masks disjoint.

Source

pub fn width(&self) -> Width

The width.

Source

pub fn known_zero(&self) -> BitVec

Bits that are certainly 0.

Source

pub fn known_one(&self) -> BitVec

Bits that are certainly 1.

Source

pub fn known(&self) -> BitVec

Bits whose value is known.

Source

pub fn unknown_mask(&self) -> BitVec

Bits whose value is not known.

Source

pub fn maybe_one(&self) -> BitVec

Bits that may be 1 (the complement of known_zero).

Source

pub fn as_constant(&self) -> Option<BitVec>

The value, if every bit is known.

Source

pub fn contains(&self, v: &BitVec) -> bool

Whether v is consistent with this knowledge.

Source

pub fn meet(&self, o: &KnownBits) -> Option<KnownBits>

The knowledge of both (the intersection of the described sets); None if they contradict each other or have different widths.

Source

pub fn join(&self, o: &KnownBits) -> Option<KnownBits>

Knowledge true of either (the smallest description of the union); None if the widths differ.

Source

pub fn bit(&self, i: u16) -> Option<bool>

Whether bit i is known, and its value.

Source

pub fn umin(&self) -> BitVec

The smallest unsigned value consistent with the knowledge.

Source

pub fn umax(&self) -> BitVec

The largest unsigned value consistent with the knowledge.

Source

pub fn smin(&self) -> BitVec

The smallest signed value consistent with the knowledge.

Source

pub fn smax(&self) -> BitVec

The largest signed value consistent with the knowledge.

Source

pub fn trailing_known_zeros(&self) -> u32

Number of low bits known to be zero.

Source

pub fn leading_known_zeros(&self) -> u32

Number of high bits known to be zero.

Source

pub fn known_low_prefix(&self) -> u32

Number of low bits whose values are all known (a known prefix from bit 0).

Source

pub fn enumerate(&self, max_unknown_bits: u32) -> Option<Vec<BitVec>>

Enumerates every consistent value if there are at most 2^max_unknown_bits (and at most 2^20 in any case).

Source§

impl KnownBits

The same transfers on known bits alone (through Facts: the result may be sharper than a bits-only transfer, never less sound).

Source

pub fn apply_un(op: UnOp, a: &KnownBits) -> Result<KnownBits, WidthError>

Known bits of op(a).

Source

pub fn apply_bin( op: BinOp, a: &KnownBits, b: &KnownBits, ) -> Result<KnownBits, WidthError>

Known bits of op(a, b).

Trait Implementations§

Source§

impl Clone for KnownBits

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for KnownBits

Source§

impl Debug for KnownBits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

MSB first: 0, 1 or ? per bit.

Source§

impl Eq for KnownBits

Source§

impl Hash for KnownBits

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for KnownBits

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KnownBits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.