Interfaces
interfaces
Interfaces are a convenience wrapper around traits, providing logic on the operation directly.
Operations inherit all the traits of their superclasses, allowing them to combine behaviours via sublcassing. This can be more convenient than adding the traits explicitly.
HasCanonicalizationPatternsInterface
dataclass
Bases: Operation, ABC
An operation subclassing this interface must implement the
get_canonicalization_patterns method, which returns a tuple of patterns that
canonicalize this operation.
Wraps CanonicalizationPatternsTrait.
Source code in xdsl/interfaces.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
traits = traits_def(_HasCanonicalizationPatternsInterfaceTrait())
class-attribute
instance-attribute
get_canonicalization_patterns() -> tuple[RewritePattern, ...]
abstractmethod
classmethod
Source code in xdsl/interfaces.py
53 54 55 56 | |
HasFolderInterface
dataclass
Bases: Operation, ABC
An operation subclassing this interface must implement the
fold method, which attempts to fold the operation.
Wraps HasFolderTrait.
Source code in xdsl/interfaces.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
traits = traits_def(_HasFolderInterfaceTrait())
class-attribute
instance-attribute
fold() -> Sequence[SSAValue | Attribute] | None
abstractmethod
Attempts to fold the operation. The fold method cannot modify the IR. Returns either an existing SSAValue or an Attribute for each result of the operation. When folding is unsuccessful, returns None.
The fold method is not allowed to mutate the operation being folded.
Source code in xdsl/interfaces.py
83 84 85 86 87 88 89 90 91 92 | |
ConditionallySpeculatableInterface
dataclass
Bases: Operation, ABC
An operation subclassing this interface must implement the
is_speculatable method, which indicates whether the operation
can be speculatively executed.
Source code in xdsl/interfaces.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
traits = traits_def(_ConditionallySpeculatableInterfaceTrait())
class-attribute
instance-attribute
is_speculatable() -> bool
abstractmethod
Returns True if this operation can be speculatively executed, False otherwise. Speculatable ops have no undefined behavior and no observable side effects.
Source code in xdsl/interfaces.py
120 121 122 123 124 125 126 127 | |