sp1_recursion_compiler/ir/
var.rs1use super::{Builder, Config, Ptr, Usize};
2
3pub trait Variable<C: Config>: Clone {
4 type Expression: From<Self>;
5
6 fn uninit(builder: &mut Builder<C>) -> Self;
7
8 fn assign(&self, src: Self::Expression, builder: &mut Builder<C>);
9
10 fn assert_eq(
11 lhs: impl Into<Self::Expression>,
12 rhs: impl Into<Self::Expression>,
13 builder: &mut Builder<C>,
14 );
15
16 fn assert_ne(
17 lhs: impl Into<Self::Expression>,
18 rhs: impl Into<Self::Expression>,
19 builder: &mut Builder<C>,
20 );
21}
22
23#[derive(Debug, Clone, Copy)]
24pub struct MemIndex<N> {
25 pub index: Usize<N>,
26 pub offset: usize,
27 pub size: usize,
28}
29
30pub trait MemVariable<C: Config>: Variable<C> {
31 fn size_of() -> usize;
32 fn load(&self, ptr: Ptr<C::N>, index: MemIndex<C::N>, builder: &mut Builder<C>);
34 fn store(&self, ptr: Ptr<C::N>, index: MemIndex<C::N>, builder: &mut Builder<C>);
36}
37
38pub trait FromConstant<C: Config> {
39 type Constant;
40
41 fn constant(value: Self::Constant, builder: &mut Builder<C>) -> Self;
42}