Return the set of all values that may be initialized in the blocks. This omits registers that are only read.
(args: list[Register], blocks: list[BasicBlock])
| 346 | |
| 347 | |
| 348 | def all_values(args: list[Register], blocks: list[BasicBlock]) -> list[Value]: |
| 349 | """Return the set of all values that may be initialized in the blocks. |
| 350 | |
| 351 | This omits registers that are only read. |
| 352 | """ |
| 353 | values: list[Value] = list(args) |
| 354 | seen_registers = set(args) |
| 355 | |
| 356 | for block in blocks: |
| 357 | for op in block.ops: |
| 358 | if not isinstance(op, ControlOp): |
| 359 | if isinstance(op, (Assign, AssignMulti)): |
| 360 | if op.dest not in seen_registers: |
| 361 | values.append(op.dest) |
| 362 | seen_registers.add(op.dest) |
| 363 | elif op.is_void: |
| 364 | continue |
| 365 | else: |
| 366 | # If we take the address of a register, it might get initialized. |
| 367 | if ( |
| 368 | isinstance(op, LoadAddress) |
| 369 | and isinstance(op.src, Register) |
| 370 | and op.src not in seen_registers |
| 371 | ): |
| 372 | values.append(op.src) |
| 373 | seen_registers.add(op.src) |
| 374 | values.append(op) |
| 375 | |
| 376 | return values |
| 377 | |
| 378 | |
| 379 | def all_values_full(args: list[Register], blocks: list[BasicBlock]) -> list[Value]: |
searching dependent graphs…