refactor(ir): separate callable discovery from interpreter dispatch - #729
Open
zhenrongliew wants to merge 1 commit into
Open
refactor(ir): separate callable discovery from interpreter dispatch#729zhenrongliew wants to merge 1 commit into
zhenrongliew wants to merge 1 commit into
Conversation
- Introduced `HasCallableBody` trait for IR-level callable-body discovery, replacing the previous `FunctionEntry` trait. - Added `Body` enum to represent different computation representations (Block, CFG, DiGraph, UnGraph). - Updated dialect definitions to support the new callable body mechanism, ensuring only one callable body field is allowed. - Removed `FunctionEntry` trait and its implementations across various languages. - Adjusted linker resolution to return `LinkTarget` and `ResolvedCallable` instead of `FunctionTarget` and `CallableBody`. - Enhanced error handling for invalid callable body definitions, including duplicate and unsupported field types. - Updated tests to validate new callable body functionality and ensure backward compatibility.
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.
Stacked on #724.
#724
made callable-body discovery input value-independent and gave every engine one shared callable-root prefix. It left the discovery mechanism in the interpreter. This PR moves it into
kirin-irand makes it derivable from the operation's own declaration.Previously:
Discovering a callable’s body required routing through
InterpDispatch::dispatch_function_entry.FunctionTargetcopied the definition statement, so a linker could contradict the IR.FunctionTarget { stage, function, definition }carried a Statement copied out of the specialization record, even thoughSpecializedFunctionInfoauthoritatively owns it.The declaration was hand-written and unchecked. Every language enum added
FunctionEntryto its derive list and marked#[callable]variants; every dialect wrote theimplby hand.Fix:
Move callable-body discovery into
kirin-ir, so interpreters can discover a definition’s implementation withoutdispatch.
Dialectnow derivesHasCallableBody: callable definitions mark one body with#[kirin(callable_body)].Restrict linking to selecting a stage and specialization (
LinkTarget).Structural discovery reads the specialization’s definition at that stage and returns its body alongside the target (
ResolvedCallable).Remove
FunctionEntry, its derive and wrapper markers, andInterpDispatch::dispatch_function_entry. Concrete execution and forward and backward analyses share structural discovery, then apply their ownboundary initialization and traversal.