ISyntax: replace SYB traversals with explicit ones#1045
Open
nanavati wants to merge 1 commit into
Open
Conversation
quark17
previously approved these changes
Jul 14, 2026
quark17
left a comment
Collaborator
There was a problem hiding this comment.
This looks good. I wonder if deriving can be removed from more files, then? For example, the deriving in IStateLoc.hs, IType.hs, VModInfo.hs, Wires.hs, etc may only have been to support the deriving in ISyntax?
Also, tangentially, PR #722 was interested in removing the syb dependency by at least changing the imports to Data.Data.
Generic.everywhere rebuilds every node of the IModule whether changed or not; the transformation only rewrites ICon identifiers. An explicit traversal covers the same reachable ICon sites (heap references are leaves either way, since the cells sit behind IORefs), preserves untouched subtrees instead of reallocating them, and answers the old XXX about IAps recursion explicitly. bluetcl's find_vmodinfo becomes a direct query (ICVerilog is the only VModInfo carrier reachable in an IPackage), and with the last generic traversals gone, the Data/Typeable derivings on ISyntax and HeapData are removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012KHVhEzJpur1ZRjNjpzBVj
nanavati
force-pushed
the
isyntax-explicit-traversal
branch
from
July 14, 2026 18:15
50a84e4 to
4a6f31b
Compare
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.
Replaces the two
Data.Generics(syb) traversals over ISyntax with explicit ones, and drops the now-unusedData/Typeablederivings from ISyntax and the evaluator heap types.Motivation
Generic traversals over a compiler IR fail in the worst way available: when a constructor or field is added,
everywhere/listifysilently skip it rather than failing to compile. The two ISyntax users are rewritten as explicit traversals with exhaustive constructor matches, so any future ISyntax change surfaces at the traversal site as an incomplete-pattern warning. This also removes the obligation to keepDatainstances over types embedding IORef-backed heap references, and leaves ISyntax free to evolve its representation without generic-traversal compatibility as a constraint.Changes
IExpand.removeInlinedPositions: theeverywhererewrite becomes an explicit traversal. It must remain lazy — clock/reset/inout wires are cyclic throughIStateVar, and only lazy unrolling terminates (now documented at the site). One behavior made explicit rather than incidental: thePredset is rebuilt withS.map, sincePTerm'sOrdconsults inlined positions and removing them can reorder or collapse elements (this matches the old syb-era rebuild throughfromList).bluetcl.find_vmodinfo:listifybecomes a direct query, preserving left-to-right, duplicate-keeping order. The site now documents the invariant that makes the direct query complete: VModInfo reaches anIPackageonly throughICVerilog— the synthesis boundary re-abstracts every synthesized module as a Verilog wrapper (the same representation as a hand-writtenimport "BVI"), and the richer elaboration products never re-enter package vocabulary.ISyntax.hs/IExpandUtils.hs: drop allData/Typeablederiving sites (16 in ISyntax, plusPExpr/HeapCell/HeapData), the now-deadDeriveDataTypeablepragmas, and a stale commented-outconstrIndexalternative. The remaining syb users insrc/comptraverse Verilog syntax only.Validation
install-src,install-extra), typecheck closures for bothbscandbluetcl.bsc.misc/method_conditions134/0 (the end-to-end exerciser of-keep-method-conds, the flag gatingremoveInlinedPositions),bsc.showrules48/0, and thebsc.bluetcldirectories.sysMethodConds_RegWrite.bluetcl-outbyte-identical to its golden — position tuples are exactly the data this transformation shapes.🤖 Generated with Claude Code
https://claude.ai/code/session_01LVL9ornS6uf9hVxAuL7GhK