Skip to content

Eqsat pdl interp

eqsat_pdl_interp

A dialect that extends pdl_interp with eqsat-specific operations.

EqSatPDLInterp = Dialect('eqsat_pdl_interp', [GetResultOp, GetResultsOp, GetDefiningOpOp, ReplaceOp, CreateOperationOp, RecordMatchOp, FinalizeOp, ChooseOp]) module-attribute

GetResultOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/eqsat_pdl_interp.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@irdl_op_definition
class GetResultOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_result-pdl_interpgetresultop).
    """

    name = "eqsat_pdl_interp.get_result"
    index = prop_def(IntegerAttr[I32])
    input_op = operand_def(OperationType)
    value = result_def(ValueType)

    assembly_format = "$index `of` $input_op attr-dict"

    def __init__(self, index: int | IntegerAttr[I32], input_op: SSAValue) -> None:
        if isinstance(index, int):
            index = IntegerAttr.from_int_and_width(index, 32)
        super().__init__(
            operands=[input_op], properties={"index": index}, result_types=[ValueType()]
        )

name = 'eqsat_pdl_interp.get_result' class-attribute instance-attribute

index = prop_def(IntegerAttr[I32]) class-attribute instance-attribute

input_op = operand_def(OperationType) class-attribute instance-attribute

value = result_def(ValueType) class-attribute instance-attribute

assembly_format = '$index `of` $input_op attr-dict' class-attribute instance-attribute

__init__(index: int | IntegerAttr[I32], input_op: SSAValue) -> None

Source code in xdsl/dialects/eqsat_pdl_interp.py
59
60
61
62
63
64
def __init__(self, index: int | IntegerAttr[I32], input_op: SSAValue) -> None:
    if isinstance(index, int):
        index = IntegerAttr.from_int_and_width(index, 32)
    super().__init__(
        operands=[input_op], properties={"index": index}, result_types=[ValueType()]
    )

GetResultsOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/eqsat_pdl_interp.py
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
@irdl_op_definition
class GetResultsOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_results-pdl_interpgetresultsop).
    """

    name = "eqsat_pdl_interp.get_results"
    index = opt_prop_def(IntegerAttr[I32])
    input_op = operand_def(OperationType)
    value = result_def(ValueType | RangeType[ValueType])

    # assembly_format = "($index^)? `of` $input_op `:` type($value) attr-dict"
    # TODO: Fix bug preventing this assebmly format from working: https://github.com/xdslproject/xdsl/issues/4136.

    def __init__(
        self,
        index: int | IntegerAttr[I32] | None,
        input_op: SSAValue,
        result_type: ValueType | RangeType[ValueType],
    ) -> None:
        if isinstance(index, int):
            index = IntegerAttr.from_int_and_width(index, 32)
        super().__init__(
            operands=[input_op],
            properties={"index": index},
            result_types=[result_type],
        )

    @classmethod
    def parse(cls, parser: Parser) -> GetResultsOp:
        index = parser.parse_optional_integer()
        if index is not None:
            index = IntegerAttr.from_int_and_width(index, 32)
        parser.parse_characters("of")
        input_op = parser.parse_operand()
        parser.parse_punctuation(":")
        result_type = parser.parse_type()
        return GetResultsOp.build(
            operands=(input_op,),
            properties={"index": index},
            result_types=(result_type,),
        )

    def print(self, printer: Printer):
        if self.index is not None:
            printer.print_string(" ", indent=0)
            self.index.print_without_type(printer)
        printer.print_string(" of ", indent=0)
        printer.print_operand(self.input_op)
        printer.print_string(" : ", indent=0)
        printer.print_attribute(self.value.type)

name = 'eqsat_pdl_interp.get_results' class-attribute instance-attribute

index = opt_prop_def(IntegerAttr[I32]) class-attribute instance-attribute

input_op = operand_def(OperationType) class-attribute instance-attribute

value = result_def(ValueType | RangeType[ValueType]) class-attribute instance-attribute

__init__(index: int | IntegerAttr[I32] | None, input_op: SSAValue, result_type: ValueType | RangeType[ValueType]) -> None

Source code in xdsl/dialects/eqsat_pdl_interp.py
81
82
83
84
85
86
87
88
89
90
91
92
93
def __init__(
    self,
    index: int | IntegerAttr[I32] | None,
    input_op: SSAValue,
    result_type: ValueType | RangeType[ValueType],
) -> None:
    if isinstance(index, int):
        index = IntegerAttr.from_int_and_width(index, 32)
    super().__init__(
        operands=[input_op],
        properties={"index": index},
        result_types=[result_type],
    )

parse(parser: Parser) -> GetResultsOp classmethod

Source code in xdsl/dialects/eqsat_pdl_interp.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
@classmethod
def parse(cls, parser: Parser) -> GetResultsOp:
    index = parser.parse_optional_integer()
    if index is not None:
        index = IntegerAttr.from_int_and_width(index, 32)
    parser.parse_characters("of")
    input_op = parser.parse_operand()
    parser.parse_punctuation(":")
    result_type = parser.parse_type()
    return GetResultsOp.build(
        operands=(input_op,),
        properties={"index": index},
        result_types=(result_type,),
    )

print(printer: Printer)

Source code in xdsl/dialects/eqsat_pdl_interp.py
110
111
112
113
114
115
116
117
def print(self, printer: Printer):
    if self.index is not None:
        printer.print_string(" ", indent=0)
        self.index.print_without_type(printer)
    printer.print_string(" of ", indent=0)
    printer.print_operand(self.input_op)
    printer.print_string(" : ", indent=0)
    printer.print_attribute(self.value.type)

GetDefiningOpOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/eqsat_pdl_interp.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
@irdl_op_definition
class GetDefiningOpOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_defining_op-pdl_interpgetdefiningopop).
    """

    name = "eqsat_pdl_interp.get_defining_op"
    value = operand_def(ValueType | RangeType[ValueType])
    input_op = result_def(OperationType)

    assembly_format = "`of` $value `:` type($value) attr-dict"

    def __init__(self, value: SSAValue) -> None:
        super().__init__(operands=[value], result_types=[OperationType()])

name = 'eqsat_pdl_interp.get_defining_op' class-attribute instance-attribute

value = operand_def(ValueType | RangeType[ValueType]) class-attribute instance-attribute

input_op = result_def(OperationType) class-attribute instance-attribute

assembly_format = '`of` $value `:` type($value) attr-dict' class-attribute instance-attribute

__init__(value: SSAValue) -> None

Source code in xdsl/dialects/eqsat_pdl_interp.py
132
133
def __init__(self, value: SSAValue) -> None:
    super().__init__(operands=[value], result_types=[OperationType()])

ReplaceOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/eqsat_pdl_interp.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
@irdl_op_definition
class ReplaceOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpreplace-pdl_interpreplaceop).
    """

    name = "eqsat_pdl_interp.replace"
    input_op = operand_def(OperationType)
    repl_values = var_operand_def(ValueType | RangeType[ValueType])

    assembly_format = (
        "$input_op `with` ` ` `(` ($repl_values^ `:` type($repl_values))? `)` attr-dict"
    )

    def __init__(self, input_op: SSAValue, repl_values: list[SSAValue]) -> None:
        super().__init__(operands=[input_op, repl_values])

name = 'eqsat_pdl_interp.replace' class-attribute instance-attribute

input_op = operand_def(OperationType) class-attribute instance-attribute

repl_values = var_operand_def(ValueType | RangeType[ValueType]) class-attribute instance-attribute

assembly_format = '$input_op `with` ` ` `(` ($repl_values^ `:` type($repl_values))? `)` attr-dict' class-attribute instance-attribute

__init__(input_op: SSAValue, repl_values: list[SSAValue]) -> None

Source code in xdsl/dialects/eqsat_pdl_interp.py
150
151
def __init__(self, input_op: SSAValue, repl_values: list[SSAValue]) -> None:
    super().__init__(operands=[input_op, repl_values])

CreateOperationOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/eqsat_pdl_interp.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
@irdl_op_definition
class CreateOperationOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcreate_operation-pdl_interpcreateoperationop).
    """

    name = "eqsat_pdl_interp.create_operation"
    constraint_name = prop_def(StringAttr, prop_name="name")
    input_attribute_names = prop_def(
        ArrayAttr[StringAttr], prop_name="inputAttributeNames"
    )
    inferred_result_types = opt_prop_def(UnitAttr, prop_name="inferredResultTypes")

    input_operands = var_operand_def(ValueType | RangeType[ValueType])
    input_attributes = var_operand_def(AttributeType | RangeType[AttributeType])
    input_result_types = var_operand_def(TypeType | RangeType[TypeType])

    result_op = result_def(OperationType)

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    # assembly_format = (
    #     "$name (`(` $input_operands^ `:` type($input_operands) `)`)?"
    #     "` `custom<CreateOperationOpAttributes>($inputAttributes, $inputAttributeNames)"
    #     "custom<CreateOperationOpResults>($inputResultTypes, type($inputResultTypes), $inferredResultTypes)"
    #     "attr-dict"
    # )
    # TODO: this assebly format is unsupported in xDSL because of the `custom` directives.

    def __init__(
        self,
        name: str | StringAttr,
        inferred_result_types: UnitAttr | None = None,
        input_attribute_names: Iterable[StringAttr] | None = None,
        input_operands: Sequence[SSAValue] | None = None,
        input_attributes: Sequence[SSAValue] | None = None,
        input_result_types: Sequence[SSAValue] | None = None,
    ) -> None:
        if isinstance(name, str):
            name = StringAttr(name)
        if input_attribute_names is not None:
            input_attribute_names = ArrayAttr(input_attribute_names)
        if input_attribute_names is None:
            input_attribute_names = ArrayAttr([])

        if input_operands is None:
            input_operands = []
        if input_attributes is None:
            input_attributes = []
        if input_result_types is None:
            input_result_types = []

        super().__init__(
            operands=[input_operands, input_attributes, input_result_types],
            result_types=[OperationType()],
            properties={
                "name": name,
                "inferredResultTypes": inferred_result_types,
                "inputAttributeNames": input_attribute_names,
            }
            if inferred_result_types
            else {
                "name": name,
                "inputAttributeNames": input_attribute_names,
            },
        )

    @staticmethod
    def _parse_attr(parser: Parser) -> tuple[Attribute, SSAValue]:
        attrname = parser.parse_attribute()
        parser.parse_punctuation("=")
        operand = parser.parse_operand()
        return (attrname, operand)

    @staticmethod
    def _parse_input_list(parser: Parser) -> list[SSAValue]:
        values: list[SSAValue] = []
        if parser.parse_optional_punctuation("("):
            values = parser.parse_comma_separated_list(
                delimiter=Parser.Delimiter.NONE,
                parse=lambda: parser.parse_operand(),
            )
            parser.parse_punctuation(":")
            parser.parse_comma_separated_list(
                delimiter=Parser.Delimiter.NONE,
                parse=lambda: parser.parse_type(),
            )
            parser.parse_punctuation(")")
        return values

    @classmethod
    def parse(cls, parser: Parser) -> CreateOperationOp:
        name = parser.parse_attribute()

        input_operands = CreateOperationOp._parse_input_list(parser)

        input_attribute_names = None
        input_attributes = None
        attributes = parser.parse_optional_comma_separated_list(
            delimiter=Parser.Delimiter.BRACES,
            parse=lambda: CreateOperationOp._parse_attr(parser),
        )
        if attributes is not None:
            input_attribute_names = [i[0] for i in attributes]
            input_attributes = [i[1] for i in attributes]
        else:
            input_attribute_names = []
            input_attributes = []
        input_attribute_names = ArrayAttr(input_attribute_names)

        input_result_types = None
        inferred_result_types = None
        if parser.parse_optional_punctuation("->") is not None:
            if parser.parse_optional_punctuation("<"):
                parser.parse_characters("inferred")
                parser.parse_punctuation(">")
                inferred_result_types = UnitAttr()
            else:
                input_result_types = CreateOperationOp._parse_input_list(parser)

        op = CreateOperationOp.build(
            operands=(input_operands, input_attributes, input_result_types),
            properties={
                "name": name,
                "inputAttributeNames": input_attribute_names,
            }
            if inferred_result_types is None
            else {
                "name": name,
                "inferredResultTypes": inferred_result_types,
                "inputAttributeNames": input_attribute_names,
            },
            result_types=(OperationType(),),
        )
        return op

    @staticmethod
    def _print_input_list(printer: Printer, values: Iterable[SSAValue]):
        printer.print_string("(", indent=0)
        printer.print_list(values, printer.print_operand)
        printer.print_string(" : ", indent=0)
        printer.print_list(values, lambda op: printer.print_attribute(op.type))
        printer.print_string(")", indent=0)

    @staticmethod
    def _print_attr(printer: Printer, value: tuple[StringAttr, SSAValue]):
        printer.print_attribute(value[0])
        printer.print_string(" = ", indent=0)
        printer.print_operand(value[1])

    def print(self, printer: Printer):
        printer.print_string(" ", indent=0)
        printer.print_attribute(self.constraint_name)
        if self.input_operands:
            CreateOperationOp._print_input_list(printer, self.input_operands)
        if self.input_attributes:
            printer.print_string(" {", indent=0)
            printer.print_list(
                zip(
                    cast(tuple[StringAttr], self.input_attribute_names.data),
                    self.input_attributes,
                ),
                lambda value: CreateOperationOp._print_attr(printer, value),
            )
            printer.print_string("}", indent=0)
        if self.inferred_result_types:
            assert not self.input_result_types
            printer.print_string(" -> <inferred>", indent=0)
        elif self.input_result_types:
            printer.print_string(" -> ", indent=0)
            CreateOperationOp._print_input_list(printer, self.input_result_types)

name = 'eqsat_pdl_interp.create_operation' class-attribute instance-attribute

constraint_name = prop_def(StringAttr, prop_name='name') class-attribute instance-attribute

input_attribute_names = prop_def(ArrayAttr[StringAttr], prop_name='inputAttributeNames') class-attribute instance-attribute

inferred_result_types = opt_prop_def(UnitAttr, prop_name='inferredResultTypes') class-attribute instance-attribute

input_operands = var_operand_def(ValueType | RangeType[ValueType]) class-attribute instance-attribute

input_attributes = var_operand_def(AttributeType | RangeType[AttributeType]) class-attribute instance-attribute

input_result_types = var_operand_def(TypeType | RangeType[TypeType]) class-attribute instance-attribute

result_op = result_def(OperationType) class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

__init__(name: str | StringAttr, inferred_result_types: UnitAttr | None = None, input_attribute_names: Iterable[StringAttr] | None = None, input_operands: Sequence[SSAValue] | None = None, input_attributes: Sequence[SSAValue] | None = None, input_result_types: Sequence[SSAValue] | None = None) -> None

Source code in xdsl/dialects/eqsat_pdl_interp.py
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
def __init__(
    self,
    name: str | StringAttr,
    inferred_result_types: UnitAttr | None = None,
    input_attribute_names: Iterable[StringAttr] | None = None,
    input_operands: Sequence[SSAValue] | None = None,
    input_attributes: Sequence[SSAValue] | None = None,
    input_result_types: Sequence[SSAValue] | None = None,
) -> None:
    if isinstance(name, str):
        name = StringAttr(name)
    if input_attribute_names is not None:
        input_attribute_names = ArrayAttr(input_attribute_names)
    if input_attribute_names is None:
        input_attribute_names = ArrayAttr([])

    if input_operands is None:
        input_operands = []
    if input_attributes is None:
        input_attributes = []
    if input_result_types is None:
        input_result_types = []

    super().__init__(
        operands=[input_operands, input_attributes, input_result_types],
        result_types=[OperationType()],
        properties={
            "name": name,
            "inferredResultTypes": inferred_result_types,
            "inputAttributeNames": input_attribute_names,
        }
        if inferred_result_types
        else {
            "name": name,
            "inputAttributeNames": input_attribute_names,
        },
    )

parse(parser: Parser) -> CreateOperationOp classmethod

Source code in xdsl/dialects/eqsat_pdl_interp.py
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
@classmethod
def parse(cls, parser: Parser) -> CreateOperationOp:
    name = parser.parse_attribute()

    input_operands = CreateOperationOp._parse_input_list(parser)

    input_attribute_names = None
    input_attributes = None
    attributes = parser.parse_optional_comma_separated_list(
        delimiter=Parser.Delimiter.BRACES,
        parse=lambda: CreateOperationOp._parse_attr(parser),
    )
    if attributes is not None:
        input_attribute_names = [i[0] for i in attributes]
        input_attributes = [i[1] for i in attributes]
    else:
        input_attribute_names = []
        input_attributes = []
    input_attribute_names = ArrayAttr(input_attribute_names)

    input_result_types = None
    inferred_result_types = None
    if parser.parse_optional_punctuation("->") is not None:
        if parser.parse_optional_punctuation("<"):
            parser.parse_characters("inferred")
            parser.parse_punctuation(">")
            inferred_result_types = UnitAttr()
        else:
            input_result_types = CreateOperationOp._parse_input_list(parser)

    op = CreateOperationOp.build(
        operands=(input_operands, input_attributes, input_result_types),
        properties={
            "name": name,
            "inputAttributeNames": input_attribute_names,
        }
        if inferred_result_types is None
        else {
            "name": name,
            "inferredResultTypes": inferred_result_types,
            "inputAttributeNames": input_attribute_names,
        },
        result_types=(OperationType(),),
    )
    return op

print(printer: Printer)

Source code in xdsl/dialects/eqsat_pdl_interp.py
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
def print(self, printer: Printer):
    printer.print_string(" ", indent=0)
    printer.print_attribute(self.constraint_name)
    if self.input_operands:
        CreateOperationOp._print_input_list(printer, self.input_operands)
    if self.input_attributes:
        printer.print_string(" {", indent=0)
        printer.print_list(
            zip(
                cast(tuple[StringAttr], self.input_attribute_names.data),
                self.input_attributes,
            ),
            lambda value: CreateOperationOp._print_attr(printer, value),
        )
        printer.print_string("}", indent=0)
    if self.inferred_result_types:
        assert not self.input_result_types
        printer.print_string(" -> <inferred>", indent=0)
    elif self.input_result_types:
        printer.print_string(" -> ", indent=0)
        CreateOperationOp._print_input_list(printer, self.input_result_types)

RecordMatchOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/eqsat_pdl_interp.py
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
@irdl_op_definition
class RecordMatchOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interprecord_match-pdl_interprecordmatchop).
    """

    name = "eqsat_pdl_interp.record_match"
    traits = traits_def(IsTerminator())
    rewriter = prop_def(SymbolRefAttr)
    rootKind = opt_prop_def(StringAttr)
    generatedOps = opt_prop_def(ArrayAttr[StringAttr])
    benefit = prop_def(IntegerAttr[I16])

    inputs = var_operand_def(AnyPDLTypeConstr)
    matched_ops = var_operand_def(OperationType)

    dest = successor_def()

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    assembly_format = (
        "$rewriter (`(` $inputs^ `:` type($inputs) `)`)? `:` `benefit` `(` $benefit `)` `,`"
        "(`generatedOps` `(` $generatedOps^ `)` `,`)? `loc` `(` `[` $matched_ops `]` `)`"
        "(`,` `root` `(` $rootKind^ `)`)? attr-dict `->` $dest"
    )

    def __init__(
        self,
        rewriter: str | SymbolRefAttr,
        root_kind: str | StringAttr | None,
        generated_ops: ArrayAttr[StringAttr] | None,
        benefit: int | IntegerAttr[I16],
        inputs: Sequence[SSAValue],
        matched_ops: Sequence[SSAValue],
        dest: Block,
    ) -> None:
        if isinstance(rewriter, str):
            rewriter = SymbolRefAttr(rewriter)
        if isinstance(root_kind, str):
            root_kind = StringAttr(root_kind)
        if isinstance(benefit, int):
            benefit = IntegerAttr.from_int_and_width(benefit, 16)
        super().__init__(
            operands=[inputs, matched_ops],
            properties={
                "rewriter": rewriter,
                "rootKind": root_kind,
                "generatedOps": generated_ops,
                "benefit": benefit,
            },
            successors=[dest],
        )

name = 'eqsat_pdl_interp.record_match' class-attribute instance-attribute

traits = traits_def(IsTerminator()) class-attribute instance-attribute

rewriter = prop_def(SymbolRefAttr) class-attribute instance-attribute

rootKind = opt_prop_def(StringAttr) class-attribute instance-attribute

generatedOps = opt_prop_def(ArrayAttr[StringAttr]) class-attribute instance-attribute

benefit = prop_def(IntegerAttr[I16]) class-attribute instance-attribute

inputs = var_operand_def(AnyPDLTypeConstr) class-attribute instance-attribute

matched_ops = var_operand_def(OperationType) class-attribute instance-attribute

dest = successor_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

assembly_format = '$rewriter (`(` $inputs^ `:` type($inputs) `)`)? `:` `benefit` `(` $benefit `)` `,`(`generatedOps` `(` $generatedOps^ `)` `,`)? `loc` `(` `[` $matched_ops `]` `)`(`,` `root` `(` $rootKind^ `)`)? attr-dict `->` $dest' class-attribute instance-attribute

__init__(rewriter: str | SymbolRefAttr, root_kind: str | StringAttr | None, generated_ops: ArrayAttr[StringAttr] | None, benefit: int | IntegerAttr[I16], inputs: Sequence[SSAValue], matched_ops: Sequence[SSAValue], dest: Block) -> None

Source code in xdsl/dialects/eqsat_pdl_interp.py
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
def __init__(
    self,
    rewriter: str | SymbolRefAttr,
    root_kind: str | StringAttr | None,
    generated_ops: ArrayAttr[StringAttr] | None,
    benefit: int | IntegerAttr[I16],
    inputs: Sequence[SSAValue],
    matched_ops: Sequence[SSAValue],
    dest: Block,
) -> None:
    if isinstance(rewriter, str):
        rewriter = SymbolRefAttr(rewriter)
    if isinstance(root_kind, str):
        root_kind = StringAttr(root_kind)
    if isinstance(benefit, int):
        benefit = IntegerAttr.from_int_and_width(benefit, 16)
    super().__init__(
        operands=[inputs, matched_ops],
        properties={
            "rewriter": rewriter,
            "rootKind": root_kind,
            "generatedOps": generated_ops,
            "benefit": benefit,
        },
        successors=[dest],
    )

FinalizeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/eqsat_pdl_interp.py
381
382
383
384
385
386
387
388
389
390
391
392
393
@irdl_op_definition
class FinalizeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpfinalize-pdl_interpfinalizeop).
    """

    name = "eqsat_pdl_interp.finalize"
    traits = traits_def(IsTerminator())

    assembly_format = "attr-dict"

    def __init__(self):
        super().__init__()

name = 'eqsat_pdl_interp.finalize' class-attribute instance-attribute

traits = traits_def(IsTerminator()) class-attribute instance-attribute

assembly_format = 'attr-dict' class-attribute instance-attribute

__init__()

Source code in xdsl/dialects/eqsat_pdl_interp.py
392
393
def __init__(self):
    super().__init__()

ChooseOp

Bases: IRDLOperation

This operation can be used in pdl_interp matchers and integrates with the backtracking mechanism. It holds multiple "choices" (successors). When this operation is encountered, a BacktrackPoint is stored, and the choice is visited. When this execution of this choice eventually finalizes, the backtracking logic will jump to the next choice, until all choices are exhausted. Finally, the default successor is visited.

Source code in xdsl/dialects/eqsat_pdl_interp.py
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
@irdl_op_definition
class ChooseOp(IRDLOperation):
    """
    This operation can be used in pdl_interp matchers and
    integrates with the backtracking mechanism. It holds multiple
    "choices" (successors). When this operation is encountered,
    a BacktrackPoint is stored, and the choice is visited.
    When this execution of this choice eventually finalizes, the
    backtracking logic will jump to the next choice, until all
    choices are exhausted. Finally, the default successor is visited.
    """

    name = "eqsat_pdl_interp.choose"
    default_dest = successor_def()
    choices = var_successor_def()
    traits = traits_def(IsTerminator())
    assembly_format = "`from` $choices `then` $default_dest attr-dict"

    def __init__(self, choices: Sequence[Block], default: Block):
        super().__init__(
            successors=[default, choices],
        )

name = 'eqsat_pdl_interp.choose' class-attribute instance-attribute

default_dest = successor_def() class-attribute instance-attribute

choices = var_successor_def() class-attribute instance-attribute

traits = traits_def(IsTerminator()) class-attribute instance-attribute

assembly_format = '`from` $choices `then` $default_dest attr-dict' class-attribute instance-attribute

__init__(choices: Sequence[Block], default: Block)

Source code in xdsl/dialects/eqsat_pdl_interp.py
414
415
416
417
def __init__(self, choices: Sequence[Block], default: Block):
    super().__init__(
        successors=[default, choices],
    )