Struct cranelift_isle::ir::PatternSequence
source · pub struct PatternSequence {
pub insts: Vec<PatternInst>,
}
Expand description
A linear sequence of instructions that match on and destructure an
argument. A pattern is fallible (may not match). If it does not fail, its
result consists of the values produced by the PatternInst
s, which may be
used by a subsequent Expr
.
Fields§
§insts: Vec<PatternInst>
Instruction sequence for pattern.
InstId
indexes into this sequence for Value::Pattern
values.
Trait Implementations§
source§impl Clone for PatternSequence
impl Clone for PatternSequence
source§fn clone(&self) -> PatternSequence
fn clone(&self) -> PatternSequence
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PatternSequence
impl Debug for PatternSequence
source§impl Default for PatternSequence
impl Default for PatternSequence
source§fn default() -> PatternSequence
fn default() -> PatternSequence
Returns the “default value” for a type. Read more
source§impl Hash for PatternSequence
impl Hash for PatternSequence
source§impl PartialEq<PatternSequence> for PatternSequence
impl PartialEq<PatternSequence> for PatternSequence
source§fn eq(&self, other: &PatternSequence) -> bool
fn eq(&self, other: &PatternSequence) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PatternVisitor for PatternSequence
impl PatternVisitor for PatternSequence
source§fn add_match_equal(&mut self, a: Value, b: Value, ty: TypeId)
fn add_match_equal(&mut self, a: Value, b: Value, ty: TypeId)
Match if
a
and b
have equal values.source§fn add_match_int(&mut self, input: Value, ty: TypeId, int_val: i128)
fn add_match_int(&mut self, input: Value, ty: TypeId, int_val: i128)
Match if
input
is the given integer constant.source§fn add_match_prim(&mut self, input: Value, ty: TypeId, val: Sym)
fn add_match_prim(&mut self, input: Value, ty: TypeId, val: Sym)
Match if
input
is the given primitive constant.source§fn add_match_variant(
&mut self,
input: Value,
input_ty: TypeId,
arg_tys: &[TypeId],
variant: VariantId
) -> Vec<Value>
fn add_match_variant( &mut self, input: Value, input_ty: TypeId, arg_tys: &[TypeId], variant: VariantId ) -> Vec<Value>
Match if
input
is the given enum variant. Returns an identifier for each field within the
enum variant. The length of the return list must equal the length of arg_tys
.source§fn add_extract(
&mut self,
input: Value,
input_ty: TypeId,
output_tys: Vec<TypeId>,
term: TermId,
infallible: bool,
multi: bool
) -> Vec<Value>
fn add_extract( &mut self, input: Value, input_ty: TypeId, output_tys: Vec<TypeId>, term: TermId, infallible: bool, multi: bool ) -> Vec<Value>
Match if the given external extractor succeeds on
input
. Returns an identifier for each
return value from the external extractor. The length of the return list must equal the
length of output_tys
.source§impl RuleVisitor for PatternSequence
impl RuleVisitor for PatternSequence
§type PatternVisitor = PatternSequence
type PatternVisitor = PatternSequence
The type of pattern visitors constructed by RuleVisitor::add_pattern.
§type ExprVisitor = ExprSequence
type ExprVisitor = ExprSequence
The type of expression visitors constructed by RuleVisitor::add_expr.
§type Expr = ReturnExpr
type Expr = ReturnExpr
The type returned from RuleVisitor::add_expr, which may be exchanged for a subpattern
identifier using RuleVisitor::expr_as_pattern.
source§fn add_arg(&mut self, index: usize, ty: TypeId) -> Value
fn add_arg(&mut self, index: usize, ty: TypeId) -> Value
Visit one of the arguments to the top-level pattern.
source§fn add_pattern<F: FnOnce(&mut Self)>(&mut self, visitor: F)
fn add_pattern<F: FnOnce(&mut Self)>(&mut self, visitor: F)
Visit a pattern, used once for the rule’s left-hand side and once for each if-let. You can
determine which part of the rule the pattern comes from based on whether the
PatternId
passed to the first call to this visitor came from add_arg
or expr_as_pattern
.source§fn add_expr<F>(&mut self, visitor: F) -> ReturnExprwhere
F: FnOnce(&mut ExprSequence) -> VisitedExpr<ExprSequence>,
fn add_expr<F>(&mut self, visitor: F) -> ReturnExprwhere F: FnOnce(&mut ExprSequence) -> VisitedExpr<ExprSequence>,
Visit an expression, used once for each if-let and once for the rule’s right-hand side.
source§fn expr_as_pattern(&mut self, expr: ReturnExpr) -> Value
fn expr_as_pattern(&mut self, expr: ReturnExpr) -> Value
Given an expression from RuleVisitor::add_expr, return an identifier that can be used with
a pattern visitor in RuleVisitor::add_pattern.
source§fn pattern_as_expr(&mut self, pattern: Value) -> Value
fn pattern_as_expr(&mut self, pattern: Value) -> Value
Given an identifier from the pattern visitor, return an identifier that can be used with
the expression visitor.