pub(crate) struct UnusedMemoryOptimizer<F: AcirField> {
unused_memory_initializations: HashSet<BlockId>,
circuit: Circuit<F>,
}Expand description
UnusedMemoryOptimizer will remove initializations of memory blocks which are unused.
A first pass collects all memory blocks which are initialized but discards the ones
which are used in a MemoryOp or as input to a BrilligCall.
The second pass removes the opcodes tagged as unused by the first pass.
Fields§
§unused_memory_initializations: HashSet<BlockId>§circuit: Circuit<F>Implementations§
Source§impl<F: AcirField> UnusedMemoryOptimizer<F>
impl<F: AcirField> UnusedMemoryOptimizer<F>
Sourcepub(crate) fn new(circuit: Circuit<F>) -> Self
pub(crate) fn new(circuit: Circuit<F>) -> Self
Creates a new UnusedMemoryOptimizer by collecting unused memory init
opcodes from Circuit.
Sourcefn collect_unused_memory_initializations(
circuit: &Circuit<F>,
) -> HashSet<BlockId>
fn collect_unused_memory_initializations( circuit: &Circuit<F>, ) -> HashSet<BlockId>
Creates a set of ids for memory blocks for which no [Opcode::MemoryOp]s exist.
These memory blocks can be safely removed.
Auto Trait Implementations§
impl<F> Freeze for UnusedMemoryOptimizer<F>
impl<F> RefUnwindSafe for UnusedMemoryOptimizer<F>where
F: RefUnwindSafe,
impl<F> Send for UnusedMemoryOptimizer<F>where
F: Send,
impl<F> Sync for UnusedMemoryOptimizer<F>where
F: Sync,
impl<F> Unpin for UnusedMemoryOptimizer<F>where
F: Unpin,
impl<F> UnwindSafe for UnusedMemoryOptimizer<F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more