Update some assignments to registers to also set a bit in a bitmap. The bitmaps are used to track if a local variable has been assigned to. Modifies blocks.
(
blocks: list[BasicBlock], bitmap_registers: list[Register], bitmap_backed: list[Register]
)
| 169 | |
| 170 | |
| 171 | def update_register_assignments_to_set_bitmap( |
| 172 | blocks: list[BasicBlock], bitmap_registers: list[Register], bitmap_backed: list[Register] |
| 173 | ) -> None: |
| 174 | """Update some assignments to registers to also set a bit in a bitmap. |
| 175 | |
| 176 | The bitmaps are used to track if a local variable has been assigned to. |
| 177 | |
| 178 | Modifies blocks. |
| 179 | """ |
| 180 | for block in blocks: |
| 181 | if any(isinstance(op, Assign) and op.dest in bitmap_backed for op in block.ops): |
| 182 | new_ops: list[Op] = [] |
| 183 | for op in block.ops: |
| 184 | if isinstance(op, Assign) and op.dest in bitmap_backed: |
| 185 | index = bitmap_backed.index(op.dest) |
| 186 | new_ops.append(op) |
| 187 | reg = bitmap_registers[index // BITMAP_BITS] |
| 188 | new = IntOp( |
| 189 | bitmap_rprimitive, |
| 190 | reg, |
| 191 | Integer(1 << (index & (BITMAP_BITS - 1)), bitmap_rprimitive), |
| 192 | IntOp.OR, |
| 193 | op.line, |
| 194 | ) |
| 195 | new_ops.append(new) |
| 196 | new_ops.append(Assign(reg, new)) |
| 197 | else: |
| 198 | new_ops.append(op) |
| 199 | block.ops = new_ops |
no test coverage detected
searching dependent graphs…