-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
refactorTool ImprovementTool Improvement
Description
The current implementation of IntrinsicFunction in mono.md deviates from our established patterns for modeling JSON contents in K sorts. This issue tracks the technical debt introduced in PR #659 to enable intrinsic function support, which we're accepting temporarily to unblock development.
Current Issues
- Inconsistent Symbol Naming Convention
- The IntrinsicFunction constructor lacks the MonoItemKind:: prefix that other constructors use
- Current: IntrinsicFunction(Symbol)
- Expected: MonoItemKind::IntrinsicFunction(Symbol) or similar - Deviation from JSON Modeling Pattern
- Previously, all sorts used by kmir-ast.md were directly present in the JSON
- IntrinsicFunction introduces a K-specific constructor that doesn't directly correspond to the JSON structure
- This breaks the 1:1 mapping between stable-mir-json output and K sorts
Proposed Solution
Consider refactoring to use a different sort structure that better separates concerns:
- Create distinct constructors like Function(Symbol, Body) and Intrinsic(Symbol) in the runtime function table. This would maintain the JSON modeling integrity while still supporting intrinsic functions
- Don't tightly couple stable-mir-json and kmir, but rather let stable-mir-json focus on extracting all useful MIR information, while kmir focuses on formal semantics. The connection between stable-mir-json and kmir can also be accomplished through a tool.
Context
- Related PR: Implement std::hint::black_box intrinsic support in KMIR #659 (initial intrinsic function support)
- Related stable-mir-json PR: Use mangled name for intrinsic symbols stable-mir-json#85
- Affected files:
- kmir/src/kmir/kdist/mir-semantics/mono.md:37
- kmir/src/kmir/kmir.py (function map generation)
- kmir/src/kmir/kdist/mir-semantics/kmir.md (intrinsic execution rules)
Notes
This refactoring should be done after:
- The relationship between kmir and stable-mir-json is better defined
- Any broader kmir refactoring efforts are completed
- The stable-mir-json intrinsics PR is merged and stabilized
Metadata
Metadata
Assignees
Labels
refactorTool ImprovementTool Improvement