pub struct Builder { /* private fields */ }Expand description
The routine under construction.
Implementations§
Source§impl Builder
impl Builder
pub fn new(shape: LaneShape) -> Builder
pub fn shape(&self) -> LaneShape
Sourcepub fn k(&mut self, v: u32) -> LReg
pub fn k(&mut self, v: u32) -> LReg
The constant v, materialized once in the routine’s prelude.
Sourcepub fn assign(&mut self, dst: LReg, src: LReg)
pub fn assign(&mut self, dst: LReg, src: LReg)
dst = src, for a register carried across the trips of a repeat.
Sourcepub fn repeat(&mut self, times: u32, f: impl FnOnce(&mut Builder))
pub fn repeat(&mut self, times: u32, f: impl FnOnce(&mut Builder))
Run f as a body repeated times times.
Sourcepub fn finish(
self,
name: impl Into<String>,
inputs: Vec<LReg>,
outputs: Vec<LReg>,
) -> Routine
pub fn finish( self, name: impl Into<String>, inputs: Vec<LReg>, outputs: Vec<LReg>, ) -> Routine
The finished routine.
pub fn add(&mut self, a: LReg, b: LReg, cin: LReg) -> (LReg, LReg)
pub fn sub(&mut self, a: LReg, b: LReg, bin: LReg) -> (LReg, LReg)
pub fn mul(&mut self, a: LReg, b: LReg) -> LReg
pub fn and(&mut self, a: LReg, b: LReg) -> LReg
pub fn or(&mut self, a: LReg, b: LReg) -> LReg
pub fn xor(&mut self, a: LReg, b: LReg) -> LReg
pub fn not(&mut self, a: LReg) -> LReg
pub fn shl(&mut self, a: LReg, k: u32) -> LReg
pub fn shr(&mut self, a: LReg, k: u32) -> LReg
pub fn ltu(&mut self, a: LReg, b: LReg) -> LReg
pub fn eq(&mut self, a: LReg, b: LReg) -> LReg
pub fn sel(&mut self, c: LReg, t: LReg, f: LReg) -> LReg
pub fn mw_zero(&mut self, n: usize) -> Mw
Sourcepub fn mw_state(&mut self, a: &Mw) -> Mw
pub fn mw_state(&mut self, a: &Mw) -> Mw
Fresh registers holding a copy of a: the state a repeat carries.
Sourcepub fn mw_assign(&mut self, dst: &Mw, src: &Mw)
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.
Sourcepub fn mw_sext(&mut self, a: &Mw, n: usize) -> Mw
pub fn mw_sext(&mut self, a: &Mw, n: usize) -> Mw
a sign-extended (from its top bit) or truncated to n words.
Sourcepub fn mw_from_word(&mut self, a: LReg, n: usize) -> Mw
pub fn mw_from_word(&mut self, a: LReg, n: usize) -> Mw
A word value (fits one word) as an n-word value.
pub fn mw_add(&mut self, a: &Mw, b: &Mw, cin: LReg) -> (Mw, LReg)
pub fn mw_sub(&mut self, a: &Mw, b: &Mw, bin: LReg) -> (Mw, LReg)
Sourcepub fn mw_inc(&mut self, a: &Mw, bit: LReg) -> (Mw, LReg)
pub fn mw_inc(&mut self, a: &Mw, bit: LReg) -> (Mw, LReg)
a + 1 when bit is 1, else a, and the carry out.
pub fn mw_and(&mut self, a: &Mw, b: &Mw) -> Mw
pub fn mw_or(&mut self, a: &Mw, b: &Mw) -> Mw
pub fn mw_xor(&mut self, a: &Mw, b: &Mw) -> Mw
pub fn mw_not(&mut self, a: &Mw) -> Mw
pub fn mw_sel(&mut self, c: LReg, t: &Mw, f: &Mw) -> Mw
Sourcepub fn mw_or_reduce(&mut self, a: &Mw) -> LReg
pub fn mw_or_reduce(&mut self, a: &Mw) -> LReg
A word that is zero exactly when a is.
Sourcepub fn mw_is_zero(&mut self, a: &Mw) -> LReg
pub fn mw_is_zero(&mut self, a: &Mw) -> LReg
1 when a is zero.
Sourcepub fn mw_top_bit(&mut self, a: &Mw) -> LReg
pub fn mw_top_bit(&mut self, a: &Mw) -> LReg
The top bit of a, as 0 or 1.
Sourcepub fn mw_shr_sticky(&mut self, a: &Mw, s: u32) -> (Mw, LReg)
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.
Sourcepub fn mw_shl_var(&mut self, a: &Mw, amt: &Mw, bits: u32) -> Mw
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.
Sourcepub fn mw_shr_var_sticky(&mut self, a: &Mw, amt: &Mw, bits: u32) -> (Mw, LReg)
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.
Sourcepub fn mw_sar_var(&mut self, a: &Mw, amt: &Mw, bits: u32) -> Mw
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.
Sourcepub fn mw_clz(&mut self, a: &Mw, n: usize) -> Mw
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.
Sourcepub fn mw_mul(&mut self, a: &Mw, b: &Mw) -> Mw
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.
Sourcepub fn mw_divrem(&mut self, a: &Mw, b: &Mw) -> (Mw, Mw)
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).
Sourcepub fn mw_popcount(&mut self, a: &Mw, n: usize) -> Mw
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§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.