Generalize interpreter traversal over CFG, Block, DiGraph, and UnGraph bodies#684
Open
zhenrongliew wants to merge 5 commits into
Open
Generalize interpreter traversal over CFG, Block, DiGraph, and UnGraph bodies#684zhenrongliew wants to merge 5 commits into
zhenrongliew wants to merge 5 commits into
Conversation
This commit introduces a new test file `body_kinds.rs` that contains acceptance tests for the generic interpreter bodies. The tests cover various scenarios including: - A Cfg-bodied `main` calling a DiGraph-bodied function. - A statement inside a Cfg block that owns a DiGraph body. - A linear callable with a flat instruction list. - Ensuring that graph nodes run in topological order. These tests aim to validate the interaction between Cfg-SSA code and DiGraph computational graphs, ensuring correct execution and error handling.
- Renamed `BodyFrame` to `BlockFrame` and adjusted related documentation to reflect the new terminology. - Enhanced the `ToyFrame` enum to include `BlockFrame` and `CfgFrame`, replacing `BodyFrame`. - Updated `FrameBuild` implementations in `ToyFrame` and `TracingFrame` to accommodate the new frame types. - Revised tests in `tests/body_kinds.rs` to ensure compatibility with the updated frame structure. - Added comprehensive tests for structured control flow (SCF) operations, including `scf.if` and `scf.for`, demonstrating their integration with the new frame types. - Implemented a custom callable-UnGraph policy to handle ungraph traversal, ensuring proper execution order and output handling.
Resolve conflicts from the Region->CFG rename (#683, now in rust): - Apply the same Cfg->CFG / CFGs->CFG naming to this branch's changes. - Keep this branch's restructure of concrete/frames.rs into concrete/frames/ (drop the stale single-file frames.rs that rust only renamed). - Drop now-unused CFG imports surfaced by the merge. All tests (1234) and doctests pass; fmt and clippy clean.
Roger-luo
reviewed
Jul 17, 2026
| /// are structurally legal IR but have no single-pass execution order. | ||
| pub struct DiGraphWalkQuery(pub kirin_ir::DiGraph); | ||
|
|
||
| impl<S, L> StageAction<S, L> for DiGraphWalkQuery |
Collaborator
There was a problem hiding this comment.
Can you remind me, what is a StageAction?
Collaborator
Author
There was a problem hiding this comment.
StageAction lets the interpreter access the specific stage-local DiGraph. In this case it resolves the graph and builds the walk plan that DiGraphFrame executes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generalize interpreter body traversal beyond CFGs
Part of #667. This addresses the second follow-up identified in the issue:
Depends on the Region → CFG rename PR.
Summary
Bodyvocabulary covering:CfgBlockDiGraphUnGraphCfgFrametraverses CFGs.BlockFrametraverses one Block.DiGraphFrametraverses a directed computational graph.CallFramemanages callee resolution, activation lifetime, returns, and caller result binding.FrameBuild::from_ungraph_entry; otherwise the interpreter reportsNoDefaultWalker.Scope
Bodyremains an intentionally closed enum of Kirin’s built-in body representations. The extensibility point for UnGraph is its traversal policy, since an undirected graph has no inherent execution order.The remaining toy-lang sparse/dense liveness simplification from #667 is left for a separate PR.