pub struct LoopFabric {Show 14 fields
pub n_in: usize,
pub n_state: usize,
pub init: Vec<Src>,
pub lo: Src,
pub hi: Src,
pub invariants: Vec<Src>,
pub body: Vec<LoopCell>,
pub next: Vec<Src>,
pub result_state: usize,
pub seq_input: Option<usize>,
pub epilogue: Vec<LoopCell>,
pub epilogue_result: Src,
pub prologue_heap: Vec<LoopCell>,
pub seq_heap_ptr: Option<Src>,
}Expand description
A counted-loop residual lowered to a CGRA: a fixed BODY datapath (SSA over the current
loop-carried state + the induction variable + loop invariants, INCLUDING predicated select
tiles for data-dependent branches) driven by a sequential controller that clocks the state
through the body once per induction value in the inclusive range lo..=hi.
Fields§
§n_in: usizeCircuit input arity (the function’s parameters become circuit inputs in0..).
n_state: usizeNumber of loop-carried state registers (the accumulators).
init: Vec<Src>Initial value of each state register, as a Src over the circuit inputs / constants.
lo: SrcInclusive induction range: the induction variable takes lo, lo+1, …, hi. Over inputs.
hi: Src§invariants: Vec<Src>Loop-invariant values read by the body (fixed across iterations), as Src over inputs.
body: Vec<LoopCell>The body as SSA LoopCells. Body-input convention for Src::In(k): 0..n_state = the
current state registers, n_state = the induction variable, n_state+1+j = invariant j.
next: Vec<Src>For each state register, the Src (over body inputs / body vals) giving its NEXT value
after one execution of the body.
result_state: usizeWhich state register holds the loop’s result (returned after the loop).
seq_input: Option<usize>Some(k) marks a SEQUENCE loop (Repeat for x in xs) rather than a numeric range loop: input
k is the iterated Seq (a memory array), the induction range is 0..=len-1 derived from the
sequence’s length at eval time, and the body reads xs[iv] through a LoopCell::MemRead tile.
None is a plain counted range loop (lo/hi are the numeric bounds). This is “collections as a
spatial resource”: the induction variable IS the address generator streaming the array.
epilogue: Vec<LoopCell>The POST-LOOP transform (an epilogue island): straight-line LoopCells over the loop’s FINAL
state (Src::In(i) = final value of state register i), computing the returned value when the
function does more than return an accumulator (e.g. Return (sum 1..n) * 2). Empty when the loop
result IS a carried register — then Self::result_state names it. This is the first CFG
COMPOSITION: a loop island feeding a transform island, sequenced into one whole-function fabric.
epilogue_result: SrcWhen epilogue is non-empty, the Src (over the final state / epilogue vals) giving the result.
prologue_heap: Vec<LoopCell>The PROLOGUE HEAP ISLAND: straight-line LoopCells that build any LOCAL collection the loop iterates
(Let ps be [(1,2),(3,4)] → HeapAlloc/HeapWrite). Evaluated ONCE before the loop into a shared
heap; the loop body then reads/writes that same heap. Empty for a numeric / parameter-sequence loop.
seq_heap_ptr: Option<Src>Some(ptr) marks a FOREACH OVER A LOCAL HEAP LIST (Repeat for (a,b) in ps, ps a local): ptr
(a Src over the prologue-heap island) is the iterated list’s pointer, its length is heap[ptr], and
element iv is heap[ptr + 1 + iv] — the body destructures it via HeapRead with the heap threaded.
Distinct from Self::seq_input (a scalar parameter array). ptr is passed to the body as the FINAL
invariant so the element-address generator can read it.
Trait Implementations§
Source§impl Clone for LoopFabric
impl Clone for LoopFabric
Source§fn clone(&self) -> LoopFabric
fn clone(&self) -> LoopFabric
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LoopFabric
impl RefUnwindSafe for LoopFabric
impl Send for LoopFabric
impl Sync for LoopFabric
impl Unpin for LoopFabric
impl UnsafeUnpin for LoopFabric
impl UnwindSafe for LoopFabric
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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.