Skip to content

Support use syntax in TIv2 - #4845

Open
rw1nkler wants to merge 10 commits into
google:mainfrom
antmicro:102999-use-syntax
Open

rw1nkler wants to merge 10 commits into
google:mainfrom
antmicro:102999-use-syntax

Conversation

@rw1nkler

Copy link
Copy Markdown
Contributor

This PR adds support for use support in TIv2, and makes it operational with bytecode interpreter that relies on TIv1 data structures.

What's included:

  • Resolution of use-bound constants, functions, structs, and type aliases, used directly or reached via ColonRef on a whole-module use subject, including nested module paths
  • Spawning use-imported procs and proc aliases
  • Constexpr propagation for use-imported constants, so they work as parametric defaults
  • A fix for an IR-conversion crash on whole-module use of a module named std

Implementation details:

  • Shared ImportData helpers (ResolveUseImportedTarget, GetUseImportedModuleInfo) let the typechecker and bytecode emitter resolve a use-bound name consistently
  • ColonRef resolution now distinguishes a whole-module use subject from a use-bound value
  • The parser binds a use-bound proc's bare name plus .config/.next/.init keys to the same entry. Since all four resolve to the same proc, the identifier's suffix is the only signal for which member was meant. This suffix lookup runs independently at typecheck time and at bytecode-emission time.

This PR also re-enables the use-syntax end-to-end DSLX tests that were previously disabled pending TIv2 support.

@richmckeever richmckeever self-assigned this Aug 25, 2026
Comment thread xls/dslx/frontend/ast_utils.cc Outdated
@magancarz

Copy link
Copy Markdown
Contributor

I rebased changes onto the latest main and removed support for use and legacy procs.

@proppy
proppy requested a review from richmckeever October 9, 2026 06:15

@richmckeever richmckeever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are places, such as MakeTypeCheckedNumberOrEnumValue in inference_table_utils.cc has a case for use which returns UnimplementedError. We should make those consider UseTreeEntry appropriately and add test cases. An AI search would be a good idea for that, since they don't have uniform search criteria.

Comment thread xls/dslx/type_system_v2/typecheck_module_v2_use_test.cc
Comment thread xls/dslx/type_system_v2/typecheck_module_v2_use_test.cc Outdated
Comment thread xls/dslx/type_system_v2/constant_collector.cc Outdated
@rw1nkler
rw1nkler marked this pull request as draft October 21, 2026 14:41
Resolves use-bound constants, functions, structs, and type aliases,
directly or via ColonRef on a whole-module use subject.

Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Lets them be used as parametric defaults and bitwidth expressions,
not just directly.

Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
A free variable naming the module itself, not one of its members,
was incorrectly assumed to always resolve to a constant.

Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Covers use-syntax mechanics and per-entity-kind resolution; re-enables
the use-syntax e2e DSLX tests disabled pending TIv2 support.

Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
GitHub regenerated the slang archive, so the checksum in the registry
no longer matches it.

Internal-tag: [#102999]
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
@rw1nkler
rw1nkler marked this pull request as ready for review October 27, 2026 13:16
@rw1nkler

rw1nkler commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

I have found a few more corner cases, for example around importing constant foo from module foo. I expanded the existing tests so the cover the discovered corner cases too.

@richmckeever PTAL

I also added one do-not-merge commit on top, because with the current state of this repository I cannot build this branch correctly without it. It should be dropped later on when proper fix for sv-lang import is provided.

This branch has not been deployed

No deployments
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.

3 participants