Skip to content

feat: PyIR over the control-flow graph - #14

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
feat/pyir-cfg
Sep 3, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
feat/pyir-cfg

Conversation

@SizzleUnrlsd

@SizzleUnrlsd SizzleUnrlsd commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Phase 3 of docs/architecture.md: PyIR now follows the control-flow graph (§5, §6).

  • Acceptance tests first (test: define PyIR over the CFG), implementation follows.
  • The IR model carries explicit terminators: Return, Branch, Jump, Raise and ForNext, which keeps Python's iteration protocol explicit (get_iter before the loop header, for_next in it) instead of an LLVM-style switch. BasicBlock and FunctionIR are immutable; blocks mirror the CFG in its order and share its block ids.
  • PyIRAnalysis requires CFGAnalysis and lowers one block at a time. Values are numbered once per function. Parameters that are never reassigned stay plain values; reassigned ones are stored to a local at entry so every block reads the same slot.
  • --emit-ir prints one block per basic block, including unreachable code after return / raise.
  • README documents the supported control flow.

Not in this PR: dominators, SSA and phi nodes (next Phase 3 item), exception edges, with, the remaining §6 instructions that need new PyHIR nodes (SetAttr, SetItem, BuildList, ...).

Part of #13: terminators, immutable blocks and lowering over the CFG. The remaining §6 instructions stay open there.

@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 3, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit 0dace23 into main Sep 3, 2026
6 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/pyir-cfg branch September 3, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant