8000 Fix DSLX ToBits derivation for arrays of tuples and empty tuples by cdleary · Pull Request #5300 · google/xls · GitHub
[go: up one dir, main page]

Skip to content

Fix DSLX ToBits derivation for arrays of tuples and empty tuples - #5300

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
xlsynth:cdleary/2026-11-07-dslx-to-bits-tuples
Nov 10, 2026
Merged

copybara-service[bot] merged 1 commit into
google:mainfrom
xlsynth:cdleary/2026-11-07-dslx-to-bits-tuples

Conversation

@cdleary
@cdleary cdleary commented Nov 7, 2026 •
Copy link
Copy Markdown
Collaborator

Deriving ToBits for a DSLX struct could crash the frontend when a field contained an array of tuples or a nested empty tuple.

The tuple branch now uses the element type selected for the current expression. Array elements share a single type entry, so the second element of (bool,)[2] previously read past that entry. Concatenating zero elements now produces uN[0]:0, which handles () inside an aggregate and preserves the existing result for an empty struct.

The regression tests check that [(true,), (false,)] packs to u2:0b10 and that ((), bool) packs to one bit for either Boolean value.

Validation

  • All 21 tests in //xls/dslx/type_system_v2:typecheck_module_v2_trait_test passed in an optimized CI build.
  • The DSLX bytecode interpreter and XLS IR JIT both passed all Boolean input combinations for the two reported shapes.
  • Ran clang-format on both changed C++ files, preserving the existing gMock and gTest include order. The XLS build cleaner and Bant passed for both affected targets.
  • Ran the optimized //xls/... wildcard on b50d71752. All 2,205 selected test targets passed (1,074 executed, 1,131 cached). The sweep excluded //xls/contrib/..., //xls/dev_tools/..., //xls/visualization/..., and five tests whose dependency graphs reach OpenROAD, Yosys, or Clang.

Reuse the shared array element type when expanding tuple members. Return a zero-width value when concatenating an empty aggregate, including a nested unit or an empty struct. Add regressions for the bit order and result widths.
@copybara-service
copybara-service Bot merged commit 737b616 into google:main Nov 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0