use crate::{
backend::Frontend,
word::{CompositeWord, Word, WordIdx},
};
use core::fmt::Debug;
pub trait Backend: Sized + Debug {
type FinalizeArg;
type FinalizeResult;
fn finalize(self, arg: Self::FinalizeArg) -> Self::FinalizeResult;
fn into_frontend(self) -> Frontend<Self> {
return Frontend::wrap(self);
}
fn input<W: Word, const N: usize>(&mut self, word: CompositeWord<W, N>) -> WordIdx<W, N>;
fn alloc<W: Word, const N: usize>(&mut self) -> WordIdx<W, N>;
fn constant<W: Word, const N: usize>(&mut self, word: CompositeWord<W, N>, out: WordIdx<W, N>);
fn alloc_constant<W: Word, const N: usize>(
&mut self,
word: CompositeWord<W, N>,
) -> WordIdx<W, N> {
let idx = self.alloc();
self.constant(word, idx);
return idx;
}
fn from_le_words<W: Word, const N: usize>(
&mut self,
ins: [WordIdx<W, 1>; N],
out: WordIdx<W, N>,
);
fn to_le_words<W: Word, const N: usize>(
&mut self,
in_: WordIdx<W, N>,
outs: [WordIdx<W, 1>; N],
);
fn output<W: Word, const N: usize>(&mut self, out: WordIdx<W, N>);
fn increase_refcount<W: Word, const N: usize>(&mut self, idx: WordIdx<W, N>);
fn decrease_refcount<W: Word, const N: usize>(&mut self, idx: WordIdx<W, N>);
fn not<W: Word, const N: usize>(&mut self, in_: WordIdx<W, N>, out: WordIdx<W, N>);
fn bitxor<W: Word, const N: usize>(
&mut self,
inl: WordIdx<W, N>,
inr: WordIdx<W, N>,
out: WordIdx<W, N>,
);
fn bitand<W: Word, const N: usize>(
&mut self,
inl: WordIdx<W, N>,
inr: WordIdx<W, N>,
out: WordIdx<W, N>,
);
fn bitxor_const<W: Word, const N: usize>(
&mut self,
inl: WordIdx<W, N>,
inr: CompositeWord<W, N>,
out: WordIdx<W, N>,
);
fn bitand_const<W: Word, const N: usize>(
&mut self,
inl: WordIdx<W, N>,
inr: CompositeWord<W, N>,
out: WordIdx<W, N>,
);
fn unbounded_shl<W: Word, const N: usize>(
&mut self,
in_: WordIdx<W, N>,
shift: usize,
out: WordIdx<W, N>,
);
fn unbounded_shr<W: Word, const N: usize>(
&mut self,
in_: WordIdx<W, N>,
shift: usize,
out: WordIdx<W, N>,
);
fn rotate_left<W: Word, const N: usize>(
&mut self,
in_: WordIdx<W, N>,
shift: usize,
out: WordIdx<W, N>,
);
fn rotate_right<W: Word, const N: usize>(
&mut self,
in_: WordIdx<W, N>,
shift: usize,
out: WordIdx<W, N>,
);
fn reverse_bits<W: Word, const N: usize>(&mut self, in_: WordIdx<W, N>, out: WordIdx<W, N>);
fn swap_bytes<W: Word, const N: usize>(&mut self, in_: WordIdx<W, N>, out: WordIdx<W, N>);
fn cast<W: Word, T: Word>(&mut self, in_: WordIdx<W, 1>, out: WordIdx<T, 1>);
fn carry<W: Word, const N: usize>(
&mut self,
p: WordIdx<W, N>,
g: WordIdx<W, N>,
carry_in: bool,
out: WordIdx<W, N>,
);
}