Struct peepmatic_runtime::optimizer::PeepholeOptimizer [−][src]
pub struct PeepholeOptimizer<'peep, 'ctx, TInstructionSet> where
TInstructionSet: InstructionSet<'ctx>, { /* fields omitted */ }
Expand description
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
PeepholeOptimizations::optimizer
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, TInstructionSet> PeepholeOptimizer<'peep, 'ctx, TInstructionSet> where
TInstructionSet: InstructionSet<'ctx>,
impl<'peep, 'ctx, TInstructionSet> PeepholeOptimizer<'peep, 'ctx, TInstructionSet> where
TInstructionSet: InstructionSet<'ctx>,
pub fn apply_one(
&mut self,
context: &mut TInstructionSet::Context,
root: TInstructionSet::Instruction
) -> Option<TInstructionSet::Instruction>
pub fn apply_one(
&mut self,
context: &mut TInstructionSet::Context,
root: TInstructionSet::Instruction
) -> Option<TInstructionSet::Instruction>
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 TInstructionSet::Context,
inst: TInstructionSet::Instruction
)
pub fn apply_all(
&mut self,
context: &mut TInstructionSet::Context,
inst: TInstructionSet::Instruction
)
Keep applying peephole optimizations to the given instruction until none can be applied anymore.