google / google/xls

[enhancement] APFloat parametrics cleanup

Open
#2,383 1 comment 0 reactions 0 assignees View on GitHub
dslx enhancement
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

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

apfloat could use some (breaking) changes to improve consistency and usability of parametrics.

For example, we have:

`pub fn to_uint`

which means the APFloat parametrics can be inferred with just supplying the `RESULT_SZ`.

But the signed version looks like:

`pub fn to_int`

which means you need to specify all 3. I think this is arguably worse than both using the latter form, because then at least you are forced to specify all 3 parametrics in the same order.

We also have:

`pub fn round`.

This one is a bit unfortunate, because we need round style to be last to take a default, but the other two parametrics can always be inferred. This restricts inference to the no parametrics specified case. To improve this one might take a larger language change.

Another example:

`pub fn downcast`

Unlike most apfloat parametric lists (including `APFloat` itself, this takes`FRACTION_SZ` first, then `EXP_SZ`.

### Current best alternative workaround (limit 100 words)

I usually discover these due to type inference errors and then carefully review the API.

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

Parametrics should be consistent and allow automatic inference as much as possible.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.