Commit aaca8d1
copilot-bluespec: Fix translation of special Float values to Bluespec. Refs #697.
`copilot-bluespec`'s translation from Copilot to Bluespec up-casts `Float`
values to `Double` values using the `realToFrac` function. `realToFrac`
incorrectly handles special floating-point values such as negative zero,
infinity, and NaN values, causing `copilot-bluespec` to generate the wrong
`Float` values on the Bluespec end.
This commit removes the use of `realToFrac` in favor of an alternative approach
based on `GHC.Float.float2Double`, which correctly handles most special
floating-point values. A notable exception is NaN values, as `float2Double`
does not reliably preserve the payload of a NaN value. As such, we include a
special case for NaN values that takes care to preserve payloads.
Co-authored-by: Ryan Scott <rscott@galois.com>1 parent 0c987a7 commit aaca8d1
1 file changed
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
566 | 585 | | |
567 | 586 | | |
568 | 587 | | |
| |||
0 commit comments