Folder
folder
¶
Folder
dataclass
¶
Source code in xdsl/folder.py
context: Context
instance-attribute
¶
__init__(context: Context) -> None
¶
try_fold(op: Operation) -> tuple[list[SSAValue], list[Operation]] | None
¶
Try to fold the given operation. Returns a tuple with the list of SSAValues that replace the results of the operation, and a list of constant operations that were created from the constant attributes generated by the folder. If the operation could not be folded, returns None.
Note that while this folds only one operation, multiple new operations can be created. Each of the results of the original operation might be replaced by a new constant operation.
Source code in xdsl/folder.py
insert_with_fold(op: Operation, builder: Builder) -> Sequence[SSAValue] | None
¶
Inserts the operation using the provided builder, trying to fold it first. If folding is successful, the folded results are returned, otherwise None is returned.
Source code in xdsl/folder.py
replace_with_fold(op: Operation, rewriter: PatternRewriter, safe_erase: bool = True) -> Sequence[SSAValue] | None
¶
Replaces the operation with its folded results. If folding is successful, the folded results are returned. Otherwise, returns None.