Skip to main content

Builder

Struct Builder 

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

The routine under construction.

Implementations§

Source§

impl Builder

Source

pub fn new(shape: LaneShape) -> Builder

Source

pub fn shape(&self) -> LaneShape

Source

pub fn w(&self) -> u32

The bits of one word.

Source

pub fn fresh(&mut self) -> LReg

A register no instruction has written yet.

Source

pub fn k(&mut self, v: u32) -> LReg

The constant v, materialized once in the routine’s prelude.

Source

pub fn assign(&mut self, dst: LReg, src: LReg)

dst = src, for a register carried across the trips of a repeat.

Source

pub fn repeat(&mut self, times: u32, f: impl FnOnce(&mut Builder))

Run f as a body repeated times times.

Source

pub fn finish( self, name: impl Into<String>, inputs: Vec<LReg>, outputs: Vec<LReg>, ) -> Routine

The finished routine.

Source

pub fn add(&mut self, a: LReg, b: LReg, cin: LReg) -> (LReg, LReg)

Source

pub fn sub(&mut self, a: LReg, b: LReg, bin: LReg) -> (LReg, LReg)

Source

pub fn mul(&mut self, a: LReg, b: LReg) -> LReg

Source

pub fn and(&mut self, a: LReg, b: LReg) -> LReg

Source

pub fn or(&mut self, a: LReg, b: LReg) -> LReg

Source

pub fn xor(&mut self, a: LReg, b: LReg) -> LReg

Source

pub fn not(&mut self, a: LReg) -> LReg

Source

pub fn shl(&mut self, a: LReg, k: u32) -> LReg

Source

pub fn shr(&mut self, a: LReg, k: u32) -> LReg

Source

pub fn ltu(&mut self, a: LReg, b: LReg) -> LReg

Source

pub fn eq(&mut self, a: LReg, b: LReg) -> LReg

Source

pub fn sel(&mut self, c: LReg, t: LReg, f: LReg) -> LReg

Source

pub fn bit_not(&mut self, b: LReg) -> LReg

1 − b for a bit b.

Source

pub fn word_bit(&mut self, a: LReg, i: u32) -> LReg

Bit i of a word, as 0 or 1.

Source

pub fn nonzero(&mut self, a: LReg) -> LReg

1 when the word is nonzero.

Source

pub fn mw_input(&mut self, n: usize) -> Mw

n fresh registers, for a routine’s inputs.

Source

pub fn mw_const(&mut self, v: u128, n: usize) -> Mw

The constant v in n words.

Source

pub fn mw_zero(&mut self, n: usize) -> Mw

Source

pub fn mw_state(&mut self, a: &Mw) -> Mw

Fresh registers holding a copy of a: the state a repeat carries.

Source

pub fn state(&mut self, a: LReg) -> LReg

A fresh register holding a copy of a.

Source

pub fn mw_assign(&mut self, dst: &Mw, src: &Mw)

dst = src as one parallel assignment: every word of src is read before any word of dst is written. A source word that is itself a destination (a whole-word shift or rotation of the state reuses the state’s own registers) is staged in a fresh register first.

Source

pub fn mw_resize(&mut self, a: &Mw, n: usize) -> Mw

a zero-extended or truncated to n words.

Source

pub fn mw_sext(&mut self, a: &Mw, n: usize) -> Mw

a sign-extended (from its top bit) or truncated to n words.

Source

pub fn mw_from_word(&mut self, a: LReg, n: usize) -> Mw

A word value (fits one word) as an n-word value.

Source

pub fn mw_add(&mut self, a: &Mw, b: &Mw, cin: LReg) -> (Mw, LReg)

Source

pub fn mw_plus(&mut self, a: &Mw, b: &Mw) -> Mw

a + b dropping the carry.

Source

pub fn mw_sub(&mut self, a: &Mw, b: &Mw, bin: LReg) -> (Mw, LReg)

Source

pub fn mw_minus(&mut self, a: &Mw, b: &Mw) -> Mw

a − b dropping the borrow.

Source

pub fn mw_neg(&mut self, a: &Mw) -> Mw

0 − a.

Source

pub fn mw_inc(&mut self, a: &Mw, bit: LReg) -> (Mw, LReg)

a + 1 when bit is 1, else a, and the carry out.

Source

pub fn mw_and(&mut self, a: &Mw, b: &Mw) -> Mw

Source

pub fn mw_or(&mut self, a: &Mw, b: &Mw) -> Mw

Source

pub fn mw_xor(&mut self, a: &Mw, b: &Mw) -> Mw

Source

pub fn mw_not(&mut self, a: &Mw) -> Mw

Source

pub fn mw_sel(&mut self, c: LReg, t: &Mw, f: &Mw) -> Mw

Source

pub fn mw_or_reduce(&mut self, a: &Mw) -> LReg

A word that is zero exactly when a is.

Source

pub fn mw_is_zero(&mut self, a: &Mw) -> LReg

1 when a is zero.

Source

pub fn mw_eq(&mut self, a: &Mw, b: &Mw) -> LReg

1 when a == b.

Source

pub fn mw_ltu(&mut self, a: &Mw, b: &Mw) -> LReg

1 when a < b, both unsigned.

Source

pub fn mw_lts(&mut self, a: &Mw, b: &Mw) -> LReg

1 when a < b, both two’s complement.

Source

pub fn mw_top_bit(&mut self, a: &Mw) -> LReg

The top bit of a, as 0 or 1.

Source

pub fn mw_bit(&mut self, a: &Mw, i: u32) -> LReg

Bit i of a (0 past its top).

Source

pub fn mw_shl(&mut self, a: &Mw, s: u32) -> Mw

a << s within a’s width.

Source

pub fn mw_shr(&mut self, a: &Mw, s: u32) -> Mw

a >> s (logical) within a’s width.

Source

pub fn mw_shr_sticky(&mut self, a: &Mw, s: u32) -> (Mw, LReg)

a >> s (logical), and 1 when any bit shifted out was set.

Source

pub fn mw_sar(&mut self, a: &Mw, s: u32) -> Mw

a >> s (arithmetic) within a’s width.

Source

pub fn mw_shl_var(&mut self, a: &Mw, amt: &Mw, bits: u32) -> Mw

a << amt for the unsigned amount in amt’s low bits bits; a shift past the width is zero.

Source

pub fn mw_shr_var_sticky(&mut self, a: &Mw, amt: &Mw, bits: u32) -> (Mw, LReg)

a >> amt (logical) for the amount in amt’s low bits bits, and the sticky bit of what fell off.

Source

pub fn mw_sar_var(&mut self, a: &Mw, amt: &Mw, bits: u32) -> Mw

a >> amt (arithmetic) for the amount in amt’s low bits bits.

Source

pub fn mw_clz(&mut self, a: &Mw, n: usize) -> Mw

The leading zeros of a, as an n-word count (a’s width when a is zero). a’s width must be a power of two.

Source

pub fn mw_mul(&mut self, a: &Mw, b: &Mw) -> Mw

The full product a × b (unsigned), a.len() + b.len() words: schoolbook over multiplier-width digits, each partial product one word, accumulated by result word and then carried.

Source

pub fn mw_divrem(&mut self, a: &Mw, b: &Mw) -> (Mw, Mw)

Unsigned a ÷ b and a mod b by restoring division over a’s bits; b must be nonzero (the caller guards a zero divisor, where the VM fails).

Source

pub fn mw_popcount(&mut self, a: &Mw, n: usize) -> Mw

The number of set bits of a, as an n-word count.

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
§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,