rizinorg / rizin

UNIX-like reverse engineering framework and command-line toolset.
https://rizin.re
GNU Lesser General Public License v3.0
2.51k stars 341 forks source link

SoftFloat integration #4535

Closed DMaroo closed 3 days ago

DMaroo commented 3 weeks ago

Your checklist for this pull request

Detailed description

I have added failing tests when using 80-bit floats (similar to the one outlined in #4252). I have also added a new meson subproject which clones SoftFloat version ~2c~ 3e. It is hosted at https://github.com/rizinorg/softfloat. I have made minor modifications to the original source which include the following:

Why use version 2c over 3e?

The complete changelog can be found here, but it has mainly to do with bugfixes in the square root algorithm, support for bfloat and a new rounding mode (round to nearest, ties away: RZ_FLOAT_RMODE_RNA in Rizin and softfloat_round_near_maxMag in SoftFloat).

Test plan

Added new tests for 80-bit floats. Newly added f80_ieee_{add,sub,mul,div}_test fail and f80_ieee_sqrt_test times out with the old implementation, and passes with the new implementation.

Closing issues

Closes #4252.

DMaroo commented 3 weeks ago

As a proof of concept, the previously failing test case f80_div_test now passes when using SoftFloat functions to calculate the result.

Rot127 commented 3 weeks ago

Could you push it to a dist-fuzz- branch, so we have an idea how many builds potentially fail? https://github.com/rizinorg/rizin/tree/dist-fuzz-softfloat-integration

Builds are ok, tests fail of course. Would be for this change then.

DMaroo commented 5 days ago

Code looks good at a first glance. Requesting changes for myself to make sure I have tested this on ppc and sparc before we merge.

@thestr4ng3r Thank you! But 80-bit floats are an x87 thing and I don't think SPARC and/or PPC have them, hence the newly added 80-bit float tests wouldn't be run there. However, it is definitely worth testing whether the existing tests pass.

wargio commented 5 days ago

Code looks good at a first glance. Requesting changes for myself to make sure I have tested this on ppc and sparc before we merge.

@thestr4ng3r Thank you! But 80-bit floats are an x87 thing and I don't think SPARC and/or PPC have them, hence the newly added 80-bit float tests wouldn't be run there. However, it is definitely worth testing whether the existing tests pass.

if is an endian problem or similar it could still work especially since i expect this to be software floats.

thestr4ng3r commented 3 days ago

To whoever merges this, please squash and add a good commit description like "Replace RzFloat implementation by SoftFloat 3e"