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
traits = traits_def(_HasCanonicalizationPatternsInterfaceTrait())
class-attribute
instance-attribute
¶
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
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
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
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
RegionBranchOpInterface
dataclass
¶
Bases: Operation, ABC
An operation subclassing this interface must implement successor_regions, and may
override the other methods, whose semantics are documented on RegionBranchOpTrait.
Wraps RegionBranchOpTrait.
Source code in xdsl/interfaces.py
traits = traits_def(_RegionBranchOpInterfaceTrait())
class-attribute
instance-attribute
¶
entry_successor_regions(operands: Sequence[Attribute | None]) -> Sequence[RegionSuccessor]
¶
See RegionBranchOpTrait.entry_successor_regions.
successor_regions(point: RegionBranchPoint) -> Sequence[RegionSuccessor]
abstractmethod
¶
successor_regions_from_region(region: Region) -> Iterator[RegionSuccessor]
¶
See RegionBranchOpTrait.successor_regions_from_region.
Source code in xdsl/interfaces.py
successor_inputs(successor: RegionSuccessor) -> Sequence[SSAValue]
¶
predecessors(successor: RegionSuccessor) -> Iterator[RegionBranchPoint]
¶
See RegionBranchOpTrait.predecessors.
Source code in xdsl/interfaces.py
region_invocation_bounds(operands: Sequence[Attribute | None]) -> Sequence[InvocationBounds]
¶
See RegionBranchOpTrait.region_invocation_bounds.
RegionBranchTerminatorOpInterface
dataclass
¶
Bases: Operation, ABC
An operation subclassing this interface is a terminator that branches between the
regions of its parent RegionBranchOpInterface. Wraps
RegionBranchTerminatorOpTrait.