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§
fn info(&self) -> &PatternInfo
Provided Methods§
Sourcefn kind(&self) -> &PatternKind
fn kind(&self) -> &PatternKind
The kind of value used to select candidate root operations for this pattern.
Sourcefn benefit(&self) -> &PatternBenefit
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.
Sourcefn has_bounded_rewrite_recursion(&self) -> bool
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.
Sourcefn generated_ops(&self) -> &[OperationName]
fn generated_ops(&self) -> &[OperationName]
Return a list of operations that may be generated when rewriting an operation instance with this pattern.
Sourcefn get_root_operation(&self) -> Option<OperationName>
fn get_root_operation(&self) -> Option<OperationName>
Return the root operation that this pattern matches.
Patterns that can match multiple root types return None
Sourcefn get_root_trait(&self) -> Option<TypeId>
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