Skip to content

Ematch

ematch

Ematch = Dialect('ematch', [GetClassValsOp, GetClassRepresentativeOp, GetClassResultOp, GetClassResultsOp, UnionOp, DedupOp]) module-attribute

GetClassValsOp

Bases: IRDLOperation

Take a value and return all values in its equivalence class.

If the value is an equivalence.class result, return the operands of the class, otherwise return a range containing the value itself.

Source code in xdsl/dialects/ematch.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@irdl_op_definition
class GetClassValsOp(IRDLOperation):
    """
    Take a value and return all values in its equivalence class.

    If the value is an equivalence.class result, return the operands of the class,
    otherwise return a range containing the value itself.
    """

    name = "ematch.get_class_vals"
    value = operand_def(ValueType)
    result = result_def(RangeType[ValueType])

    assembly_format = "$value attr-dict"

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

name = 'ematch.get_class_vals' class-attribute instance-attribute

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

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

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

__init__(value: SSAValue) -> None

Source code in xdsl/dialects/ematch.py
35
36
37
38
39
def __init__(self, value: SSAValue) -> None:
    super().__init__(
        operands=[value],
        result_types=[RangeType(ValueType())],
    )

GetClassRepresentativeOp

Bases: IRDLOperation

Get one of the values in the equivalence class of v.

Source code in xdsl/dialects/ematch.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@irdl_op_definition
class GetClassRepresentativeOp(IRDLOperation):
    """
    Get one of the values in the equivalence class of v.
    """

    name = "ematch.get_class_representative"
    value = operand_def(ValueType)
    result = result_def(ValueType)

    assembly_format = "$value attr-dict"

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

name = 'ematch.get_class_representative' class-attribute instance-attribute

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

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

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

__init__(value: SSAValue) -> None

Source code in xdsl/dialects/ematch.py
54
55
56
57
58
def __init__(self, value: SSAValue) -> None:
    super().__init__(
        operands=[value],
        result_types=[ValueType()],
    )

GetClassResultOp

Bases: IRDLOperation

Get the equivalence.class result corresponding to the equivalence class of v.

Source code in xdsl/dialects/ematch.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@irdl_op_definition
class GetClassResultOp(IRDLOperation):
    """
    Get the equivalence.class result corresponding to the equivalence class of v.
    """

    name = "ematch.get_class_result"
    value = operand_def(ValueType)
    result = result_def(ValueType)

    assembly_format = "$value attr-dict"

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

name = 'ematch.get_class_result' class-attribute instance-attribute

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

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

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

__init__(value: SSAValue) -> None

Source code in xdsl/dialects/ematch.py
73
74
75
76
77
def __init__(self, value: SSAValue) -> None:
    super().__init__(
        operands=[value],
        result_types=[ValueType()],
    )

GetClassResultsOp

Bases: IRDLOperation

Get the equivalence.class results corresponding to the equivalence classes of a range of values.

Source code in xdsl/dialects/ematch.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@irdl_op_definition
class GetClassResultsOp(IRDLOperation):
    """
    Get the equivalence.class results corresponding to the equivalence classes
    of a range of values.
    """

    name = "ematch.get_class_results"
    values = operand_def(RangeType[ValueType])
    result = result_def(RangeType[ValueType])

    assembly_format = "$values attr-dict"

    def __init__(self, values: SSAValue) -> None:
        super().__init__(
            operands=[values],
            result_types=[RangeType(ValueType())],
        )

name = 'ematch.get_class_results' class-attribute instance-attribute

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

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

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

__init__(values: SSAValue) -> None

Source code in xdsl/dialects/ematch.py
93
94
95
96
97
def __init__(self, values: SSAValue) -> None:
    super().__init__(
        operands=[values],
        result_types=[RangeType(ValueType())],
    )

UnionOp

Bases: IRDLOperation

Merge two values, an operation and a value range, or two value ranges into equivalence class(es).

Supported operand type combinations: - (value, value): merge two values - (operation, range): merge operation results with values - (range, range): merge two value ranges

Source code in xdsl/dialects/ematch.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
@irdl_op_definition
class UnionOp(IRDLOperation):
    """
    Merge two values, an operation and a value range, or two value ranges
    into equivalence class(es).

    Supported operand type combinations:
    - (value, value): merge two values
    - (operation, range<value>): merge operation results with values
    - (range<value>, range<value>): merge two value ranges
    """

    name = "ematch.union"
    lhs = operand_def(ValueType | OperationType | RangeType[ValueType])
    rhs = operand_def(ValueType | RangeType[ValueType])

    assembly_format = "$lhs `:` type($lhs) `,` $rhs `:` type($rhs) attr-dict"

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

name = 'ematch.union' class-attribute instance-attribute

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

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

assembly_format = '$lhs `:` type($lhs) `,` $rhs `:` type($rhs) attr-dict' class-attribute instance-attribute

__init__(lhs: SSAValue, rhs: SSAValue) -> None

Source code in xdsl/dialects/ematch.py
118
119
def __init__(self, lhs: SSAValue, rhs: SSAValue) -> None:
    super().__init__(operands=[lhs, rhs])

DedupOp

Bases: IRDLOperation

Check if the operation already exists in the hashcons.

If so, remove the new one and return the existing one.

Source code in xdsl/dialects/ematch.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@irdl_op_definition
class DedupOp(IRDLOperation):
    """
    Check if the operation already exists in the hashcons.

    If so, remove the new one and return the existing one.
    """

    name = "ematch.dedup"
    input_op = operand_def(OperationType)
    result_op = result_def(OperationType)

    assembly_format = "$input_op attr-dict"

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

name = 'ematch.dedup' class-attribute instance-attribute

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

result_op = result_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/ematch.py
136
137
138
139
140
def __init__(self, input_op: SSAValue) -> None:
    super().__init__(
        operands=[input_op],
        result_types=[OperationType()],
    )