Rewriter
rewriter
InsertPoint
dataclass
An insert point. It is either a point before an operation, or at the end of a block.
See external documentation.
Source code in xdsl/rewriter.py
18 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 | |
block: Block
instance-attribute
The block where the insertion point is in.
insert_before: Operation | None = field(default=None)
class-attribute
instance-attribute
The insertion point is right before this operation. If the operation is None, the insertion point is at the end of the block.
__init__(block: Block, insert_before: Operation | None = None) -> None
__post_init__() -> None
Source code in xdsl/rewriter.py
36 37 38 39 40 41 42 | |
before(op: Operation) -> InsertPoint
staticmethod
Gets the insertion point before an operation.
Source code in xdsl/rewriter.py
44 45 46 47 48 49 | |
after(op: Operation) -> InsertPoint
staticmethod
Gets the insertion point after an operation.
Source code in xdsl/rewriter.py
51 52 53 54 55 56 57 | |
at_start(block: Block) -> InsertPoint
staticmethod
Gets the insertion point at the start of a block.
Source code in xdsl/rewriter.py
59 60 61 62 | |
at_end(block: Block) -> InsertPoint
staticmethod
Gets the insertion point at the end of a block.
Source code in xdsl/rewriter.py
64 65 66 67 | |
BlockInsertPoint
dataclass
An insert point for a block. It is either a point before a block, or after a block.
Source code in xdsl/rewriter.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
region: Region
instance-attribute
The region where the insertion point is in.
insert_before: Block | None = field(default=None)
class-attribute
instance-attribute
The insertion point is right before this block. If the block is None, the insertion point is at the end of the region.
__init__(region: Region, insert_before: Block | None = None) -> None
__post_init__() -> None
Source code in xdsl/rewriter.py
86 87 88 89 90 91 92 | |
before(block: Block) -> BlockInsertPoint
staticmethod
Gets the insertion point before a block.
Source code in xdsl/rewriter.py
94 95 96 97 98 99 | |
after(block: Block) -> BlockInsertPoint
staticmethod
Gets the insertion point after a block.
Source code in xdsl/rewriter.py
101 102 103 104 105 106 107 | |
at_start(region: Region) -> BlockInsertPoint
staticmethod
Gets the insertion point at the start of a region.
Source code in xdsl/rewriter.py
109 110 111 112 | |
at_end(region: Region) -> BlockInsertPoint
staticmethod
Gets the insertion point at the end of a region.
Source code in xdsl/rewriter.py
114 115 116 117 | |
Rewriter
Source code in xdsl/rewriter.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
erase_op(op: Operation, safe_erase: bool = True)
staticmethod
Erase an operation. Check that the operation has no uses, and has a parent. If safe_erase is True, check that the operation has no uses. Otherwise, replace its uses with ErasedSSAValue.
Source code in xdsl/rewriter.py
121 122 123 124 125 126 127 128 129 130 131 132 | |
replace_op(op: Operation, new_ops: Operation | Sequence[Operation], new_results: Sequence[SSAValue | None] | None = None, safe_erase: bool = True)
staticmethod
Replace an operation with multiple new ones. If new_results is specified, map the results of the deleted operations with these SSA values. Otherwise, use the results of the last operation added. None elements in new_results are the SSA values to delete. If safe_erase is False, then operations can be deleted even if they are still used.
Source code in xdsl/rewriter.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
replace_value_with_new_type(val: SSAValue, new_type: Attribute) -> SSAValue
staticmethod
Replace a value with a value of a new type, and return the new value. This will insert the new value in the operation or block, and remove the existing value.
Source code in xdsl/rewriter.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
inline_block(source: Block, insertion_point: InsertPoint, arg_values: Sequence[SSAValue] = ())
staticmethod
Move the block operations before another operation. The block should not be a parent of the operation.
Source code in xdsl/rewriter.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
insert_block(block: Block | Iterable[Block], insert_point: BlockInsertPoint)
staticmethod
Insert one or multiple blocks at a given location. The blocks to insert should be detached from any region. The insertion point should not be contained in the block to insert.
Source code in xdsl/rewriter.py
274 275 276 277 278 279 280 281 282 283 284 285 | |
insert_op(op_or_ops: Operation | Sequence[Operation], insertion_point: InsertPoint)
staticmethod
Insert operations at a certain location in a block.
Source code in xdsl/rewriter.py
287 288 289 290 291 292 293 294 295 296 | |
move_region_contents_to_new_regions(region: Region) -> Region
staticmethod
Move the region blocks to a new region.
Source code in xdsl/rewriter.py
298 299 300 301 302 303 | |
inline_region(region: Region, insertion_point: BlockInsertPoint) -> None
staticmethod
Move the region blocks to a given location.
Source code in xdsl/rewriter.py
305 306 307 308 309 310 311 | |