Skip to content

Update to Scala 3.8.3 + relaxed DFDecimal rules, more fixes and docs#378

Merged
soronpo merged 29 commits into
mainfrom
training
Apr 9, 2026
Merged

Update to Scala 3.8.3 + relaxed DFDecimal rules, more fixes and docs#378
soronpo merged 29 commits into
mainfrom
training

Conversation

@soronpo
Copy link
Copy Markdown
Collaborator

@soronpo soronpo commented Apr 9, 2026

Fixes #374 and #375

Oron Port and others added 29 commits April 7, 2026 02:26
- Fix misleading comment that SInt slice returns Bits — it preserves
  the source type (SInt→SInt, UInt→UInt, Bits→Bits) (#65)
- Add Bit Concatenation section documenting the ++ operator and
  tuple .toBits alternative (#66)
- Clarify that .width works on DFHDL values (ports, variables,
  constants declared with <>) with cross-reference (#67)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…perations

Two changes to the exactOp macros in Exact.scala:

1. Remove cleanTypeHack indirection — the extra transparent inline +
   inline match layer around every exactOp* call was causing the Scala 3
   compiler to re-expand the inline tree exponentially at each chained
   operation.

2. Add flattenInlined tree optimization — the macros now flatten nested
   Inlined nodes from subexpressions by extracting val bindings into a
   flat Block, reducing the tree depth that the compiler's posttyper
   phase processes.

Together these reduce compile time for chained arithmetic expressions
from exponential to near-linear (e.g. 4-operand + .bits(13,0): 23s → 3s,
5-operand: 176s → 7s).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the cleanTypeHack inline-match workaround with ascribeWidenedType,
which adds a Typed node using the dealiased type in the macro output.
This achieves the same clean error messages (no ExactOp2Aux[...].Out
projections) without adding an extra transparent inline layer that
caused exponential compile time growth.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that error messages from chained transparent inline operations
show resolved DFVal types rather than ExactOp2Aux[...].Out projections.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Check1.Check and Check2.Check inline given instances don't need
transparent since they always return Check[...] with no type narrowing.
Removing transparent avoids unnecessary inline expansion overhead during
given resolution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Neither CTName nor DualSummonTrapError use dependent type narrowing
in their return types, so transparent is unnecessary overhead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a plugin phase that runs between typer and posttyper to flatten
deeply nested Inlined trees from chained transparent inline expansions.
The Scala 3 posttyper phase exhibits super-linear behavior on nested
Inlined nodes, so flattening them beforehand reduces compile time
further for large expression chains.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-minimize Inlined call trees in FlattenInlinedPhase to prevent PostTyper
from re-transforming complex call trees that are immediately discarded.
PostTyper's Inlined handler calls transform(call) but replaces the result
with inlineCallTrace — a simple Ident. By pre-computing this Ident in our
plugin phase, we eliminate O(N²) behavior from chained inline expansions.

Results: 8 additions 33s→2s, 9 additions 130s→3s, 20 additions ∞→7s.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
A 20-addition chain (21 operands) that would have been impossible to
compile before the FlattenInlinedPhase.minimizeCall fix. If this
regresses, compilation of this test file will hang or OOM.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Consecutive same-op anonymous Funcs for &, |, ^, and ++ (DFBits only) are
now merged into a single multi-arg Func during elaboration. For example,
`a ^ b ^ c` produces Func(^, [a, b, c]) instead of nested binary Funcs.

+, -, * are excluded because carry promotion assumes binary (2-arg) Funcs.
++ is restricted to flat DFBits concatenation (not struct/vector/string).
Multi-referenced nodes are not merged to preserve CSE naming.
Merged positions span from the first operand to the last in the chain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@soronpo soronpo changed the title Update to Scala 3.8.3 + more fixes and docs Update to Scala 3.8.3 + relaxed DFDecimal rules, more fixes and docs Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Knowledge Gap] partial_histogram_add.v - Chained UInt arithmetic causes Scala 3 compilation timeout

1 participant