Skip to content

Exceptions

exceptions

Custom xDSL exceptions.

This module contains all custom exceptions used by xDSL.

UnregisteredConstructException

Bases: Exception

An exception raised when a dialect, operation, type, or attribute is not registered.

Source code in xdsl/utils/exceptions.py
18
19
20
21
22
class UnregisteredConstructException(Exception):
    """
    An exception raised when a dialect, operation, type,
    or attribute is not registered.
    """

AlreadyRegisteredConstructException

Bases: Exception

An exception raised when a dialect, operation, type, or attribute is registered twice.

Source code in xdsl/utils/exceptions.py
25
26
27
28
29
class AlreadyRegisteredConstructException(Exception):
    """
    An exception raised when a dialect, operation, type,
    or attribute is registered twice.
    """

DiagnosticException

Bases: Exception

Source code in xdsl/utils/exceptions.py
32
33
class DiagnosticException(Exception):
    pass

VerifyException

Bases: DiagnosticException

Source code in xdsl/utils/exceptions.py
36
37
class VerifyException(DiagnosticException):
    pass

PassFailedException

Bases: DiagnosticException

A diagnostic error which can be raised during the execution of a pass, used to signify that the pass did not succeed.

Source code in xdsl/utils/exceptions.py
40
41
42
43
44
45
46
class PassFailedException(DiagnosticException):
    """
    A diagnostic error which can be raised during the execution of a pass, used to
    signify that the pass did not succeed.
    """

    pass

PyRDLError

Bases: Exception

An error in our IRDL eDSL.

Source code in xdsl/utils/exceptions.py
49
50
51
52
class PyRDLError(Exception):
    """
    An error in our IRDL eDSL.
    """

PyRDLOpDefinitionError

Bases: PyRDLError

An error in the Operation definition eDSL.

Source code in xdsl/utils/exceptions.py
55
56
57
58
class PyRDLOpDefinitionError(PyRDLError):
    """
    An error in the Operation definition eDSL.
    """

PyRDLAttrDefinitionError

Bases: PyRDLError

An error in the Attribute definition eDSL.

Source code in xdsl/utils/exceptions.py
61
62
63
64
class PyRDLAttrDefinitionError(PyRDLError):
    """
    An error in the Attribute definition eDSL.
    """

PyRDLTypeError

Bases: TypeError, PyRDLError

A type error in our IRDL eDSL.

Source code in xdsl/utils/exceptions.py
67
68
69
70
class PyRDLTypeError(TypeError, PyRDLError):
    """
    A type error in our IRDL eDSL.
    """

InvalidIRException

Bases: Exception

Source code in xdsl/utils/exceptions.py
73
74
class InvalidIRException(Exception):
    pass

ShrinkException

Bases: Exception

Exception for test case reduction when used in conjunction with the Shrink Ray reducer.

To find a reduced version of a test case, raise this exception on the line of code you want to hit, and pass the --shrink argument to xdsl-opt, by changing its invocation from: xdsl-opt input_file.mlir -p my,pass,pipeline to: shrinkray "xdsl-opt -p my,pass,pipeline --shrink" input_file.mlir.

Source code in xdsl/utils/exceptions.py
77
78
79
80
81
82
83
84
85
86
87
88
89
class ShrinkException(Exception):
    """
    Exception for test case reduction when used in conjunction with the [Shrink Ray](https://github.com/DRMacIver/shrinkray)
    reducer.

    To find a reduced version of a test case, raise this exception on the line of code you want to hit,
    and pass the `--shrink` argument to `xdsl-opt`, by changing its invocation from:
    `xdsl-opt input_file.mlir -p my,pass,pipeline`
    to:
    `shrinkray "xdsl-opt -p my,pass,pipeline --shrink" input_file.mlir`.
    """

    pass

InterpretationError

Bases: Exception

An error that can be raised during interpretation, or Interpreter setup.

Source code in xdsl/utils/exceptions.py
92
93
94
95
96
97
class InterpretationError(Exception):
    """
    An error that can be raised during interpretation, or Interpreter setup.
    """

    pass

BuilderNotFoundException dataclass

Bases: Exception

Exception raised when no builders are found for a given attribute type and a given tuple of arguments.

Source code in xdsl/utils/exceptions.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
@dataclass
class BuilderNotFoundException(Exception):
    """
    Exception raised when no builders are found for a given attribute type
    and a given tuple of arguments.
    """

    attribute: type[Attribute]
    args: tuple[Any, ...]

    def __str__(self) -> str:
        return (
            f"No builder found for attribute {self.attribute} with "
            f"arguments {self.args}"
        )

attribute: type[Attribute] instance-attribute

args: tuple[Any, ...] instance-attribute

__init__(attribute: type[Attribute], args: tuple[Any, ...]) -> None

__str__() -> str

Source code in xdsl/utils/exceptions.py
110
111
112
113
114
def __str__(self) -> str:
    return (
        f"No builder found for attribute {self.attribute} with "
        f"arguments {self.args}"
    )

ParseError dataclass

Bases: Exception

Source code in xdsl/utils/exceptions.py
117
118
119
120
121
122
123
@dataclass
class ParseError(Exception):
    span: Span
    msg: str

    def __str__(self) -> str:
        return self.span.print_with_context(self.msg)

span: Span instance-attribute

msg: str instance-attribute

__init__(span: Span, msg: str) -> None

__str__() -> str

Source code in xdsl/utils/exceptions.py
122
123
def __str__(self) -> str:
    return self.span.print_with_context(self.msg)

MultipleSpansParseError dataclass

Bases: ParseError

Source code in xdsl/utils/exceptions.py
126
127
128
129
130
131
132
133
134
135
136
137
@dataclass
class MultipleSpansParseError(ParseError):
    ref_text: str | None
    refs: list[tuple[Span, str | None]]

    def __str__(self) -> str:
        res = self.span.print_with_context(self.msg)
        if self.ref_text is not None:
            res += self.ref_text + "\n"
        for span, msg in self.refs:
            res += span.print_with_context(msg) + "\n"
        return res

ref_text: str | None instance-attribute

refs: list[tuple[Span, str | None]] instance-attribute

__init__(span: Span, msg: str, ref_text: str | None, refs: list[tuple[Span, str | None]]) -> None

__str__() -> str

Source code in xdsl/utils/exceptions.py
131
132
133
134
135
136
137
def __str__(self) -> str:
    res = self.span.print_with_context(self.msg)
    if self.ref_text is not None:
        res += self.ref_text + "\n"
    for span, msg in self.refs:
        res += span.print_with_context(msg) + "\n"
    return res

PassPipelineParseError

Bases: BaseException

Source code in xdsl/utils/exceptions.py
140
141
142
143
144
145
class PassPipelineParseError(BaseException):
    def __init__(self, token: SpecToken, msg: str):
        super().__init__(
            "Error parsing pass pipeline specification:\n"
            + token.span.print_with_context(msg)
        )

__init__(token: SpecToken, msg: str)

Source code in xdsl/utils/exceptions.py
141
142
143
144
145
def __init__(self, token: SpecToken, msg: str):
    super().__init__(
        "Error parsing pass pipeline specification:\n"
        + token.span.print_with_context(msg)
    )

LLVMTranslationException

Bases: Exception

Exception raised during LLVM translation.

Source code in xdsl/utils/exceptions.py
148
149
150
151
152
153
class LLVMTranslationException(Exception):
    """
    Exception raised during LLVM translation.
    """

    pass