Interpreter associated types#677
Open
zhenrongliew wants to merge 7 commits into
Open
Conversation
…fect algebra Collapse Interpretable<L, I, F, C, E, T> into Interpretable<I>, moving Value/Error/Effect onto associated types of Interp. Rename the forward control enum Effect -> ForwardEffect and expose it as the per-analysis I::Effect (forward/concrete/constprop engines set type Effect = ForwardEffect<Value, Error>) via a ForwardInterp helper trait. ForwardEffect stays forward-only (Next, Jump, Branch, Call, Yield, Return, Enter, EnterAny); future analyses define their own I::Effect. Frames remain customizable and own traversal. No liveness. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Introduced total frame types for the toy language, embedding standard framework frames with SCF if/for frames. - Updated the `Frame` and `AbstractFrame` implementations to support new SCF frames. - Enhanced documentation to clarify the role of structured control flow in dialects. - Added tests for constant propagation analysis with `scf.if` constructs, ensuring correct behavior for both identical and differing constant yields. - Refactored existing tests to accommodate changes in frame handling and analysis.
Roger-luo
reviewed
Jun 23, 2026
- Updated the implementation of Interpretable and FunctionEntry traits to specialize on ForwardContext instead of Ctx, allowing for a clearer separation of context types for different analyses. - Modified various interpreter implementations (e.g., If, For, Yield) to utilize ForwardContext for SSA read/write operations. - Enhanced documentation to reflect the changes in context handling and the specialization boundary between forward and future analyses. - Adjusted related tests and snapshots to align with the new context structure, ensuring consistency across the interpreter's functionality.
- Renamed `Env` trait to `Store` for clarity in the context of storage capabilities. - Updated references to `Env` in the `FrameDriver` and `ForwardFrameDriver` traits to reflect the new naming. - Introduced `ForwardAbstractInterpreter` as the forward dataflow engine, replacing `AbstractInterpreter` in relevant contexts. - Adjusted documentation to clarify the distinction between shared protocols and forward-specific capabilities. - Updated example implementations and tests to utilize the new forward dataflow structures. - Ensured backward compatibility by retaining aliases for the previous frame driver capabilities.
- Introduced `ValueContext` to replace `ForwardContext` across various modules, enhancing clarity and consistency in the interpreter's context management. - Updated implementations of `Interpretable` and `FunctionEntry` traits to utilize `ValueContext`, ensuring all dialects and functions align with the new context structure. - Adjusted related documentation to reflect the changes in context usage, emphasizing the role of `ValueContext` in both execution and analysis. - Removed unnecessary dependencies on `HasTop` in the `AbstractInterpreter` trait, streamlining the trait's requirements.
- Introduced `ForwardAbstractInterpreter` to facilitate forward lattice-based abstract interpretation. - Added traits for customizable analysis policies: `CallContext` and `WideningStrategy`. - Implemented context-insensitive analysis with join-until-widen behavior. - Created `FnInfo` struct to manage function summaries and their associated data. - Developed methods for analyzing functions by name and running interprocedural fixpoints. - Added `Interp` and `Env` traits to define shared contracts for concrete execution and analyses. - Introduced `ForwardEval` and `BackwardLiveness` markers for semantic evaluation types. - Enhanced SSA storage access with `ForwardEvalInterp` for reading and writing SSA values.
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.
Summary
This PR focuses on interpreter refactor to consolidate type parameters :
Interpretable<L, I, F, C, E, T>intoInterpretable<I>Value,Error, and statementEffectontoInterpassociated typesCtxas the statement-local read/write helperForwardEffectthe forward-only statement-to-frame algebraScope/ScopeHookabstractionscf.ifandscf.fornow push SCF-owned concrete/abstract framesNotes
Enter/EnterAnyare gone. Their abstract behavior is now owned by SCF frames. New focused constprop tests cover unknownscf.ifjoining:Const(1)TopBackward/liveness analysis is intentionally deferred to a follow-up PR with its own effect algebra.