Skip to content

Ematch

ematch

Ematch = Dialect('ematch', [GetClassValsOp, GetClassRepresentativeOp, GetClassResultOp, GetClassResultsOp, UnionOp, DedupOp, AreEquivalentOp]) 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
@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
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
@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
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
@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
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
@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
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
@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
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
@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
def __init__(self, input_op: SSAValue) -> None:
    super().__init__(
        operands=[input_op],
        result_types=[OperationType()],
    )

AreEquivalentOp

Bases: IRDLOperation

Check whether two values are in the same equivalence class.

Unlike pdl_interp.are_equal, two equivalence.class results are considered equivalent if their e-classes have been merged, even if they are not the same SSA value. Values that are not equivalence.class results are only equivalent to themselves. On success, control branches to the true destination, otherwise to the false destination.

Source code in xdsl/dialects/ematch.py
@irdl_op_definition
class AreEquivalentOp(IRDLOperation):
    """
    Check whether two values are in the same equivalence class.

    Unlike `pdl_interp.are_equal`, two equivalence.class results are considered
    equivalent if their e-classes have been merged, even if they are not the
    same SSA value. Values that are not equivalence.class results are only
    equivalent to themselves. On success, control branches to the true
    destination, otherwise to the false destination.
    """

    name = "ematch.are_equivalent"
    traits = traits_def(IsTerminator())
    lhs = operand_def(ValueType)
    rhs = operand_def(ValueType)
    true_dest = successor_def()
    false_dest = successor_def()

    assembly_format = "$lhs `,` $rhs attr-dict `->` $true_dest `,` $false_dest"

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

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

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

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

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

true_dest = successor_def() class-attribute instance-attribute

false_dest = successor_def() class-attribute instance-attribute

assembly_format = '$lhs `,` $rhs attr-dict `->` $true_dest `,` $false_dest' class-attribute instance-attribute

__init__(lhs: SSAValue, rhs: SSAValue, true_dest: Block, false_dest: Block) -> None

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