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] Tabular comparisons (including for tuples of boolean, one-hot cases) can be cumbersome in Rustic match syntax #1913

Open
cdleary opened this issue Feb 6, 2025 · 1 comment
Labels
dslx DSLX (domain specific language) implementation / front-end enhancement New feature or request

Comments

@cdleary
Copy link
Collaborator

cdleary commented Feb 6, 2025

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

As described in this comment and its followups: #1909 (comment)

It's common to smash some boolean values together and make a table of how you want to handle the possibilities for that bit vector. We may want to consider better syntax for this.

(Aside: IMO ideally if we do add non-Rustic syntax there's a simple way we can describe a simple desugaring of it into a Rustic pattern match just as confirmation we're not adding anything too far afield.)

cc @proppy @ericastor @mikex-oss

Current best alternative workaround (limit 100 words)

As described in followup comments we have things like:

match one_hot(sel) {
  0b100 => 
  0b010 => 
  0b001 =>
  _ => fail!("impossible_if_original_was_one_hot", ...)
}

which should demonstrate conclusively to the optimizer it can use a one_hot_sel and constructs like

match (x, y, z) {
  (true, _, _) => ...
  (_, true, _) => ...
  (_, _, true) => ...
   _ => ...
}

which lower to priority selectors on individual boolean values being set and should optimize into a prio sel primitive selector, but the OP here suggests that if this is common enough we may want to consider streamlining it.

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

Consider the addition of dedicated syntax for this (i.e. if we find it is quite common and the next-best-alternative is considered too burdensome given that frequency).

@cdleary cdleary added the enhancement New feature or request label Feb 6, 2025
@cdleary cdleary added the dslx DSLX (domain specific language) implementation / front-end label Feb 6, 2025
@proppy
Copy link
Member

proppy commented Feb 7, 2025

Related #1729

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

2 participants