Crate peepmatic[][src]

Expand description

peepmatic is a DSL and compiler for generating peephole optimizers.

The user writes a set of optimizations in the DSL, and then peepmatic compiles the set of optimizations into an efficient peephole optimizer.

Structs

A breadth-first traversal of an AST

A boolean literal.

A condition code.

A symbolic constant.

A depth-first traversal of an AST.

An integer literal.

A left-hand side describes what is required for a particular optimization to apply.

An operation with an operator, and operands of type T.

A complete optimization: a left-hand side to match against and a right-hand side replacement.

A set of optimizations.

A precondition adds additional constraints to a pattern, such as “$C must be a power of two”.

An unquote operation.

A variable that matches any subtree.

A verification or type checking error.

Enums

Contraint operators.

An operand of a precondition’s constraint.

A reference to any AST node.

A structural pattern, potentially with wildcard variables for matching whole subtrees.

The right-hand side of an optimization that contains the instructions to replace any matched left-hand side with.

A low-level DFS traversal event: either entering or exiting the traversal of an AST node.

An integer or boolean value literal.

Traits

A trait implemented by all AST nodes.

Enumerate the child AST nodes of a given node.

A trait for getting the span where an AST node was defined.

Functions

Construct an automaton from a set of linear optimizations.

Compile the given DSL file into a compact peephole optimizations automaton!

Compile the given DSL source text down into a compact peephole optimizations automaton.

Translate the given AST optimizations into linear optimizations.

Ensure that we emit match operations in a consistent order.

99.99% of nops are unnecessary; remove them.

Sort a set of optimizations from least to most general.

Sort the linear optimizations lexicographically.

Verify and type check a set of optimizations.

Type Definitions

Either Ok(T) or Err(VerifyError).