MLIR

Multi-Level IR Compiler Framework

'pdl_interp' Dialect

Interpreted pattern execution dialect The PDL Interpreter dialect provides a lower level abstraction compared to the PDL dialect, and is targeted towards low level optimization and interpreter code generation. The dialect operations encapsulates low-level pattern match and rewrite “primitives”, such as navigating the IR (Operation::getOperand), creating new operations (OpBuilder::create), etc. Many of the operations within this dialect also fuse branching control flow with some form of a predicate comparison operation. This type of fusion reduces the amount of work that an interpreter must do when executing.

Operations 

source

pdl_interp.apply_constraint (pdl_interp::ApplyConstraintOp) 

Apply a constraint to a set of positional values

Syntax:

operation ::= `pdl_interp.apply_constraint` $name `(` $args `:` type($args) `)` (`:` type($results)^)? attr-dict
              `->` successors

pdl_interp.apply_constraint operations apply a generic constraint, that has been registered with the interpreter, with a given set of positional values. The constraint function may return any number of results. On success, this operation branches to the true destination, otherwise the false destination is taken. This behavior can be reversed by setting the attribute isNegated to true.

Example:

// Apply `myConstraint` to the entities defined by `input`, `attr`, and
// `op`.
pdl_interp.apply_constraint "myConstraint"(%input, %attr, %op : !pdl.value, !pdl.attribute, !pdl.operation) -> ^matchDest, ^failureDest

Traits: Terminator

Attributes: 

AttributeMLIR TypeDescription
name::mlir::StringAttrstring attribute
isNegated::mlir::BoolAttrbool attribute

Operands: 

OperandDescription
argsvariadic of pdl type

Results: 

ResultDescription
resultsvariadic of pdl type

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.apply_rewrite (pdl_interp::ApplyRewriteOp) 

Invoke and apply an externally registered rewrite method

Syntax:

operation ::= `pdl_interp.apply_rewrite` $name (`(` $args^ `:` type($args) `)`)? (`:` type($results)^)? attr-dict

pdl_interp.apply_rewrite operations invoke an external rewriter that has been registered with the interpreter to perform the rewrite after a successful match. The rewrite is passed a set of positional arguments. The rewrite function may return any number of results.

Example:

// Rewriter operating solely on the root operation.
pdl_interp.apply_rewrite "rewriter"(%root : !pdl.operation)

// Rewriter operating solely on the root operation and return an attribute.
%attr = pdl_interp.apply_rewrite "rewriter"(%root : !pdl.operation) : !pdl.attribute

// Rewriter operating on the root operation along with additional arguments
// from the matcher.
pdl_interp.apply_rewrite "rewriter"(%root : !pdl.operation, %value : !pdl.value)

Attributes: 

AttributeMLIR TypeDescription
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
argsvariadic of pdl type

Results: 

ResultDescription
resultsvariadic of pdl type

pdl_interp.are_equal (pdl_interp::AreEqualOp) 

Check if two positional values or ranges are equivalent

Syntax:

operation ::= `pdl_interp.are_equal` operands `:` type($lhs) attr-dict `->` successors

pdl_interp.are_equal operations compare two positional values for equality. On success, this operation branches to the true destination, otherwise the false destination is taken.

Example:

pdl_interp.are_equal %result1, %result2 : !pdl.value -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, SameTypeOperands, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
lhspdl type
rhspdl type

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.branch (pdl_interp::BranchOp) 

General branch operation

Syntax:

operation ::= `pdl_interp.branch` $dest attr-dict

pdl_interp.branch operations expose general branch functionality to the interpreter, and are generally used to branch from one pattern match sequence to another.

Example:

pdl_interp.branch ^dest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Successors: 

SuccessorDescription
destany successor

pdl_interp.check_attribute (pdl_interp::CheckAttributeOp) 

Check the value of an Attribute

Syntax:

operation ::= `pdl_interp.check_attribute` $attribute `is` $constantValue attr-dict `->` successors

pdl_interp.check_attribute operations compare the value of a given attribute with a constant value. On success, this operation branches to the true destination, otherwise the false destination is taken.

Example:

pdl_interp.check_attribute %attr is 10 -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
constantValue::mlir::Attributeany attribute

Operands: 

OperandDescription
attributePDL handle to an mlir::Attribute

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.check_operand_count (pdl_interp::CheckOperandCountOp) 

Check the number of operands of an Operation

Syntax:

operation ::= `pdl_interp.check_operand_count` `of` $inputOp `is` (`at_least` $compareAtLeast^)? $count attr-dict
              `->` successors

pdl_interp.check_operand_count operations compare the number of operands of a given operation value with a constant. The comparison is either exact or at_least, with the latter used to compare against a minimum number of expected operands. On success, this operation branches to the true destination, otherwise the false destination is taken.

Example:

// Check for exact equality.
pdl_interp.check_operand_count of %op is 2 -> ^matchDest, ^failureDest

// Check for at least N operands.
pdl_interp.check_operand_count of %op is at_least 2 -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
count::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative
compareAtLeast::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.check_operation_name (pdl_interp::CheckOperationNameOp) 

Check the OperationName of an Operation

Syntax:

operation ::= `pdl_interp.check_operation_name` `of` $inputOp `is` $name attr-dict `->` successors

pdl_interp.check_operation_name operations compare the name of a given operation with a known name. On success, this operation branches to the true destination, otherwise the false destination is taken.

Example:

pdl_interp.check_operation_name of %op is "foo.op" -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.check_result_count (pdl_interp::CheckResultCountOp) 

Check the number of results of an Operation

Syntax:

operation ::= `pdl_interp.check_result_count` `of` $inputOp `is` (`at_least` $compareAtLeast^)? $count attr-dict
              `->` successors

pdl_interp.check_result_count operations compare the number of results of a given operation value with a constant. The comparison is either exact or at_least, with the latter used to compare against a minimum number of expected results. On success, this operation branches to the true destination, otherwise the false destination is taken.

Example:

// Check for exact equality.
pdl_interp.check_result_count of %op is 2 -> ^matchDest, ^failureDest

// Check for at least N results.
pdl_interp.check_result_count of %op is at_least 2 -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
count::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative
compareAtLeast::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.check_type (pdl_interp::CheckTypeOp) 

Compare a type to a known value

Syntax:

operation ::= `pdl_interp.check_type` $value `is` $type attr-dict `->` successors

pdl_interp.check_type operations compare a type with a statically known type. On success, this operation branches to the true destination, otherwise the false destination is taken.

Example:

pdl_interp.check_type %type is i32 -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
type::mlir::TypeAttrany type attribute

Operands: 

OperandDescription
valuePDL handle to an mlir::Type

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.check_types (pdl_interp::CheckTypesOp) 

Compare a range of types to a range of known values

Syntax:

operation ::= `pdl_interp.check_types` $value `are` $types attr-dict `->` successors

pdl_interp.check_types operations compare a range of types with a statically known range of types. On success, this operation branches to the true destination, otherwise the false destination is taken.

Example:

pdl_interp.check_types %type are [i32, i64] -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
types::mlir::ArrayAttrtype array attribute

Operands: 

OperandDescription
valuerange of PDL handle to an mlir::Type values

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.continue (pdl_interp::ContinueOp) 

Breaks the current iteration

Syntax:

operation ::= `pdl_interp.continue` attr-dict

pdl_interp.continue operation breaks the current iteration within the pdl_interp.foreach region and continues with the next iteration from the beginning of the region.

Example:

pdl_interp.continue

Traits: AlwaysSpeculatableImplTrait, HasParent<ForEachOp>, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

pdl_interp.create_attribute (pdl_interp::CreateAttributeOp) 

Create an interpreter handle to a constant Attribute

Syntax:

operation ::= `pdl_interp.create_attribute` $value attr-dict-with-keyword

pdl_interp.create_attribute operations generate a handle within the interpreter for a specific constant attribute value.

Example:

%attr = pdl_interp.create_attribute 10 : i64

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
value::mlir::Attributeany attribute

Results: 

ResultDescription
attributePDL handle to an mlir::Attribute

pdl_interp.create_operation (pdl_interp::CreateOperationOp) 

Create an instance of a specific Operation

Syntax:

operation ::= `pdl_interp.create_operation` $name (`(` $inputOperands^ `:` type($inputOperands) `)`)? ``
              custom<CreateOperationOpAttributes>($inputAttributes, $inputAttributeNames)
              custom<CreateOperationOpResults>($inputResultTypes, type($inputResultTypes),
              $inferredResultTypes)
              attr-dict

pdl_interp.create_operation operations create an Operation instance with the specified attributes, operands, and result types. See pdl.operation for a more detailed description on the general interpretation of the arguments to this operation.

Example:

// Create an instance of a `foo.op` operation.
%op = pdl_interp.create_operation "foo.op"(%arg0 : !pdl.value) {"attrA" = %attr0} -> (%type : !pdl.type)

// Create an instance of a `foo.op` operation that has inferred result types
// (using the InferTypeOpInterface).
%op = pdl_interp.create_operation "foo.op"(%arg0 : !pdl.value) {"attrA" = %attr0} -> <inferred>

Traits: AttrSizedOperandSegments

Attributes: 

AttributeMLIR TypeDescription
name::mlir::StringAttrstring attribute
inputAttributeNames::mlir::ArrayAttrstring array attribute
inferredResultTypes::mlir::UnitAttrunit attribute

Operands: 

OperandDescription
inputOperandsvariadic of single element or range of PDL handle for an mlir::Value
inputAttributesvariadic of PDL handle to an mlir::Attribute
inputResultTypesvariadic of single element or range of PDL handle to an mlir::Type

Results: 

ResultDescription
resultOpPDL handle to an mlir::Operation *

pdl_interp.create_range (pdl_interp::CreateRangeOp) 

Construct a range of PDL entities

Syntax:

operation ::= `pdl_interp.create_range` ($arguments^ `:` type($arguments))?
              custom<RangeType>(ref(type($arguments)), type($result))
              attr-dict

pdl_interp.create_range operations construct a range from a given set of PDL entities, which all share the same underlying element type. For example, a !pdl.range<value> may be constructed from a list of !pdl.value or !pdl.range<value> entities.

Example:

// Construct a range of values.
%valueRange = pdl_interp.create_range %inputValue, %inputRange : !pdl.value, !pdl.range<value>

// Construct a range of types.
%typeRange = pdl_interp.create_range %inputType, %inputRange : !pdl.type, !pdl.range<type>

// Construct an empty range of types.
%valueRange = pdl_interp.create_range : !pdl.range<type>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
argumentsvariadic of pdl type

Results: 

ResultDescription
resultrange of PDL handle to an mlir::Type or PDL handle for an mlir::Value values

pdl_interp.create_type (pdl_interp::CreateTypeOp) 

Create an interpreter handle to a constant Type

Syntax:

operation ::= `pdl_interp.create_type` $value attr-dict

pdl_interp.create_type operations generate a handle within the interpreter for a specific constant type value.

Example:

pdl_interp.create_type i64

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
value::mlir::TypeAttrany type attribute

Results: 

ResultDescription
resultPDL handle to an mlir::Type

pdl_interp.create_types (pdl_interp::CreateTypesOp) 

Create an interpreter handle to a range of constant Types

Syntax:

operation ::= `pdl_interp.create_types` $value attr-dict

pdl_interp.create_types operations generate a handle within the interpreter for a specific range of constant type values.

Example:

pdl_interp.create_types [i64, i64]

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
value::mlir::ArrayAttrtype array attribute

Results: 

ResultDescription
resultrange of PDL handle to an mlir::Type values

pdl_interp.erase (pdl_interp::EraseOp) 

Mark an operation as erased

Syntax:

operation ::= `pdl_interp.erase` $inputOp attr-dict

pdl.erase operations are used to specify that an operation should be marked as erased. The semantics of this operation correspond with the eraseOp method on a PatternRewriter.

Example:

pdl_interp.erase %root

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

pdl_interp.extract (pdl_interp::ExtractOp) 

Extract the item at the specified index in a range

Syntax:

operation ::= `pdl_interp.extract` $index `of` $range `:` type($result) attr-dict

pdl_interp.extract operations are used to extract an item from a range at the specified index. If the index is out of range, returns null.

Example:

// Extract the value at index 1 from a range of values.
%ops = pdl_interp.extract 1 of %values : !pdl.value

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
index::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative

Operands: 

OperandDescription
rangerange of pdl type values

Results: 

ResultDescription
resultpdl type

pdl_interp.finalize (pdl_interp::FinalizeOp) 

Finalize a pattern match or rewrite sequence

Syntax:

operation ::= `pdl_interp.finalize` attr-dict

pdl_interp.finalize is used to denote the termination of a match or rewrite sequence.

Example:

pdl_interp.finalize

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

pdl_interp.foreach (pdl_interp::ForEachOp) 

Iterates over a range of values or ranges

pdl_interp.foreach iteratively selects an element from a range of values and executes the region until pdl.continue is reached.

In the bytecode interpreter, this operation is implemented by looping over the values and, for each selection, running the bytecode until we reach pdl.continue. This may result in multiple matches being reported. Note that the input range is mutated (popped from).

Example:

pdl_interp.foreach %op : !pdl.operation in %ops {
  pdl_interp.continue
} -> ^next

Traits: Terminator

Operands: 

OperandDescription
valuesrange of pdl type values

Successors: 

SuccessorDescription
successorany successor

pdl_interp.func (pdl_interp::FuncOp) 

PDL Interpreter Function Operation

pdl_interp.func operations act as interpreter functions. These are callable SSA-region operations that contain other interpreter operations. Interpreter functions are used for both the matching and the rewriting portion of the interpreter.

Example:

pdl_interp.func @rewriter(%root: !pdl.operation) {
  %op = pdl_interp.create_operation "foo.new_operation"
  pdl_interp.erase %root
  pdl_interp.finalize
}

Traits: IsolatedFromAbove

Interfaces: CallableOpInterface, FunctionOpInterface, Symbol

Attributes: 

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute
function_type::mlir::TypeAttrtype attribute of function type
arg_attrs::mlir::ArrayAttrArray of dictionary attributes
res_attrs::mlir::ArrayAttrArray of dictionary attributes

pdl_interp.get_attribute (pdl_interp::GetAttributeOp) 

Get a specified attribute value from an Operation

Syntax:

operation ::= `pdl_interp.get_attribute` $name `of` $inputOp attr-dict

pdl_interp.get_attribute operations try to get a specific attribute from an operation. If the operation does not have that attribute, a null value is returned.

Example:

%attr = pdl_interp.get_attribute "attr" of %op

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
name::mlir::StringAttrstring attribute

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Results: 

ResultDescription
attributePDL handle to an mlir::Attribute

pdl_interp.get_attribute_type (pdl_interp::GetAttributeTypeOp) 

Get the result type of a specified Attribute

Syntax:

operation ::= `pdl_interp.get_attribute_type` `of` $value attr-dict

pdl_interp.get_attribute_type operations get the resulting type of a specific attribute.

Example:

%type = pdl_interp.get_attribute_type of %attr

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
valuePDL handle to an mlir::Attribute

Results: 

ResultDescription
resultPDL handle to an mlir::Type

pdl_interp.get_defining_op (pdl_interp::GetDefiningOpOp) 

Get the defining operation of a Value

Syntax:

operation ::= `pdl_interp.get_defining_op` `of` $value `:` type($value) attr-dict

pdl_interp.get_defining_op operations try to get the defining operation of a specific value or range of values. In the case of range, the defining op of the first value is returned. If the value is not an operation result or range of operand results, null is returned.

Example:

%op = pdl_interp.get_defining_op of %value : !pdl.value

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
valuesingle element or range of PDL handle for an mlir::Value

Results: 

ResultDescription
inputOpPDL handle to an mlir::Operation *

pdl_interp.get_operand (pdl_interp::GetOperandOp) 

Get a specified operand from an Operation

Syntax:

operation ::= `pdl_interp.get_operand` $index `of` $inputOp attr-dict

pdl_interp.get_operand operations try to get a specific operand from an operation If the operation does not have an operand for the given index, a null value is returned.

Example:

%operand = pdl_interp.get_operand 1 of %op

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
index::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Results: 

ResultDescription
valuePDL handle for an mlir::Value

pdl_interp.get_operands (pdl_interp::GetOperandsOp) 

Get a specified operand group from an Operation

Syntax:

operation ::= `pdl_interp.get_operands` ($index^)? `of` $inputOp `:` type($value) attr-dict

pdl_interp.get_operands operations try to get a specific operand group from an operation. If the expected result is a single Value, null is returned if the operand group is not of size 1. If a range is expected, null is returned if the operand group is invalid. If no index is provided, the returned operand group corresponds to all operands of the operation.

Example:

// Get the first group of operands from an operation, and expect a single
// element.
%operand = pdl_interp.get_operands 0 of %op : !pdl.value

// Get the first group of operands from an operation.
%operands = pdl_interp.get_operands 0 of %op : !pdl.range<value>

// Get all of the operands from an operation.
%operands = pdl_interp.get_operands of %op : !pdl.range<value>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
index::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Results: 

ResultDescription
valuesingle element or range of PDL handle for an mlir::Value

pdl_interp.get_result (pdl_interp::GetResultOp) 

Get a specified result from an Operation

Syntax:

operation ::= `pdl_interp.get_result` $index `of` $inputOp attr-dict

pdl_interp.get_result operations try to get a specific result from an operation. If the operation does not have a result for the given index, a null value is returned.

Example:

%result = pdl_interp.get_result 1 of %op

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
index::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Results: 

ResultDescription
valuePDL handle for an mlir::Value

pdl_interp.get_results (pdl_interp::GetResultsOp) 

Get a specified result group from an Operation

Syntax:

operation ::= `pdl_interp.get_results` ($index^)? `of` $inputOp `:` type($value) attr-dict

pdl_interp.get_results operations try to get a specific result group from an operation. If the expected result is a single Value, null is returned if the result group is not of size 1. If a range is expected, null is returned if the result group is invalid. If no index is provided, the returned operand group corresponds to all results of the operation.

Example:

// Get the first group of results from an operation, and expect a single
// element.
%result = pdl_interp.get_results 0 of %op : !pdl.value

// Get the first group of results from an operation.
%results = pdl_interp.get_results 0 of %op : !pdl.range<value>

// Get all of the results from an operation.
%results = pdl_interp.get_results of %op : !pdl.range<value>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
index::mlir::IntegerAttr32-bit signless integer attribute whose value is non-negative

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Results: 

ResultDescription
valuesingle element or range of PDL handle for an mlir::Value

pdl_interp.get_users (pdl_interp::GetUsersOp) 

Get the users of a Value

Syntax:

operation ::= `pdl_interp.get_users` `of` $value `:` type($value) attr-dict

pdl_interp.get_users extracts the users that accept this value. In the case of a range, the union of users of the all the values are returned, similarly to ResultRange::getUsers.

Example:

// Get all the users of a single value.
%ops = pdl_interp.get_users of %value : !pdl.value

// Get all the users of the first value in a range.
%ops = pdl_interp.get_users of %values : !pdl.range<value>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
valuesingle element or range of PDL handle for an mlir::Value

Results: 

ResultDescription
operationsrange of PDL handle to an mlir::Operation * values

pdl_interp.get_value_type (pdl_interp::GetValueTypeOp) 

Get the result type of a specified Value

Syntax:

operation ::= `pdl_interp.get_value_type` `of` $value `:` type($result) attr-dict

pdl_interp.get_value_type operations get the resulting type of a specific value or range thereof.

Example:

// Get the type of a single value.
%type = pdl_interp.get_value_type of %value : !pdl.type

// Get the types of a value range.
%type = pdl_interp.get_value_type of %values : !pdl.range<type>

Traits: AlwaysSpeculatableImplTrait

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
valuesingle element or range of PDL handle for an mlir::Value

Results: 

ResultDescription
resultsingle element or range of PDL handle to an mlir::Type

pdl_interp.is_not_null (pdl_interp::IsNotNullOp) 

Check if a positional value is non-null

Syntax:

operation ::= `pdl_interp.is_not_null` $value `:` type($value) attr-dict `->` successors

pdl_interp.is_not_null operations check that a positional value or range exists. For ranges, this does not mean that the range was simply empty. On success, this operation branches to the true destination. Otherwise, the false destination is taken.

Example:

pdl_interp.is_not_null %value : !pdl.value -> ^matchDest, ^failureDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Operands: 

OperandDescription
valuepdl type

Successors: 

SuccessorDescription
trueDestany successor
falseDestany successor

pdl_interp.record_match (pdl_interp::RecordMatchOp) 

Record the metadata for a successful pattern match

Syntax:

operation ::= `pdl_interp.record_match` $rewriter (`(` $inputs^ `:` type($inputs) `)`)? `:`
              `benefit` `(` $benefit `)` `,`
              (`generatedOps` `(` $generatedOps^ `)` `,`)?
              `loc` `(` `[` $matchedOps `]` `)`
              (`,` `root` `(` $rootKind^ `)`)? attr-dict `->` $dest

pdl_interp.record_match operations record a successful pattern match with the interpreter and branch to the next part of the matcher. The metadata recorded by these operations correspond to a specific pdl.pattern, as well as what values were used during that match that should be propagated to the rewriter.

Example:

pdl_interp.record_match @rewriters::myRewriter(%root : !pdl.operation) : benefit(1), loc([%root, %op1]), root("foo.op") -> ^nextDest

Traits: AttrSizedOperandSegments, Terminator

Attributes: 

AttributeMLIR TypeDescription
rewriter::mlir::SymbolRefAttrsymbol reference attribute
rootKind::mlir::StringAttrstring attribute
generatedOps::mlir::ArrayAttrstring array attribute
benefit::mlir::IntegerAttr16-bit signless integer attribute whose value is non-negative

Operands: 

OperandDescription
inputsvariadic of pdl type
matchedOpsvariadic of PDL handle to an mlir::Operation *

Successors: 

SuccessorDescription
destany successor

pdl_interp.replace (pdl_interp::ReplaceOp) 

Mark an operation as replaced

Syntax:

operation ::= `pdl_interp.replace` $inputOp `with` ` ` `(` ($replValues^ `:` type($replValues))? `)`
              attr-dict

pdl_interp.replaced operations are used to specify that an operation should be marked as replaced. The semantics of this operation correspond with the replaceOp method on a PatternRewriter. The set of replacement values must match the number of results specified by the operation.

Example:

// Replace root node with 2 values:
pdl_interp.replace %root with (%val0, %val1 : !pdl.type, !pdl.type)

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *
replValuesvariadic of single element or range of PDL handle for an mlir::Value

pdl_interp.switch_attribute (pdl_interp::SwitchAttributeOp) 

Switch on the value of an Attribute

Syntax:

operation ::= `pdl_interp.switch_attribute` $attribute `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest

pdl_interp.switch_attribute operations compare the value of a given attribute with a set of constant attributes. If the value matches one of the provided case values the destination for that case value is taken, otherwise the default destination is taken.

Example:

pdl_interp.switch_attribute %attr to [10, true](^10Dest, ^trueDest) -> ^defaultDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
caseValues::mlir::ArrayAttrarray attribute

Operands: 

OperandDescription
attributePDL handle to an mlir::Attribute

Successors: 

SuccessorDescription
defaultDestany successor
casesany successor

pdl_interp.switch_operand_count (pdl_interp::SwitchOperandCountOp) 

Switch on the operand count of an Operation

Syntax:

operation ::= `pdl_interp.switch_operand_count` `of` $inputOp `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest

pdl_interp.switch_operand_count operations compare the operand count of a given operation with a set of potential counts. If the value matches one of the provided case values the destination for that case value is taken, otherwise the default destination is taken.

Example:

pdl_interp.switch_operand_count of %op to [10, 2] -> ^10Dest, ^2Dest, ^defaultDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
caseValues::mlir::DenseIntElementsAttr32-bit signless integer elements attribute

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Successors: 

SuccessorDescription
defaultDestany successor
casesany successor

pdl_interp.switch_operation_name (pdl_interp::SwitchOperationNameOp) 

Switch on the OperationName of an Operation

Syntax:

operation ::= `pdl_interp.switch_operation_name` `of` $inputOp `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest

pdl_interp.switch_operation_name operations compare the name of a given operation with a set of known names. If the value matches one of the provided case values the destination for that case value is taken, otherwise the default destination is taken.

Example:

pdl_interp.switch_operation_name of %op to ["foo.op", "bar.op"](^fooDest, ^barDest) -> ^defaultDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
caseValues::mlir::ArrayAttrstring array attribute

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Successors: 

SuccessorDescription
defaultDestany successor
casesany successor

pdl_interp.switch_result_count (pdl_interp::SwitchResultCountOp) 

Switch on the result count of an Operation

Syntax:

operation ::= `pdl_interp.switch_result_count` `of` $inputOp `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest

pdl_interp.switch_result_count operations compare the result count of a given operation with a set of potential counts. If the value matches one of the provided case values the destination for that case value is taken, otherwise the default destination is taken.

Example:

pdl_interp.switch_result_count of %op to [0, 2](^0Dest, ^2Dest) -> ^defaultDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
caseValues::mlir::DenseIntElementsAttr32-bit signless integer elements attribute

Operands: 

OperandDescription
inputOpPDL handle to an mlir::Operation *

Successors: 

SuccessorDescription
defaultDestany successor
casesany successor

pdl_interp.switch_type (pdl_interp::SwitchTypeOp) 

Switch on a Type value

Syntax:

operation ::= `pdl_interp.switch_type` $value `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest

pdl_interp.switch_type operations compare a type with a set of statically known types. If the value matches one of the provided case values the destination for that case value is taken, otherwise the default destination is taken.

Example:

pdl_interp.switch_type %type to [i32, i64] -> ^i32Dest, ^i64Dest, ^defaultDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
caseValues::mlir::ArrayAttrtype array attribute

Operands: 

OperandDescription
valuePDL handle to an mlir::Type

Successors: 

SuccessorDescription
defaultDestany successor
casesany successor

pdl_interp.switch_types (pdl_interp::SwitchTypesOp) 

Switch on a range of Type values

Syntax:

operation ::= `pdl_interp.switch_types` $value `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest

pdl_interp.switch_types operations compare a range of types with a set of statically known ranges. If the value matches one of the provided case values the destination for that case value is taken, otherwise the default destination is taken.

Example:

pdl_interp.switch_types %type is [[i32], [i64, i64]] -> ^i32Dest, ^i64Dest, ^defaultDest

Traits: AlwaysSpeculatableImplTrait, Terminator

Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{}

Attributes: 

AttributeMLIR TypeDescription
caseValues::mlir::ArrayAttrtype-array array attribute

Operands: 

OperandDescription
valuerange of PDL handle to an mlir::Type values

Successors: 

SuccessorDescription
defaultDestany successor
casesany successor