Folder
folder
Folder
dataclass
Source code in xdsl/folder.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
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.
Source code in xdsl/folder.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |