[][src]Struct peepmatic_runtime::optimizer::PeepholeOptimizer

pub struct PeepholeOptimizer<'peep, 'ctx, I> where
    I: InstructionSet<'ctx>, 
{ /* fields omitted */ }

A peephole optimizer instance that can apply a set of peephole optimizations to instructions.

These are created from a set of peephole optimizations with the [PeepholeOptimizer::instance][crate::PeepholeOptimizer::instance] method.

Reusing an instance when applying peephole optimizations to different instruction sequences means that you reuse internal allocations that are used to match left-hand sides and build up right-hand sides.

Implementations

impl<'peep, 'ctx, I> PeepholeOptimizer<'peep, 'ctx, I> where
    I: InstructionSet<'ctx>, 
[src]

pub fn apply_one(
    &mut self,
    context: &mut I::Context,
    root: I::Instruction
) -> Option<I::Instruction>
[src]

Attempt to apply a single peephole optimization to the given root instruction.

If an optimization is applied, then the root is replaced with the optimization's right-hand side, and the root of the right-hand side is returned as Some.

If no optimization's left-hand side matches root, then root is left untouched and None is returned.

pub fn apply_all(&mut self, context: &mut I::Context, inst: I::Instruction)[src]

Keep applying peephole optimizations to the given instruction until none can be applied anymore.

Trait Implementations

impl<'peep, 'ctx, I> Debug for PeepholeOptimizer<'peep, 'ctx, I> where
    I: InstructionSet<'ctx>, 
[src]

Auto Trait Implementations

impl<'peep, 'ctx, I> !RefUnwindSafe for PeepholeOptimizer<'peep, 'ctx, I>

impl<'peep, 'ctx, I> !Send for PeepholeOptimizer<'peep, 'ctx, I>

impl<'peep, 'ctx, I> !Sync for PeepholeOptimizer<'peep, 'ctx, I>

impl<'peep, 'ctx, I> Unpin for PeepholeOptimizer<'peep, 'ctx, I> where
    I: Unpin,
    <I as InstructionSet<'ctx>>::Instruction: Unpin

impl<'peep, 'ctx, I> !UnwindSafe for PeepholeOptimizer<'peep, 'ctx, I>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.