Pattern

Trait Pattern 

Source
pub trait Pattern {
    // Required method
    fn info(&self) -> &PatternInfo;

    // Provided methods
    fn name(&self) -> &'static str { ... }
    fn kind(&self) -> &PatternKind { ... }
    fn benefit(&self) -> &PatternBenefit { ... }
    fn has_bounded_rewrite_recursion(&self) -> bool { ... }
    fn generated_ops(&self) -> &[OperationName] { ... }
    fn get_root_operation(&self) -> Option<OperationName> { ... }
    fn get_root_trait(&self) -> Option<TypeId> { ... }
}

Required Methods§

Source

fn info(&self) -> &PatternInfo

Provided Methods§

Source

fn name(&self) -> &'static str

A name used when printing diagnostics related to this pattern

Source

fn kind(&self) -> &PatternKind

The kind of value used to select candidate root operations for this pattern.

Source

fn benefit(&self) -> &PatternBenefit

Returns the benefit - the inverse of “cost” - of matching this pattern.

The benefit of a Pattern is always static - rewrites that may have dynamic benefit can be instantiated multiple times (different instances), for each benefit that they may return, and be guarded by different match condition predicates.

Source

fn has_bounded_rewrite_recursion(&self) -> bool

Returns true if this pattern is known to result in recursive application, i.e. this pattern may generate IR that also matches this pattern, but is known to bound the recursion. This signals to the rewrite driver that it is safe to apply this pattern recursively to the generated IR.

Source

fn generated_ops(&self) -> &[OperationName]

Return a list of operations that may be generated when rewriting an operation instance with this pattern.

Source

fn get_root_operation(&self) -> Option<OperationName>

Return the root operation that this pattern matches.

Patterns that can match multiple root types return None

Source

fn get_root_trait(&self) -> Option<TypeId>

Return the trait id used to match the root operation of this pattern.

If the pattern does not use a trait id for deciding the root match, this returns None

Implementors§