Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xls][mlir] Fix emission of debug locations in xls_translate #1992

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

schilkp
Copy link
Contributor

@schilkp schilkp commented Mar 9, 2025

As noted in #1916, I was not able to easily add a round-trip test for channel attributes due to some issues with debug locations in xls_translate.

While fixing this, I wanted to verify that round-trip conversion worked by smoke testing with ops_translate.mlir, where I noticed that my xls->mlir translation did not support trace and that my naming of the fifo flop kind enum was inconsistent.


Poping the stack, this PR contains the following commits addressing all of the above:

[xls][mlir] Use underscore in zero latency enum case name

Makes it consistent with all other values in XLS MLIR assembly.

[xls][mlir] Add xls->mlir translation of trace IR node

[xls][mlir] Emit well-formed XLS source location infos in xls_translate

xls_translate previously assigned an ID to every source file encountered in the MLIR Location of input ops and referenced these IDs in the XLS pos attribute of the produced IR nodes, but did not actually add these source file names to the XLS package, leading to invalid pos attributes.

This patch fixes this by relying on Package::AddSourceLocation to both construct the SourceLocation for nodes and automatically registering the file with the package.

With this, xls_translate can also re-use the file name ID assignment/lookup from XLS proper.

[xls][mlir] Add round-trip conversion test for channel properties

This was previously not easily possible due to the incorrect emission of XLS file locations in xls_translate.

[xls][mlir] Expand ops_translate.mlir test to round-trip verification.


I rolled all this into a single PR because these are all interdependent, probably making review a bit more annoying. Sorry 😇

@jpienaar @jmolloy

schilkp added 5 commits March 9, 2025 07:43
Makes it consistent with all other values in XLS MLIR assembly.
`xls_translate` previously assigned an ID to every source file
encountered in the MLIR `Location` of input ops and referenced these IDs
in the XLS `pos` attribute of the produced IR nodes, but did not
actually add these source file names to the XLS package, leading to
invalid `pos` attributes.

This patch fixes this by relying on `Package::AddSourceLocation` to both
construct the `SourceLocation` for nodes and automatically registering
the file with the package.

With this, `xls_translate` can also re-use the file name ID
assignment/lookup from XLS proper.
This was previously not easily possible due to the incorrect emission of
XLS file locations in `xls_translate`.
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.

1 participant