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

[enhancement][DSLX] Add support for #[derive(Pack, Unpack)] to generate type_{from,to}_bits helpers #1698

Open
cdleary opened this issue Nov 7, 2024 · 0 comments
Labels
dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request

Comments

@cdleary
Copy link
Collaborator

cdleary commented Nov 7, 2024

What's hard to do? (limit 100 words)

Right now for complex structures you have to create bit and byte encoders and decoders by hand which can be error prone and not as amenable to metaprogramming.

Current best alternative workaround (limit 100 words)

You can write them by hand.

Your view of the "best case XLS enhancement" (limit 100 words)

We add annotations on struct definitions of the form #[derive(Pack, Unpack)] and that will generate ${type|lower}_{from,to}_bits functions. If so desired we could add least significant bit metadata to the annotation request.

Note that this would generate an "emphemeral" (not in the source text) function, likely as an integrated part of the DSLX type inference process, which is where we do other macro-esque actions that need type information. We would likely benefit from a more solid way to report any errors in emphemeral functions even though they were not present in the source text, but that seems like it might be supplemental if the generated functions generally could not have errors, but you can imagine things like reporting what went wrong in the callee where the callee was emphemeral so it was harder to point at what went wrong -- we do some of this already for BuiltinNameDefs though.

@cdleary cdleary added dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant