Skip to content

Pdl interp

pdl_interp

boolLike = ContainerOf(IntegerType(1)) module-attribute

signlessIntegerLike = ContainerOf(AnyOf([IntegerType, IndexType])) module-attribute

floatingPointLike = ContainerOf(AnyOf([Float16Type, Float32Type, Float64Type])) module-attribute

PDLInterp = Dialect('pdl_interp', [GetOperandOp, GetOperandsOp, FinalizeOp, CheckOperationNameOp, CheckOperandCountOp, CheckResultCountOp, CheckTypeOp, CheckTypesOp, IsNotNullOp, GetResultOp, GetResultsOp, GetAttributeOp, GetAttributeTypeOp, CheckAttributeOp, AreEqualOp, ApplyConstraintOp, ApplyRewriteOp, RecordMatchOp, GetValueTypeOp, ReplaceOp, EraseOp, CreateAttributeOp, CreateOperationOp, CreateRangeOp, SwitchOperationNameOp, SwitchOperandCountOp, SwitchResultCountOp, SwitchTypeOp, SwitchTypesOp, SwitchAttributeOp, CreateTypeOp, CreateTypesOp, FuncOp, GetDefiningOpOp, ForEachOp, ContinueOp, BranchOp]) module-attribute

GetOperandOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
@irdl_op_definition
class GetOperandOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_operand-pdl_interpgetoperandop).
    """

    name = "pdl_interp.get_operand"
    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(index, i32)
        super().__init__(
            operands=[input_op], properties={"index": index}, result_types=[ValueType()]
        )

name = 'pdl_interp.get_operand' 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/pdl_interp.py
112
113
114
115
116
117
def __init__(self, index: int | IntegerAttr[I32], input_op: SSAValue) -> None:
    if isinstance(index, int):
        index = IntegerAttr(index, i32)
    super().__init__(
        operands=[input_op], properties={"index": index}, result_types=[ValueType()]
    )

GetOperandsOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@irdl_op_definition
class GetOperandsOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_operands-pdl_interpgetoperandsop).
    """

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

    # TODO: assembly format doesn't work due to a bug:
    # https://github.com/xdslproject/xdsl/issues/5562
    # assembly_format = "($index^)? `of` $input_op `:` type($value) attr-dict"

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

    @classmethod
    def parse(cls, parser: Parser) -> GetOperandsOp:
        index = parser.parse_optional_integer()
        if index is not None:
            index = IntegerAttr(index, 32)
        parser.parse_characters("of")
        input_op = parser.parse_operand()
        parser.parse_punctuation(":")
        result_type = parser.parse_type()
        return GetOperandsOp.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 = 'pdl_interp.get_operands' 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/pdl_interp.py
135
136
137
138
139
140
141
142
143
144
145
146
147
def __init__(
    self,
    index: int | IntegerAttr[I32] | None,
    input_op: SSAValue,
    result_type: ValueType | RangeType[ValueType],
) -> None:
    if isinstance(index, int):
        index = IntegerAttr(index, i32)
    super().__init__(
        operands=[input_op],
        properties={"index": index},
        result_types=[result_type],
    )

parse(parser: Parser) -> GetOperandsOp classmethod

Source code in xdsl/dialects/pdl_interp.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@classmethod
def parse(cls, parser: Parser) -> GetOperandsOp:
    index = parser.parse_optional_integer()
    if index is not None:
        index = IntegerAttr(index, 32)
    parser.parse_characters("of")
    input_op = parser.parse_operand()
    parser.parse_punctuation(":")
    result_type = parser.parse_type()
    return GetOperandsOp.build(
        operands=(input_op,),
        properties={"index": index},
        result_types=(result_type,),
    )

print(printer: Printer)

Source code in xdsl/dialects/pdl_interp.py
164
165
166
167
168
169
170
171
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)

FinalizeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
174
175
176
177
178
179
180
181
182
183
184
185
186
@irdl_op_definition
class FinalizeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpfinalize-pdl_interpfinalizeop).
    """

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

    assembly_format = "attr-dict"

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

name = '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/pdl_interp.py
185
186
def __init__(self):
    super().__init__()

CheckOperationNameOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
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
@irdl_op_definition
class CheckOperationNameOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcheck_operation_name-pdl_interpcheckoperationnameop).
    """

    name = "pdl_interp.check_operation_name"
    traits = traits_def(IsTerminator())
    operation_name = prop_def(StringAttr, prop_name="name")
    input_op = operand_def(OperationType)
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = (
        "`of` $input_op `is` $name attr-dict `->` $true_dest `, ` $false_dest"
    )

    def __init__(
        self,
        operation_name: str | StringAttr,
        input_op: SSAValue,
        trueDest: Block,
        falseDest: Block,
    ) -> None:
        if isinstance(operation_name, str):
            operation_name = StringAttr(operation_name)
        super().__init__(
            operands=[input_op],
            properties={"name": operation_name},
            successors=[trueDest, falseDest],
        )

name = 'pdl_interp.check_operation_name' class-attribute instance-attribute

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

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

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

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '`of` $input_op `is` $name attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(operation_name: str | StringAttr, input_op: SSAValue, trueDest: Block, falseDest: Block) -> None

Source code in xdsl/dialects/pdl_interp.py
206
207
208
209
210
211
212
213
214
215
216
217
218
219
def __init__(
    self,
    operation_name: str | StringAttr,
    input_op: SSAValue,
    trueDest: Block,
    falseDest: Block,
) -> None:
    if isinstance(operation_name, str):
        operation_name = StringAttr(operation_name)
    super().__init__(
        operands=[input_op],
        properties={"name": operation_name},
        successors=[trueDest, falseDest],
    )

CheckOperandCountOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
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
@irdl_op_definition
class CheckOperandCountOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcheck_operand_count-pdl_interpcheckoperandcountop).
    """

    name = "pdl_interp.check_operand_count"
    traits = traits_def(IsTerminator())
    input_op = operand_def(OperationType)
    count = prop_def(IntegerAttr[I32])
    compareAtLeast = opt_prop_def(UnitAttr)
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = "`of` $input_op `is` (`at_least` $compareAtLeast^)? $count attr-dict `->` $true_dest `, ` $false_dest"

    def __init__(
        self,
        input_op: SSAValue,
        count: int | IntegerAttr[I32],
        trueDest: Block,
        falseDest: Block,
        compareAtLeast: bool = False,
    ) -> None:
        if isinstance(count, int):
            count = IntegerAttr(count, i32)
        properties = dict[str, Attribute](count=count)
        if compareAtLeast:
            properties["compareAtLeast"] = UnitAttr()
        super().__init__(
            operands=[input_op],
            properties=properties,
            successors=[trueDest, falseDest],
        )

name = 'pdl_interp.check_operand_count' class-attribute instance-attribute

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

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

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

compareAtLeast = opt_prop_def(UnitAttr) class-attribute instance-attribute

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '`of` $input_op `is` (`at_least` $compareAtLeast^)? $count attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(input_op: SSAValue, count: int | IntegerAttr[I32], trueDest: Block, falseDest: Block, compareAtLeast: bool = False) -> None

Source code in xdsl/dialects/pdl_interp.py
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
def __init__(
    self,
    input_op: SSAValue,
    count: int | IntegerAttr[I32],
    trueDest: Block,
    falseDest: Block,
    compareAtLeast: bool = False,
) -> None:
    if isinstance(count, int):
        count = IntegerAttr(count, i32)
    properties = dict[str, Attribute](count=count)
    if compareAtLeast:
        properties["compareAtLeast"] = UnitAttr()
    super().__init__(
        operands=[input_op],
        properties=properties,
        successors=[trueDest, falseDest],
    )

CheckResultCountOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
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
@irdl_op_definition
class CheckResultCountOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcheck_result_count-pdl_interpcheckresultcountop).
    """

    name = "pdl_interp.check_result_count"
    traits = traits_def(IsTerminator())
    input_op = operand_def(OperationType)
    count = prop_def(IntegerAttr[I32])
    compareAtLeast = opt_prop_def(UnitAttr)
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = "`of` $input_op `is` (`at_least` $compareAtLeast^)? $count attr-dict `->` $true_dest `, ` $false_dest"

    def __init__(
        self,
        input_op: SSAValue,
        count: int | IntegerAttr[I32],
        trueDest: Block,
        falseDest: Block,
        compareAtLeast: bool = False,
    ) -> None:
        if isinstance(count, int):
            count = IntegerAttr(count, i32)
        properties = dict[str, Attribute](count=count)
        if compareAtLeast:
            properties["compareAtLeast"] = UnitAttr()
        super().__init__(
            operands=[input_op],
            properties=properties,
            successors=[trueDest, falseDest],
        )

name = 'pdl_interp.check_result_count' class-attribute instance-attribute

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

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

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

compareAtLeast = opt_prop_def(UnitAttr) class-attribute instance-attribute

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '`of` $input_op `is` (`at_least` $compareAtLeast^)? $count attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(input_op: SSAValue, count: int | IntegerAttr[I32], trueDest: Block, falseDest: Block, compareAtLeast: bool = False) -> None

Source code in xdsl/dialects/pdl_interp.py
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
def __init__(
    self,
    input_op: SSAValue,
    count: int | IntegerAttr[I32],
    trueDest: Block,
    falseDest: Block,
    compareAtLeast: bool = False,
) -> None:
    if isinstance(count, int):
        count = IntegerAttr(count, i32)
    properties = dict[str, Attribute](count=count)
    if compareAtLeast:
        properties["compareAtLeast"] = UnitAttr()
    super().__init__(
        operands=[input_op],
        properties=properties,
        successors=[trueDest, falseDest],
    )

IsNotNullOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
@irdl_op_definition
class IsNotNullOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpis_not_null-pdl_interpisnotnullop).
    """

    name = "pdl_interp.is_not_null"
    traits = traits_def(IsTerminator())
    value = operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType]))
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = (
        "$value `:` type($value) attr-dict `->` $true_dest `, ` $false_dest"
    )

    def __init__(self, value: SSAValue, trueDest: Block, falseDest: Block) -> None:
        super().__init__(operands=[value], successors=[trueDest, falseDest])

name = 'pdl_interp.is_not_null' class-attribute instance-attribute

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

value = operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType])) class-attribute instance-attribute

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '$value `:` type($value) attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(value: SSAValue, trueDest: Block, falseDest: Block) -> None

Source code in xdsl/dialects/pdl_interp.py
310
311
def __init__(self, value: SSAValue, trueDest: Block, falseDest: Block) -> None:
    super().__init__(operands=[value], successors=[trueDest, falseDest])

GetResultOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
@irdl_op_definition
class GetResultOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_result-pdl_interpgetresultop).
    """

    name = "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(index, i32)
        super().__init__(
            operands=[input_op], properties={"index": index}, result_types=[ValueType()]
        )

name = '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/pdl_interp.py
327
328
329
330
331
332
def __init__(self, index: int | IntegerAttr[I32], input_op: SSAValue) -> None:
    if isinstance(index, int):
        index = IntegerAttr(index, i32)
    super().__init__(
        operands=[input_op], properties={"index": index}, result_types=[ValueType()]
    )

GetResultsOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
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
379
380
381
382
383
384
385
@irdl_op_definition
class GetResultsOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_results-pdl_interpgetresultsop).
    """

    name = "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(index, i32)
        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(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 = '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/pdl_interp.py
349
350
351
352
353
354
355
356
357
358
359
360
361
def __init__(
    self,
    index: int | IntegerAttr[I32] | None,
    input_op: SSAValue,
    result_type: ValueType | RangeType[ValueType],
) -> None:
    if isinstance(index, int):
        index = IntegerAttr(index, i32)
    super().__init__(
        operands=[input_op],
        properties={"index": index},
        result_types=[result_type],
    )

parse(parser: Parser) -> GetResultsOp classmethod

Source code in xdsl/dialects/pdl_interp.py
363
364
365
366
367
368
369
370
371
372
373
374
375
376
@classmethod
def parse(cls, parser: Parser) -> GetResultsOp:
    index = parser.parse_optional_integer()
    if index is not None:
        index = IntegerAttr(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/pdl_interp.py
378
379
380
381
382
383
384
385
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)

GetAttributeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
@irdl_op_definition
class GetAttributeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_attribute-pdl_interpgetattributeop).
    """

    name = "pdl_interp.get_attribute"
    constraint_name = prop_def(StringAttr, prop_name="name")
    input_op = operand_def(OperationType)
    value = result_def(AttributeType)

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

    def __init__(self, name: str | StringAttr, input_op: SSAValue) -> None:
        if isinstance(name, str):
            name = StringAttr(name)
        super().__init__(
            operands=[input_op],
            properties={"name": name},
            result_types=[AttributeType()],
        )

name = 'pdl_interp.get_attribute' class-attribute instance-attribute

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

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

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

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

__init__(name: str | StringAttr, input_op: SSAValue) -> None

Source code in xdsl/dialects/pdl_interp.py
401
402
403
404
405
406
407
408
def __init__(self, name: str | StringAttr, input_op: SSAValue) -> None:
    if isinstance(name, str):
        name = StringAttr(name)
    super().__init__(
        operands=[input_op],
        properties={"name": name},
        result_types=[AttributeType()],
    )

GetAttributeTypeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
@irdl_op_definition
class GetAttributeTypeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_attribute_type-pdl_interpgetattributetypeop).
    """

    name = "pdl_interp.get_attribute_type"
    value = operand_def(AttributeType)
    result = result_def(TypeType)

    assembly_format = "`of` $value attr-dict"

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

name = 'pdl_interp.get_attribute_type' class-attribute instance-attribute

value = operand_def(AttributeType) class-attribute instance-attribute

result = result_def(TypeType) class-attribute instance-attribute

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

__init__(value: SSAValue) -> None

Source code in xdsl/dialects/pdl_interp.py
423
424
425
426
427
def __init__(self, value: SSAValue) -> None:
    super().__init__(
        operands=[value],
        result_types=[TypeType()],
    )

CheckAttributeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
@irdl_op_definition
class CheckAttributeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcheck_attribute-pdl_interpcheckattributeop).
    """

    name = "pdl_interp.check_attribute"
    traits = traits_def(IsTerminator())
    constantValue = prop_def()
    attribute = operand_def(AttributeType)
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = (
        "$attribute `is` $constantValue attr-dict `->` $true_dest `, ` $false_dest"
    )

    def __init__(
        self,
        constantValue: Attribute,
        attribute: SSAValue,
        trueDest: Block,
        falseDest: Block,
    ) -> None:
        super().__init__(
            operands=[attribute],
            properties={"constantValue": constantValue},
            successors=[trueDest, falseDest],
        )

name = 'pdl_interp.check_attribute' class-attribute instance-attribute

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

constantValue = prop_def() class-attribute instance-attribute

attribute = operand_def(AttributeType) class-attribute instance-attribute

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '$attribute `is` $constantValue attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(constantValue: Attribute, attribute: SSAValue, trueDest: Block, falseDest: Block) -> None

Source code in xdsl/dialects/pdl_interp.py
447
448
449
450
451
452
453
454
455
456
457
458
def __init__(
    self,
    constantValue: Attribute,
    attribute: SSAValue,
    trueDest: Block,
    falseDest: Block,
) -> None:
    super().__init__(
        operands=[attribute],
        properties={"constantValue": constantValue},
        successors=[trueDest, falseDest],
    )

CheckTypeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
@irdl_op_definition
class CheckTypeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcheck_type-pdl_interpchecktypeop).
    """

    name = "pdl_interp.check_type"
    traits = traits_def(IsTerminator())
    type = prop_def(TypeAttribute)
    value = operand_def(TypeType)
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = "$value `is` $type attr-dict `->` $true_dest `, ` $false_dest"

    def __init__(
        self, type: TypeAttribute, value: SSAValue, trueDest: Block, falseDest: Block
    ) -> None:
        super().__init__(
            operands=[value],
            properties={"type": type},
            successors=[trueDest, falseDest],
        )

name = 'pdl_interp.check_type' class-attribute instance-attribute

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

type = prop_def(TypeAttribute) class-attribute instance-attribute

value = operand_def(TypeType) class-attribute instance-attribute

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '$value `is` $type attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(type: TypeAttribute, value: SSAValue, trueDest: Block, falseDest: Block) -> None

Source code in xdsl/dialects/pdl_interp.py
476
477
478
479
480
481
482
483
def __init__(
    self, type: TypeAttribute, value: SSAValue, trueDest: Block, falseDest: Block
) -> None:
    super().__init__(
        operands=[value],
        properties={"type": type},
        successors=[trueDest, falseDest],
    )

CheckTypesOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
@irdl_op_definition
class CheckTypesOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcheck_types-pdl_interpchecktypesop).
    """

    name = "pdl_interp.check_types"
    traits = traits_def(IsTerminator())
    types = prop_def(ArrayAttr[TypeAttribute])
    value = operand_def(RangeType[TypeType])
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = "$value `are` $types attr-dict `->` $true_dest `, ` $false_dest"

    def __init__(
        self,
        types: ArrayAttr[TypeAttribute] | Sequence[TypeAttribute],
        value: SSAValue,
        trueDest: Block,
        falseDest: Block,
    ) -> None:
        if not isinstance(types, ArrayAttr):
            types = ArrayAttr(types)
        super().__init__(
            operands=[value],
            properties={"types": types},
            successors=[trueDest, falseDest],
        )

name = 'pdl_interp.check_types' class-attribute instance-attribute

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

types = prop_def(ArrayAttr[TypeAttribute]) class-attribute instance-attribute

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

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '$value `are` $types attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(types: ArrayAttr[TypeAttribute] | Sequence[TypeAttribute], value: SSAValue, trueDest: Block, falseDest: Block) -> None

Source code in xdsl/dialects/pdl_interp.py
501
502
503
504
505
506
507
508
509
510
511
512
513
514
def __init__(
    self,
    types: ArrayAttr[TypeAttribute] | Sequence[TypeAttribute],
    value: SSAValue,
    trueDest: Block,
    falseDest: Block,
) -> None:
    if not isinstance(types, ArrayAttr):
        types = ArrayAttr(types)
    super().__init__(
        operands=[value],
        properties={"types": types},
        successors=[trueDest, falseDest],
    )

AreEqualOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
@irdl_op_definition
class AreEqualOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpare_equal-pdl_interpareequalop).
    """

    name = "pdl_interp.are_equal"
    traits = traits_def(IsTerminator())
    T: ClassVar = VarConstraint("T", AnyPDLTypeConstr | base(RangeType[AnyPDLType]))
    lhs = operand_def(T)
    rhs = operand_def(T)
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = (
        "operands `:` type($lhs) attr-dict `->` $true_dest `, ` $false_dest"
    )

    def __init__(
        self, lhs: SSAValue, rhs: SSAValue, trueDest: Block, falseDest: Block
    ) -> None:
        super().__init__(operands=[lhs, rhs], successors=[trueDest, falseDest])

name = 'pdl_interp.are_equal' class-attribute instance-attribute

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

T: ClassVar = VarConstraint('T', AnyPDLTypeConstr | base(RangeType[AnyPDLType])) class-attribute instance-attribute

lhs = operand_def(T) class-attribute instance-attribute

rhs = operand_def(T) class-attribute instance-attribute

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = 'operands `:` type($lhs) attr-dict `->` $true_dest `, ` $false_dest' class-attribute instance-attribute

__init__(lhs: SSAValue, rhs: SSAValue, trueDest: Block, falseDest: Block) -> None

Source code in xdsl/dialects/pdl_interp.py
535
536
537
538
def __init__(
    self, lhs: SSAValue, rhs: SSAValue, trueDest: Block, falseDest: Block
) -> None:
    super().__init__(operands=[lhs, rhs], successors=[trueDest, falseDest])

ApplyConstraintOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
@irdl_op_definition
class ApplyConstraintOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpapply_constraint-pdl_interpapplyconstraintop).
    """

    name = "pdl_interp.apply_constraint"
    traits = traits_def(IsTerminator())
    constraint_name = prop_def(StringAttr, prop_name="name")
    is_negated = prop_def(
        BoolAttr, prop_name="isNegated", default_value=BoolAttr.from_bool(False)
    )
    args = var_operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType]))
    results_ = var_result_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType]))
    true_dest = successor_def()
    false_dest = successor_def()
    irdl_options = (ParsePropInAttrDict(),)

    assembly_format = "$name `(` $args `:` type($args) `)` (`:` type($results_)^)? attr-dict `->` $true_dest `,` $false_dest"

    def __init__(
        self,
        constraint_name: str | StringAttr,
        args: Sequence[SSAValue],
        true_dest: Block,
        false_dest: Block,
        res_types: Sequence[AnyPDLType | RangeType[AnyPDLType]] = (),
        is_negated: bool | BoolAttr = False,
    ) -> None:
        if isinstance(constraint_name, str):
            constraint_name = StringAttr(constraint_name)
        if isinstance(is_negated, bool):
            is_negated = BoolAttr.from_bool(is_negated)
        super().__init__(
            operands=[args],
            properties={
                "name": constraint_name,
                "isNegated": is_negated,
            },
            result_types=[
                res_types,
            ],
            successors=[true_dest, false_dest],
        )

name = 'pdl_interp.apply_constraint' class-attribute instance-attribute

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

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

is_negated = prop_def(BoolAttr, prop_name='isNegated', default_value=(BoolAttr.from_bool(False))) class-attribute instance-attribute

args = var_operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType])) class-attribute instance-attribute

results_ = var_result_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType])) class-attribute instance-attribute

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

irdl_options = (ParsePropInAttrDict(),) class-attribute instance-attribute

assembly_format = '$name `(` $args `:` type($args) `)` (`:` type($results_)^)? attr-dict `->` $true_dest `,` $false_dest' class-attribute instance-attribute

__init__(constraint_name: str | StringAttr, args: Sequence[SSAValue], true_dest: Block, false_dest: Block, res_types: Sequence[AnyPDLType | RangeType[AnyPDLType]] = (), is_negated: bool | BoolAttr = False) -> None

Source code in xdsl/dialects/pdl_interp.py
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
def __init__(
    self,
    constraint_name: str | StringAttr,
    args: Sequence[SSAValue],
    true_dest: Block,
    false_dest: Block,
    res_types: Sequence[AnyPDLType | RangeType[AnyPDLType]] = (),
    is_negated: bool | BoolAttr = False,
) -> None:
    if isinstance(constraint_name, str):
        constraint_name = StringAttr(constraint_name)
    if isinstance(is_negated, bool):
        is_negated = BoolAttr.from_bool(is_negated)
    super().__init__(
        operands=[args],
        properties={
            "name": constraint_name,
            "isNegated": is_negated,
        },
        result_types=[
            res_types,
        ],
        successors=[true_dest, false_dest],
    )

ApplyRewriteOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
@irdl_op_definition
class ApplyRewriteOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpapply_rewrite-pdl_interpapplyrewriteop).
    """

    name = "pdl_interp.apply_rewrite"
    rewrite_name = prop_def(StringAttr, prop_name="name")
    args = var_operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType]))
    results_ = var_result_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType]))
    irdl_options = (ParsePropInAttrDict(),)

    assembly_format = (
        "$name (`(` $args^ `:` type($args) `)`)? (`:` type($results_)^)? attr-dict"
    )

    def __init__(
        self,
        rewrite_name: str | StringAttr,
        args: Sequence[SSAValue],
        res_types: Sequence[AnyPDLType | RangeType[AnyPDLType]] = (),
    ) -> None:
        if isinstance(rewrite_name, str):
            rewrite_name = StringAttr(rewrite_name)
        super().__init__(
            operands=[args],
            properties={
                "name": rewrite_name,
            },
            result_types=[
                res_types,
            ],
        )

name = 'pdl_interp.apply_rewrite' class-attribute instance-attribute

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

args = var_operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType])) class-attribute instance-attribute

results_ = var_result_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType])) class-attribute instance-attribute

irdl_options = (ParsePropInAttrDict(),) class-attribute instance-attribute

assembly_format = '$name (`(` $args^ `:` type($args) `)`)? (`:` type($results_)^)? attr-dict' class-attribute instance-attribute

__init__(rewrite_name: str | StringAttr, args: Sequence[SSAValue], res_types: Sequence[AnyPDLType | RangeType[AnyPDLType]] = ()) -> None

Source code in xdsl/dialects/pdl_interp.py
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
def __init__(
    self,
    rewrite_name: str | StringAttr,
    args: Sequence[SSAValue],
    res_types: Sequence[AnyPDLType | RangeType[AnyPDLType]] = (),
) -> None:
    if isinstance(rewrite_name, str):
        rewrite_name = StringAttr(rewrite_name)
    super().__init__(
        operands=[args],
        properties={
            "name": rewrite_name,
        },
        result_types=[
            res_types,
        ],
    )

RecordMatchOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
@irdl_op_definition
class RecordMatchOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interprecord_match-pdl_interprecordmatchop).
    """

    name = "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 | base(RangeType[AnyPDLType]))
    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(benefit, i16)
        super().__init__(
            operands=[inputs, matched_ops],
            properties={
                "rewriter": rewriter,
                "rootKind": root_kind,
                "generatedOps": generated_ops,
                "benefit": benefit,
            },
            successors=[dest],
        )

name = '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 | base(RangeType[AnyPDLType])) 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/pdl_interp.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
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(benefit, i16)
    super().__init__(
        operands=[inputs, matched_ops],
        properties={
            "rewriter": rewriter,
            "rootKind": root_kind,
            "generatedOps": generated_ops,
            "benefit": benefit,
        },
        successors=[dest],
    )

ValueConstrFromResultConstr dataclass

Bases: AttrConstraint[ValueType | RangeType[ValueType]]

Source code in xdsl/dialects/pdl_interp.py
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
@dataclass(frozen=True)
class ValueConstrFromResultConstr(AttrConstraint[ValueType | RangeType[ValueType]]):
    result_constr: AttrConstraint[TypeType | RangeType[TypeType]]

    def can_infer(self, var_constraint_names: AbstractSet[str]) -> bool:
        return self.result_constr.can_infer(var_constraint_names)

    def infer(self, context: ConstraintContext) -> ValueType | RangeType[ValueType]:
        result_type = self.result_constr.infer(context)
        if isinstance(result_type, RangeType):
            return RangeType(ValueType())
        return ValueType()

    def verify(self, attr: Attribute, constraint_context: ConstraintContext) -> None:
        if isa(attr, RangeType[ValueType]):
            result_type = RangeType(TypeType())
        elif isa(attr, ValueType):
            result_type = TypeType()
        else:
            raise VerifyException(
                f"Expected an attribute of type ValueType or RangeType[ValueType], but got {attr}"
            )
        return self.result_constr.verify(result_type, constraint_context)

    def mapping_type_vars(
        self, type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]
    ) -> AttrConstraint[ValueType | RangeType[ValueType]]:
        return ValueConstrFromResultConstr(
            self.result_constr.mapping_type_vars(type_var_mapping)
        )

result_constr: AttrConstraint[TypeType | RangeType[TypeType]] instance-attribute

__init__(result_constr: AttrConstraint[TypeType | RangeType[TypeType]]) -> None

can_infer(var_constraint_names: AbstractSet[str]) -> bool

Source code in xdsl/dialects/pdl_interp.py
680
681
def can_infer(self, var_constraint_names: AbstractSet[str]) -> bool:
    return self.result_constr.can_infer(var_constraint_names)

infer(context: ConstraintContext) -> ValueType | RangeType[ValueType]

Source code in xdsl/dialects/pdl_interp.py
683
684
685
686
687
def infer(self, context: ConstraintContext) -> ValueType | RangeType[ValueType]:
    result_type = self.result_constr.infer(context)
    if isinstance(result_type, RangeType):
        return RangeType(ValueType())
    return ValueType()

verify(attr: Attribute, constraint_context: ConstraintContext) -> None

Source code in xdsl/dialects/pdl_interp.py
689
690
691
692
693
694
695
696
697
698
def verify(self, attr: Attribute, constraint_context: ConstraintContext) -> None:
    if isa(attr, RangeType[ValueType]):
        result_type = RangeType(TypeType())
    elif isa(attr, ValueType):
        result_type = TypeType()
    else:
        raise VerifyException(
            f"Expected an attribute of type ValueType or RangeType[ValueType], but got {attr}"
        )
    return self.result_constr.verify(result_type, constraint_context)

mapping_type_vars(type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]) -> AttrConstraint[ValueType | RangeType[ValueType]]

Source code in xdsl/dialects/pdl_interp.py
700
701
702
703
704
705
def mapping_type_vars(
    self, type_var_mapping: Mapping[TypeVar, AttrConstraint | IntConstraint]
) -> AttrConstraint[ValueType | RangeType[ValueType]]:
    return ValueConstrFromResultConstr(
        self.result_constr.mapping_type_vars(type_var_mapping)
    )

GetValueTypeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
@irdl_op_definition
class GetValueTypeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_value_type-pdl_interpgetvaluetypeop).
    """

    name = "pdl_interp.get_value_type"
    T: ClassVar = VarConstraint("T", base(TypeType) | base(RangeType[TypeType]))
    value = operand_def(ValueConstrFromResultConstr(T))
    result = result_def(T)

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

    def __init__(self, value: SSAValue) -> None:
        super().__init__(
            operands=[value],
            result_types=[
                RangeType(TypeType())
                if isinstance(value.type, RangeType)
                else TypeType()
            ],
        )

name = 'pdl_interp.get_value_type' class-attribute instance-attribute

T: ClassVar = VarConstraint('T', base(TypeType) | base(RangeType[TypeType])) class-attribute instance-attribute

value = operand_def(ValueConstrFromResultConstr(T)) class-attribute instance-attribute

result = result_def(T) class-attribute instance-attribute

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

__init__(value: SSAValue) -> None

Source code in xdsl/dialects/pdl_interp.py
721
722
723
724
725
726
727
728
729
def __init__(self, value: SSAValue) -> None:
    super().__init__(
        operands=[value],
        result_types=[
            RangeType(TypeType())
            if isinstance(value.type, RangeType)
            else TypeType()
        ],
    )

ReplaceOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
@irdl_op_definition
class ReplaceOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpreplace-pdl_interpreplaceop).
    """

    name = "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: Sequence[SSAValue]) -> None:
        super().__init__(operands=[input_op, repl_values])

name = '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: Sequence[SSAValue]) -> None

Source code in xdsl/dialects/pdl_interp.py
746
747
def __init__(self, input_op: SSAValue, repl_values: Sequence[SSAValue]) -> None:
    super().__init__(operands=[input_op, repl_values])

EraseOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
750
751
752
753
754
755
756
757
758
759
760
761
762
@irdl_op_definition
class EraseOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interperase-pdl_interpreaseop).
    """

    name = "pdl_interp.erase"
    input_op = operand_def(OperationType)

    assembly_format = "$input_op attr-dict"

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

name = 'pdl_interp.erase' class-attribute instance-attribute

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

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

__init__(input_op: SSAValue) -> None

Source code in xdsl/dialects/pdl_interp.py
761
762
def __init__(self, input_op: SSAValue) -> None:
    super().__init__(operands=[input_op])

CreateAttributeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
765
766
767
768
769
770
771
772
773
774
775
776
777
778
@irdl_op_definition
class CreateAttributeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcreate_attribute-pdl_interpcreateattributeop).
    """

    name = "pdl_interp.create_attribute"
    value = prop_def(AnyAttr())
    attribute = result_def(AttributeType)

    assembly_format = "$value attr-dict-with-keyword"

    def __init__(self, value: Attribute) -> None:
        super().__init__(properties={"value": value}, result_types=[AttributeType()])

name = 'pdl_interp.create_attribute' class-attribute instance-attribute

value = prop_def(AnyAttr()) class-attribute instance-attribute

attribute = result_def(AttributeType) class-attribute instance-attribute

assembly_format = '$value attr-dict-with-keyword' class-attribute instance-attribute

__init__(value: Attribute) -> None

Source code in xdsl/dialects/pdl_interp.py
777
778
def __init__(self, value: Attribute) -> None:
    super().__init__(properties={"value": value}, result_types=[AttributeType()])

CreateOperationOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
@irdl_op_definition
class CreateOperationOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcreate_operation-pdl_interpcreateoperationop).
    """

    name = "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 assembly 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 = '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/pdl_interp.py
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
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/pdl_interp.py
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
@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/pdl_interp.py
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
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)

RangeTypeDirective dataclass

Bases: CustomDirective

Custom directive for parsing/printing range types in CreateRangeOp.

Source code in xdsl/dialects/pdl_interp.py
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
@irdl_custom_directive
class RangeTypeDirective(CustomDirective):
    """
    Custom directive for parsing/printing range types in CreateRangeOp.
    """

    arguments_type: TypeDirective
    result_type: TypeDirective

    def parse(self, parser: Parser, state: ParsingState) -> bool:
        args_inner = self.arguments_type.inner
        assert isinstance(args_inner, VariadicOperandVariable)

        arg_types = state.operand_types[args_inner.index]

        if arg_types:
            # Infer result type from first argument (getRangeElementTypeOrSelf)
            first_type = arg_types[0]
            if isa(first_type, RangeType[AnyPDLType]):
                element_type = first_type.element_type
            else:
                assert isinstance(first_type, AnyPDLType)
                element_type = first_type
            result_type = RangeType(element_type)
            self.result_type.set(state, (result_type,))
            return False  # No input consumed during inference
        else:
            # Parse `: type` for result when no arguments
            parser.parse_punctuation(":")
            result_type = parser.parse_type()
            self.result_type.set(state, (result_type,))
            return True

    def print(self, printer: Printer, state: PrintingState, op: IRDLOperation) -> None:
        arg_types = self.arguments_type.get(op)
        if not arg_types:
            # Print `: result_type` only when no arguments
            printer.print_string(" : ")
            result_types = self.result_type.get(op)
            printer.print_attribute(result_types[0])

arguments_type: TypeDirective instance-attribute

result_type: TypeDirective instance-attribute

parse(parser: Parser, state: ParsingState) -> bool

Source code in xdsl/dialects/pdl_interp.py
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
def parse(self, parser: Parser, state: ParsingState) -> bool:
    args_inner = self.arguments_type.inner
    assert isinstance(args_inner, VariadicOperandVariable)

    arg_types = state.operand_types[args_inner.index]

    if arg_types:
        # Infer result type from first argument (getRangeElementTypeOrSelf)
        first_type = arg_types[0]
        if isa(first_type, RangeType[AnyPDLType]):
            element_type = first_type.element_type
        else:
            assert isinstance(first_type, AnyPDLType)
            element_type = first_type
        result_type = RangeType(element_type)
        self.result_type.set(state, (result_type,))
        return False  # No input consumed during inference
    else:
        # Parse `: type` for result when no arguments
        parser.parse_punctuation(":")
        result_type = parser.parse_type()
        self.result_type.set(state, (result_type,))
        return True

print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None

Source code in xdsl/dialects/pdl_interp.py
987
988
989
990
991
992
993
def print(self, printer: Printer, state: PrintingState, op: IRDLOperation) -> None:
    arg_types = self.arguments_type.get(op)
    if not arg_types:
        # Print `: result_type` only when no arguments
        printer.print_string(" : ")
        result_types = self.result_type.get(op)
        printer.print_attribute(result_types[0])

CreateRangeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
@irdl_op_definition
class CreateRangeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcreate_range-pdl_interpcreaterangeop).
    """

    name = "pdl_interp.create_range"
    arguments = var_operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType]))
    result = result_def(RangeType[AnyPDLType])

    custom_directives = (RangeTypeDirective,)

    assembly_format = (
        "($arguments^ `:` type($arguments))?"
        "custom<RangeTypeDirective>(ref(type($arguments)), type($result))"
        "attr-dict"
    )

    def __init__(
        self,
        arguments: Sequence[SSAValue],
        result_type: RangeType[AnyPDLType],
    ) -> None:
        super().__init__(
            operands=[arguments],
            result_types=[result_type],
        )

name = 'pdl_interp.create_range' class-attribute instance-attribute

arguments = var_operand_def(AnyPDLTypeConstr | base(RangeType[AnyPDLType])) class-attribute instance-attribute

result = result_def(RangeType[AnyPDLType]) class-attribute instance-attribute

custom_directives = (RangeTypeDirective,) class-attribute instance-attribute

assembly_format = '($arguments^ `:` type($arguments))?custom<RangeTypeDirective>(ref(type($arguments)), type($result))attr-dict' class-attribute instance-attribute

__init__(arguments: Sequence[SSAValue], result_type: RangeType[AnyPDLType]) -> None

Source code in xdsl/dialects/pdl_interp.py
1014
1015
1016
1017
1018
1019
1020
1021
1022
def __init__(
    self,
    arguments: Sequence[SSAValue],
    result_type: RangeType[AnyPDLType],
) -> None:
    super().__init__(
        operands=[arguments],
        result_types=[result_type],
    )

GetDefiningOpOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
@irdl_op_definition
class GetDefiningOpOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpget_defining_op-pdl_interpgetdefiningopop).
    """

    name = "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 = '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/pdl_interp.py
1037
1038
def __init__(self, value: SSAValue) -> None:
    super().__init__(operands=[value], result_types=[OperationType()])

SwitchOperationNameOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
@irdl_op_definition
class SwitchOperationNameOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpswitch_operation_name-pdl_interpswitchoperationnameop).
    """

    name = "pdl_interp.switch_operation_name"

    case_values = prop_def(ArrayAttr[StringAttr], prop_name="caseValues")

    input_op = operand_def(OperationType)

    default_dest = successor_def()
    cases = var_successor_def()

    traits = traits_def(IsTerminator())
    assembly_format = (
        "`of` $input_op `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest"
    )

    def __init__(
        self,
        case_values: ArrayAttr[StringAttr] | Iterable[StringAttr],
        input_op: SSAValue,
        default_dest: Block,
        cases: Sequence[Block],
    ) -> None:
        case_values = ArrayAttr(case_values)
        super().__init__(
            operands=[input_op],
            properties={"caseValues": case_values},
            successors=[default_dest, cases],
        )

name = 'pdl_interp.switch_operation_name' class-attribute instance-attribute

case_values = prop_def(ArrayAttr[StringAttr], prop_name='caseValues') class-attribute instance-attribute

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

default_dest = successor_def() class-attribute instance-attribute

cases = var_successor_def() class-attribute instance-attribute

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

assembly_format = '`of` $input_op `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest' class-attribute instance-attribute

__init__(case_values: ArrayAttr[StringAttr] | Iterable[StringAttr], input_op: SSAValue, default_dest: Block, cases: Sequence[Block]) -> None

Source code in xdsl/dialects/pdl_interp.py
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
def __init__(
    self,
    case_values: ArrayAttr[StringAttr] | Iterable[StringAttr],
    input_op: SSAValue,
    default_dest: Block,
    cases: Sequence[Block],
) -> None:
    case_values = ArrayAttr(case_values)
    super().__init__(
        operands=[input_op],
        properties={"caseValues": case_values},
        successors=[default_dest, cases],
    )

SwitchOperandCountOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
@irdl_op_definition
class SwitchOperandCountOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpswitch_operand_count-pdl_interpswitchoperandcountop).
    """

    name = "pdl_interp.switch_operand_count"

    case_values = prop_def(DenseIntElementsAttr, prop_name="caseValues")

    input_op = operand_def(OperationType)

    default_dest = successor_def()
    cases = var_successor_def()

    traits = traits_def(IsTerminator())
    assembly_format = (
        "`of` $input_op `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest"
    )

    def __init__(
        self,
        case_values: DenseIntElementsAttr | Sequence[int],
        input_op: SSAValue,
        default_dest: Block,
        cases: Sequence[Block],
    ) -> None:
        if not isa(case_values, DenseIntElementsAttr):
            assert isinstance(case_values, Sequence)
            case_values = DenseIntElementsAttr.from_list(
                VectorType(IntegerType(32), (len(case_values),)), case_values
            )

        super().__init__(
            operands=[input_op],
            properties={"caseValues": case_values},
            successors=[default_dest, cases],
        )

name = 'pdl_interp.switch_operand_count' class-attribute instance-attribute

case_values = prop_def(DenseIntElementsAttr, prop_name='caseValues') class-attribute instance-attribute

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

default_dest = successor_def() class-attribute instance-attribute

cases = var_successor_def() class-attribute instance-attribute

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

assembly_format = '`of` $input_op `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest' class-attribute instance-attribute

__init__(case_values: DenseIntElementsAttr | Sequence[int], input_op: SSAValue, default_dest: Block, cases: Sequence[Block]) -> None

Source code in xdsl/dialects/pdl_interp.py
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
def __init__(
    self,
    case_values: DenseIntElementsAttr | Sequence[int],
    input_op: SSAValue,
    default_dest: Block,
    cases: Sequence[Block],
) -> None:
    if not isa(case_values, DenseIntElementsAttr):
        assert isinstance(case_values, Sequence)
        case_values = DenseIntElementsAttr.from_list(
            VectorType(IntegerType(32), (len(case_values),)), case_values
        )

    super().__init__(
        operands=[input_op],
        properties={"caseValues": case_values},
        successors=[default_dest, cases],
    )

SwitchResultCountOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
@irdl_op_definition
class SwitchResultCountOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpswitch_result_count-pdl_interpswitchresultcountop).
    """

    name = "pdl_interp.switch_result_count"

    case_values = prop_def(DenseIntElementsAttr, prop_name="caseValues")

    input_op = operand_def(OperationType)

    default_dest = successor_def()
    cases = var_successor_def()

    traits = traits_def(IsTerminator())
    assembly_format = (
        "`of` $input_op `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest"
    )

    def __init__(
        self,
        case_values: DenseIntElementsAttr | Sequence[int],
        input_op: SSAValue,
        default_dest: Block,
        cases: Sequence[Block],
    ) -> None:
        if not isa(case_values, DenseIntElementsAttr):
            assert isinstance(case_values, Sequence)
            case_values = DenseIntElementsAttr.from_list(
                VectorType(IntegerType(32), (len(case_values),)), case_values
            )
        super().__init__(
            operands=[input_op],
            properties={"caseValues": case_values},
            successors=[default_dest, cases],
        )

name = 'pdl_interp.switch_result_count' class-attribute instance-attribute

case_values = prop_def(DenseIntElementsAttr, prop_name='caseValues') class-attribute instance-attribute

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

default_dest = successor_def() class-attribute instance-attribute

cases = var_successor_def() class-attribute instance-attribute

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

assembly_format = '`of` $input_op `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest' class-attribute instance-attribute

__init__(case_values: DenseIntElementsAttr | Sequence[int], input_op: SSAValue, default_dest: Block, cases: Sequence[Block]) -> None

Source code in xdsl/dialects/pdl_interp.py
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
def __init__(
    self,
    case_values: DenseIntElementsAttr | Sequence[int],
    input_op: SSAValue,
    default_dest: Block,
    cases: Sequence[Block],
) -> None:
    if not isa(case_values, DenseIntElementsAttr):
        assert isinstance(case_values, Sequence)
        case_values = DenseIntElementsAttr.from_list(
            VectorType(IntegerType(32), (len(case_values),)), case_values
        )
    super().__init__(
        operands=[input_op],
        properties={"caseValues": case_values},
        successors=[default_dest, cases],
    )

SwitchTypeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
@irdl_op_definition
class SwitchTypeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpswitch_type-pdl_interpswitchtypeop).
    """

    name = "pdl_interp.switch_type"

    case_values = prop_def(ArrayAttr[TypeAttribute], prop_name="caseValues")

    value = operand_def(TypeType)

    default_dest = successor_def()
    cases = var_successor_def()

    traits = traits_def(IsTerminator())
    assembly_format = (
        "$value `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest"
    )

    def __init__(
        self,
        case_values: ArrayAttr[TypeAttribute] | Sequence[TypeAttribute],
        value: SSAValue,
        default_dest: Block,
        cases: Sequence[Block],
    ) -> None:
        if not isinstance(case_values, ArrayAttr):
            case_values = ArrayAttr(case_values)
        super().__init__(
            operands=[value],
            properties={"caseValues": case_values},
            successors=[default_dest, cases],
        )

name = 'pdl_interp.switch_type' class-attribute instance-attribute

case_values = prop_def(ArrayAttr[TypeAttribute], prop_name='caseValues') class-attribute instance-attribute

value = operand_def(TypeType) class-attribute instance-attribute

default_dest = successor_def() class-attribute instance-attribute

cases = var_successor_def() class-attribute instance-attribute

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

assembly_format = '$value `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest' class-attribute instance-attribute

__init__(case_values: ArrayAttr[TypeAttribute] | Sequence[TypeAttribute], value: SSAValue, default_dest: Block, cases: Sequence[Block]) -> None

Source code in xdsl/dialects/pdl_interp.py
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
def __init__(
    self,
    case_values: ArrayAttr[TypeAttribute] | Sequence[TypeAttribute],
    value: SSAValue,
    default_dest: Block,
    cases: Sequence[Block],
) -> None:
    if not isinstance(case_values, ArrayAttr):
        case_values = ArrayAttr(case_values)
    super().__init__(
        operands=[value],
        properties={"caseValues": case_values},
        successors=[default_dest, cases],
    )

SwitchTypesOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
@irdl_op_definition
class SwitchTypesOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpswitch_types-pdl_interpswitchtypesop).
    """

    name = "pdl_interp.switch_types"

    case_values = prop_def(ArrayAttr[ArrayAttr[TypeAttribute]], prop_name="caseValues")

    value = operand_def(RangeType[TypeType])

    default_dest = successor_def()
    cases = var_successor_def()

    traits = traits_def(IsTerminator())
    assembly_format = (
        "$value `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest"
    )

    def __init__(
        self,
        case_values: ArrayAttr[ArrayAttr[TypeAttribute]]
        | Sequence[ArrayAttr[TypeAttribute] | Sequence[TypeAttribute]],
        value: SSAValue,
        default_dest: Block,
        cases: Sequence[Block],
    ) -> None:
        if not isinstance(case_values, ArrayAttr):
            case_values = ArrayAttr(
                [v if isinstance(v, ArrayAttr) else ArrayAttr(v) for v in case_values]
            )
        super().__init__(
            operands=[value],
            properties={"caseValues": case_values},
            successors=[default_dest, cases],
        )

name = 'pdl_interp.switch_types' class-attribute instance-attribute

case_values = prop_def(ArrayAttr[ArrayAttr[TypeAttribute]], prop_name='caseValues') class-attribute instance-attribute

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

default_dest = successor_def() class-attribute instance-attribute

cases = var_successor_def() class-attribute instance-attribute

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

assembly_format = '$value `to` $caseValues `(` $cases `)` attr-dict `->` $default_dest' class-attribute instance-attribute

__init__(case_values: ArrayAttr[ArrayAttr[TypeAttribute]] | Sequence[ArrayAttr[TypeAttribute] | Sequence[TypeAttribute]], value: SSAValue, default_dest: Block, cases: Sequence[Block]) -> None

Source code in xdsl/dialects/pdl_interp.py
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
def __init__(
    self,
    case_values: ArrayAttr[ArrayAttr[TypeAttribute]]
    | Sequence[ArrayAttr[TypeAttribute] | Sequence[TypeAttribute]],
    value: SSAValue,
    default_dest: Block,
    cases: Sequence[Block],
) -> None:
    if not isinstance(case_values, ArrayAttr):
        case_values = ArrayAttr(
            [v if isinstance(v, ArrayAttr) else ArrayAttr(v) for v in case_values]
        )
    super().__init__(
        operands=[value],
        properties={"caseValues": case_values},
        successors=[default_dest, cases],
    )

FuncOpCallableInterface dataclass

Bases: CallableOpInterface

Source code in xdsl/dialects/pdl_interp.py
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
class FuncOpCallableInterface(CallableOpInterface):
    @classmethod
    def get_callable_region(cls, op: Operation) -> Region:
        assert isinstance(op, FuncOp)
        return op.body

    @classmethod
    def get_argument_types(cls, op: Operation) -> tuple[Attribute, ...]:
        assert isinstance(op, FuncOp)
        return op.function_type.inputs.data

    @classmethod
    def get_result_types(cls, op: Operation) -> tuple[Attribute, ...]:
        assert isinstance(op, FuncOp)
        return op.function_type.outputs.data

get_callable_region(op: Operation) -> Region classmethod

Source code in xdsl/dialects/pdl_interp.py
1231
1232
1233
1234
@classmethod
def get_callable_region(cls, op: Operation) -> Region:
    assert isinstance(op, FuncOp)
    return op.body

get_argument_types(op: Operation) -> tuple[Attribute, ...] classmethod

Source code in xdsl/dialects/pdl_interp.py
1236
1237
1238
1239
@classmethod
def get_argument_types(cls, op: Operation) -> tuple[Attribute, ...]:
    assert isinstance(op, FuncOp)
    return op.function_type.inputs.data

get_result_types(op: Operation) -> tuple[Attribute, ...] classmethod

Source code in xdsl/dialects/pdl_interp.py
1241
1242
1243
1244
@classmethod
def get_result_types(cls, op: Operation) -> tuple[Attribute, ...]:
    assert isinstance(op, FuncOp)
    return op.function_type.outputs.data

FuncOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
@irdl_op_definition
class FuncOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpfunc-pdl_interpfuncop).
    """

    name = "pdl_interp.func"
    sym_name = prop_def(SymbolNameConstraint())
    function_type = prop_def(FunctionType)
    arg_attrs = opt_prop_def(ArrayAttr[DictionaryAttr])
    res_attrs = opt_prop_def(ArrayAttr[DictionaryAttr])

    body = region_def()

    traits = traits_def(
        IsolatedFromAbove(), SymbolOpInterface(), FuncOpCallableInterface()
    )

    @classmethod
    def parse(cls, parser: Parser) -> FuncOp:
        (
            name,
            input_types,
            return_types,
            region,
            extra_attrs,
            arg_attrs,
            res_attrs,
        ) = parse_func_op_like(
            parser, reserved_attr_names=("sym_name", "function_type")
        )
        func = FuncOp(
            sym_name=name,
            function_type=(input_types, return_types),
            region=region,
            arg_attrs=arg_attrs,
            res_attrs=res_attrs,
        )
        if extra_attrs is not None:
            func.attributes |= extra_attrs.data
        return func

    def print(self, printer: Printer):
        print_func_op_like(
            printer,
            self.sym_name,
            self.function_type,
            self.body,
            self.attributes,
            arg_attrs=self.arg_attrs,
            res_attrs=self.res_attrs,
            reserved_attr_names=(
                "sym_name",
                "function_type",
                "arg_attrs",
            ),
        )

    def __init__(
        self,
        sym_name: str | StringAttr,
        function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]],
        arg_attrs: ArrayAttr[DictionaryAttr] | None = None,
        res_attrs: ArrayAttr[DictionaryAttr] | None = None,
        region: Region | type[Region.DEFAULT] = Region.DEFAULT,
    ) -> None:
        if isinstance(sym_name, str):
            sym_name = StringAttr(sym_name)
        if isinstance(function_type, tuple):
            inputs, outputs = function_type
            function_type = FunctionType.from_lists(inputs, outputs)
        if not isinstance(region, Region):
            region = Region(Block(arg_types=function_type.inputs))

        super().__init__(
            properties={
                "sym_name": sym_name,
                "function_type": function_type,
                "arg_attrs": arg_attrs,
                "res_attrs": res_attrs,
            },
            regions=[region],
        )

name = 'pdl_interp.func' class-attribute instance-attribute

sym_name = prop_def(SymbolNameConstraint()) class-attribute instance-attribute

function_type = prop_def(FunctionType) class-attribute instance-attribute

arg_attrs = opt_prop_def(ArrayAttr[DictionaryAttr]) class-attribute instance-attribute

res_attrs = opt_prop_def(ArrayAttr[DictionaryAttr]) class-attribute instance-attribute

body = region_def() class-attribute instance-attribute

traits = traits_def(IsolatedFromAbove(), SymbolOpInterface(), FuncOpCallableInterface()) class-attribute instance-attribute

parse(parser: Parser) -> FuncOp classmethod

Source code in xdsl/dialects/pdl_interp.py
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
@classmethod
def parse(cls, parser: Parser) -> FuncOp:
    (
        name,
        input_types,
        return_types,
        region,
        extra_attrs,
        arg_attrs,
        res_attrs,
    ) = parse_func_op_like(
        parser, reserved_attr_names=("sym_name", "function_type")
    )
    func = FuncOp(
        sym_name=name,
        function_type=(input_types, return_types),
        region=region,
        arg_attrs=arg_attrs,
        res_attrs=res_attrs,
    )
    if extra_attrs is not None:
        func.attributes |= extra_attrs.data
    return func

print(printer: Printer)

Source code in xdsl/dialects/pdl_interp.py
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
def print(self, printer: Printer):
    print_func_op_like(
        printer,
        self.sym_name,
        self.function_type,
        self.body,
        self.attributes,
        arg_attrs=self.arg_attrs,
        res_attrs=self.res_attrs,
        reserved_attr_names=(
            "sym_name",
            "function_type",
            "arg_attrs",
        ),
    )

__init__(sym_name: str | StringAttr, function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]], arg_attrs: ArrayAttr[DictionaryAttr] | None = None, res_attrs: ArrayAttr[DictionaryAttr] | None = None, region: Region | type[Region.DEFAULT] = Region.DEFAULT) -> None

Source code in xdsl/dialects/pdl_interp.py
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
def __init__(
    self,
    sym_name: str | StringAttr,
    function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]],
    arg_attrs: ArrayAttr[DictionaryAttr] | None = None,
    res_attrs: ArrayAttr[DictionaryAttr] | None = None,
    region: Region | type[Region.DEFAULT] = Region.DEFAULT,
) -> None:
    if isinstance(sym_name, str):
        sym_name = StringAttr(sym_name)
    if isinstance(function_type, tuple):
        inputs, outputs = function_type
        function_type = FunctionType.from_lists(inputs, outputs)
    if not isinstance(region, Region):
        region = Region(Block(arg_types=function_type.inputs))

    super().__init__(
        properties={
            "sym_name": sym_name,
            "function_type": function_type,
            "arg_attrs": arg_attrs,
            "res_attrs": res_attrs,
        },
        regions=[region],
    )

SwitchAttributeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
@irdl_op_definition
class SwitchAttributeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpswitch_attribute-pdl_interpswitchattributeop).
    """

    name = "pdl_interp.switch_attribute"

    attribute = operand_def(AttributeType)
    caseValues = prop_def(ArrayAttr)
    defaultDest = successor_def()
    cases = var_successor_def()

    traits = traits_def(IsTerminator())

    assembly_format = (
        "$attribute `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest"
    )

    def __init__(
        self,
        attribute: SSAValue,
        case_values: ArrayAttr,
        default_dest: Block,
        cases: list[Block],
    ) -> None:
        super().__init__(
            operands=[attribute],
            properties={"caseValues": case_values},
            successors=[default_dest, cases],
        )

name = 'pdl_interp.switch_attribute' class-attribute instance-attribute

attribute = operand_def(AttributeType) class-attribute instance-attribute

caseValues = prop_def(ArrayAttr) class-attribute instance-attribute

defaultDest = successor_def() class-attribute instance-attribute

cases = var_successor_def() class-attribute instance-attribute

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

assembly_format = '$attribute `to` $caseValues `(` $cases `)` attr-dict `->` $defaultDest' class-attribute instance-attribute

__init__(attribute: SSAValue, case_values: ArrayAttr, default_dest: Block, cases: list[Block]) -> None

Source code in xdsl/dialects/pdl_interp.py
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
def __init__(
    self,
    attribute: SSAValue,
    case_values: ArrayAttr,
    default_dest: Block,
    cases: list[Block],
) -> None:
    super().__init__(
        operands=[attribute],
        properties={"caseValues": case_values},
        successors=[default_dest, cases],
    )

CreateTypeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
@irdl_op_definition
class CreateTypeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcreate_type-pdl_interpcreatetypeop).
    """

    name = "pdl_interp.create_type"

    value = prop_def(TypeAttribute)
    result = result_def(TypeType)

    assembly_format = "$value attr-dict"

    def __init__(self, value: TypeAttribute) -> None:
        super().__init__(
            properties={"value": value},
            result_types=[TypeType()],
        )

name = 'pdl_interp.create_type' class-attribute instance-attribute

value = prop_def(TypeAttribute) class-attribute instance-attribute

result = result_def(TypeType) class-attribute instance-attribute

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

__init__(value: TypeAttribute) -> None

Source code in xdsl/dialects/pdl_interp.py
1378
1379
1380
1381
1382
def __init__(self, value: TypeAttribute) -> None:
    super().__init__(
        properties={"value": value},
        result_types=[TypeType()],
    )

CreateTypesOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
@irdl_op_definition
class CreateTypesOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcreate_types-pdl_interpcreatetypesop).
    """

    name = "pdl_interp.create_types"

    value = prop_def(ArrayAttr)
    result = result_def(RangeType[TypeType])

    assembly_format = "$value attr-dict"

    def __init__(self, value: ArrayAttr) -> None:
        super().__init__(
            properties={"value": value},
            result_types=[RangeType(TypeType())],
        )

name = 'pdl_interp.create_types' class-attribute instance-attribute

value = prop_def(ArrayAttr) class-attribute instance-attribute

result = result_def(RangeType[TypeType]) class-attribute instance-attribute

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

__init__(value: ArrayAttr) -> None

Source code in xdsl/dialects/pdl_interp.py
1398
1399
1400
1401
1402
def __init__(self, value: ArrayAttr) -> None:
    super().__init__(
        properties={"value": value},
        result_types=[RangeType(TypeType())],
    )

ContinueOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
@irdl_op_definition
class ContinueOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpcontinue-pdl_interpcontinueop).
    """

    name = "pdl_interp.continue"
    traits = traits_def(IsTerminator())

    assembly_format = "attr-dict"

    def __init__(self) -> None:
        super().__init__()

name = 'pdl_interp.continue' class-attribute instance-attribute

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

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

__init__() -> None

Source code in xdsl/dialects/pdl_interp.py
1416
1417
def __init__(self) -> None:
    super().__init__()

ForEachOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
@irdl_op_definition
class ForEachOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpforeach-pdl_interpforeachop).
    """

    name = "pdl_interp.foreach"
    traits = traits_def(IsTerminator())

    values = operand_def(RangeType[AnyPDLType])
    region = region_def()
    successor = successor_def()

    def __init__(
        self,
        values: SSAValue,
        successor: Block,
        region: Region | type[Region.DEFAULT] = Region.DEFAULT,
    ) -> None:
        if not isinstance(region, Region):
            assert isa(values.type, RangeType[AnyPDLType])
            val_type = values.type.element_type
            region = Region(Block(arg_types=(val_type,)))

        super().__init__(operands=[values], successors=[successor], regions=[region])

    @classmethod
    def parse(cls, parser: Parser) -> ForEachOp:
        arg = parser.parse_argument()
        parser.parse_characters("in")
        values = parser.parse_operand()
        region = parser.parse_region(arguments=[arg])
        parser.parse_punctuation("->")
        successor = parser.parse_successor()
        attrs = parser.parse_optional_attr_dict()

        op = ForEachOp(values, successor, region)
        if attrs:
            op.attributes = attrs
        return op

    def print(self, printer: Printer):
        loop_var = self.region.blocks[0].args[0]
        printer.print_string(" ")
        printer.print_ssa_value(loop_var)
        printer.print_string(" : ")
        printer.print_attribute(loop_var.type)
        printer.print_string(" in ")
        printer.print_operand(self.values)
        printer.print_string(" ")
        printer.print_region(self.region, print_entry_block_args=False)
        printer.print_string(" -> ")
        printer.print_block_name(self.successor)
        printer.print_op_attributes(self.attributes)

    def verify_(self) -> None:
        if not self.region.blocks:
            raise VerifyException("Region must not be empty")

        block = self.region.blocks[0]
        if len(block.args) != 1:
            raise VerifyException("Region must have exactly one argument")

        arg_type = block.args[0].type

        assert isa(self.values, SSAValue[RangeType[AnyPDLType]])
        if self.values.type.element_type != arg_type:
            raise VerifyException(
                f"Region argument type {arg_type} does not match "
                f"range element type {self.values.type.element_type}"
            )

name = 'pdl_interp.foreach' class-attribute instance-attribute

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

values = operand_def(RangeType[AnyPDLType]) class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

successor = successor_def() class-attribute instance-attribute

__init__(values: SSAValue, successor: Block, region: Region | type[Region.DEFAULT] = Region.DEFAULT) -> None

Source code in xdsl/dialects/pdl_interp.py
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
def __init__(
    self,
    values: SSAValue,
    successor: Block,
    region: Region | type[Region.DEFAULT] = Region.DEFAULT,
) -> None:
    if not isinstance(region, Region):
        assert isa(values.type, RangeType[AnyPDLType])
        val_type = values.type.element_type
        region = Region(Block(arg_types=(val_type,)))

    super().__init__(operands=[values], successors=[successor], regions=[region])

parse(parser: Parser) -> ForEachOp classmethod

Source code in xdsl/dialects/pdl_interp.py
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
@classmethod
def parse(cls, parser: Parser) -> ForEachOp:
    arg = parser.parse_argument()
    parser.parse_characters("in")
    values = parser.parse_operand()
    region = parser.parse_region(arguments=[arg])
    parser.parse_punctuation("->")
    successor = parser.parse_successor()
    attrs = parser.parse_optional_attr_dict()

    op = ForEachOp(values, successor, region)
    if attrs:
        op.attributes = attrs
    return op

print(printer: Printer)

Source code in xdsl/dialects/pdl_interp.py
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
def print(self, printer: Printer):
    loop_var = self.region.blocks[0].args[0]
    printer.print_string(" ")
    printer.print_ssa_value(loop_var)
    printer.print_string(" : ")
    printer.print_attribute(loop_var.type)
    printer.print_string(" in ")
    printer.print_operand(self.values)
    printer.print_string(" ")
    printer.print_region(self.region, print_entry_block_args=False)
    printer.print_string(" -> ")
    printer.print_block_name(self.successor)
    printer.print_op_attributes(self.attributes)

verify_() -> None

Source code in xdsl/dialects/pdl_interp.py
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
def verify_(self) -> None:
    if not self.region.blocks:
        raise VerifyException("Region must not be empty")

    block = self.region.blocks[0]
    if len(block.args) != 1:
        raise VerifyException("Region must have exactly one argument")

    arg_type = block.args[0].type

    assert isa(self.values, SSAValue[RangeType[AnyPDLType]])
    if self.values.type.element_type != arg_type:
        raise VerifyException(
            f"Region argument type {arg_type} does not match "
            f"range element type {self.values.type.element_type}"
        )

BranchOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/pdl_interp.py
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
@irdl_op_definition
class BranchOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/PDLInterpOps/#pdl_interpbranch-pdl_interpbranchop).
    """

    name = "pdl_interp.branch"
    traits = traits_def(IsTerminator())

    dest = successor_def()

    assembly_format = "$dest attr-dict"

    def __init__(self, dest: Block) -> None:
        super().__init__(successors=[dest])

name = 'pdl_interp.branch' class-attribute instance-attribute

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

dest = successor_def() class-attribute instance-attribute

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

__init__(dest: Block) -> None

Source code in xdsl/dialects/pdl_interp.py
1506
1507
def __init__(self, dest: Block) -> None:
    super().__init__(successors=[dest])