Struct orzir_core::ApInt

source ·
pub struct ApInt { /* private fields */ }
Expand description

An arbitrary precision integer with signedless semantics.

Implementations§

source§

impl ApInt

source

pub fn zero(width: usize) -> Self

Create a 0 with given width.

source

pub fn is_zero(&self) -> bool

Check if the integer is zero.

source

pub fn one(width: usize) -> Self

Create a 1 with given width.

source

pub fn is_one(&self) -> bool

Check if the integer is one.

source

pub fn width(&self) -> usize

Get the width of the integer.

source

pub fn inplace_bitor(&mut self, other: &Self)

Inplace bitwise or operation.

source

pub fn inplace_bitand(&mut self, other: &Self)

Inplace bitwise and operation.

source

pub fn inplace_bitxor(&mut self, other: &Self)

Inplace bitwise xor operation.

source

pub fn inplace_bitnot(&mut self)

Inplace bitwise not operation.

source

pub fn zeroext(&mut self, width: usize)

Inplace addition operation.

source

pub fn signext(&mut self, width: usize)

Inplace addition operation.

source

pub fn into_signext(self, width: usize) -> Self

Consumes the integer and zero extends it.

source

pub fn into_zeroext(self, width: usize) -> Self

Consumes the integer and zero extends it.

source

pub fn truncate(&mut self, width: usize) -> Self

Inplace addition operation.

source

pub fn into_truncated(self, width: usize) -> (Self, Self)

Consumes the integer and truncates it.

source

pub fn inplace_add(&mut self, rhs: &Self) -> bool

Inplace addition and return the carry.

source

pub fn inplace_sub(&mut self, rhs: &Self) -> bool

Inplace subtraction and return the borrow.

source

pub fn inplace_widening_shl(&mut self, shamt: usize)

Inplace shift left and widen the integer.

source

pub fn inplace_carrying_shl(&mut self, shamt: usize) -> Self

Inplace shift left and return the overflow.

source

pub fn highest_bit(&self) -> bool

Get the highest bit of the integer.

source

pub fn all_ones(width: usize) -> Self

Get the lowest bit of the integer.

source

pub fn inplace_neg(&mut self)

Inplace negation.

source

pub fn inplace_abs(&mut self) -> bool

Inplace absolute value and return the sign.

source

pub fn into_abs(self) -> (Self, bool)

Consumes the integer and return the absolute value and the sign.

source

pub fn inplace_widening_umul_chunk(&mut self, chunk: u64)

Inplace widening unsigned multiplication by a chunk.

This operation widen the integer by one chunk width.

source

pub fn shrink_to_fit(&mut self)

Shrinks the integer to minimum width.

source

pub fn into_shrunk(self) -> Self

Consumes the integer and return the shrunk integer.

source

pub fn inplace_carrying_umul_chunk(&mut self, chunk: u64) -> Self

Inplace carrying unsigned multiplication by a chunk.

source

pub fn inplace_widening_umul(&mut self, rhs: &Self)

Inplace widening unsigned multiplication.

source

pub fn inplace_widening_smul(&mut self, rhs: &Self)

Inplace widening signed multiplication.

source

pub fn inplace_carrying_umul(&mut self, rhs: &Self) -> Self

Inplace carrying signed multiplication, return the overflow.

source

pub fn inplace_carrying_smul(&mut self, rhs: &Self) -> Self

Inplace carrying signed multiplication, return the overflow.

source

pub fn inplace_lshr(&mut self, shamt: usize) -> Self

Inplace logical shift right and return the discarded bits.

source

pub fn inplace_ashr(&mut self, shamt: usize) -> Self

Inplace arithmetic shift right and return the discarded bits.

source

pub fn inplace_udiv(&mut self, divisor: &Self) -> Self

Unsigned division and return the remainder.

source

pub fn inplace_sdiv(&mut self, divisor: &Self) -> Self

Signed division and return the remainder.

Trait Implementations§

source§

impl Binary for ApInt

source§

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

Formats the value using the given formatter.
source§

impl Clone for ApInt

source§

fn clone(&self) -> ApInt

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for ApInt

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for ApInt

source§

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

Formats the value using the given formatter. Read more
source§

impl From<Vec<u64>> for ApInt

source§

fn from(chunks: Vec<u64>) -> Self

Converts to this type from the input type.
source§

impl From<i16> for ApInt

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for ApInt

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for ApInt

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for ApInt

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl From<u16> for ApInt

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for ApInt

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for ApInt

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for ApInt

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for ApInt

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 LowerHex for ApInt

source§

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

Formats the value using the given formatter.
source§

impl Ord for ApInt

source§

fn cmp(&self, other: &Self) -> Ordering

Compare two integers as unsigned integers.

1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl Parse for ApInt

§

type Item = ApInt

source§

fn parse(_: &mut Context, state: &mut ParseState<'_>) -> ParseResult<Self::Item>

source§

impl PartialEq for ApInt

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ApInt

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

Compare two integers as unsigned integers.

1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Print for ApInt

source§

fn print(&self, _: &Context, state: &mut PrintState) -> PrintResult<()>

source§

impl TryFrom<&str> for ApInt

§

type Error = ApIntParseError

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

fn try_from(s: &str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<String> for ApInt

§

type Error = ApIntParseError

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

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl UpperHex for ApInt

source§

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

Formats the value using the given formatter.
source§

impl Eq for ApInt

source§

impl StructuralPartialEq for ApInt

Auto Trait Implementations§

§

impl Freeze for ApInt

§

impl RefUnwindSafe for ApInt

§

impl Send for ApInt

§

impl Sync for ApInt

§

impl Unpin for ApInt

§

impl UnwindSafe for ApInt

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.