Trait orzir_core::RewritePattern

source ·
pub trait RewritePattern<Rewriter: PatternRewriter> {
    // Required methods
    fn matches(&self, ctx: &Context, op: ArenaPtr<OpObj>) -> RewriteResult<()>;
    fn rewrite(
        &self,
        ctx: &mut Context,
        op: ArenaPtr<OpObj>,
        rewriter: &Rewriter
    ) -> RewriteResult<()>;
}
Expand description

A pattern for rewriting operations.

TODO: design a better API for this.

Required Methods§

source

fn matches(&self, ctx: &Context, op: ArenaPtr<OpObj>) -> RewriteResult<()>

Try to match the pattern with the given operation.

source

fn rewrite( &self, ctx: &mut Context, op: ArenaPtr<OpObj>, rewriter: &Rewriter ) -> RewriteResult<()>

Rewrite the operation with the pattern.

Implementors§