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§
- Bfs
- A breadth-first traversal of an AST
- Boolean
- A boolean literal.
- Condition
Code - A condition code.
- Constant
- A symbolic constant.
- Dfs
- A depth-first traversal of an AST.
- Integer
- An integer literal.
- Lhs
- A left-hand side describes what is required for a particular optimization to apply.
- Operation
- An operation with an operator, and operands of type
T
. - Optimization
- A complete optimization: a left-hand side to match against and a right-hand side replacement.
- Optimizations
- A set of optimizations.
- Precondition
- A precondition adds additional constraints to a pattern, such as “$C must be a power of two”.
- Unquote
- An unquote operation.
- Variable
- A variable that matches any subtree.
- Verify
Error - A verification or type checking error.
Enums§
- Constraint
- Contraint operators.
- Constraint
Operand - An operand of a precondition’s constraint.
- DynAst
Ref - A reference to any AST node.
- Pattern
- A structural pattern, potentially with wildcard variables for matching whole subtrees.
- Rhs
- The right-hand side of an optimization that contains the instructions to replace any matched left-hand side with.
- Traversal
Event - A low-level DFS traversal event: either entering or exiting the traversal of an AST node.
- Value
Literal - An integer or boolean value literal.
Traits§
- Ast
- A trait implemented by all AST nodes.
- Child
Nodes - Enumerate the child AST nodes of a given node.
- Span
- A trait for getting the span where an AST node was defined.
Functions§
- automatize
- Construct an automaton from a set of linear optimizations.
- compile_
file - Compile the given DSL file into a compact peephole optimizations automaton!
- compile_
str - Compile the given DSL source text down into a compact peephole optimizations automaton.
- linearize
- Translate the given AST optimizations into linear optimizations.
- match_
in_ same_ order - Ensure that we emit match operations in a consistent order.
- remove_
unnecessary_ nops - 99.99% of nops are unnecessary; remove them.
- sort_
least_ to_ most_ general - Sort a set of optimizations from least to most general.
- sort_
lexicographically - Sort the linear optimizations lexicographically.
- verify
- Verify and type check a set of optimizations.
Type Aliases§
- Verify
Result - Either
Ok(T)
orErr(VerifyError)
.