forked from riscv/sail-riscv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently the softfloat interface relies on two global registers defined in Sail to return values, one of which is a mirror of `fflags`. Unfortunately this doesn't work if the model is compiled with `-static` or wrapped in an anonymous namespace (I am doing the latter in a similar way to [@arichardson's method here](https://github.com/CTSRD-CHERI/cheri-compressed-cap/blob/89d21384c0183e5c422e23e1e5b37e127ad14e96/test/sail_wrapper_common.c#L50)). This commit changes the design so that there is only a one-way dependency - the softfloat implementation does not depend on the model. This is done by returning the result of the floating point operation as a normal function return value, and then the model retrieves the new flags by simply calling another platform function (`extern_float_flags()`). This is a bit cleaner, works with `-static` and also removes the need for `write_fflags()` and `update_softfloat_fflags()`. Tested with `run_fp_tests.sh` - all 82 tests pass.
- Loading branch information
Showing
8 changed files
with
484 additions
and
627 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,87 @@ | ||
#pragma once | ||
|
||
unit softfloat_f16add(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f16sub(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f16mul(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f16div(mach_bits rm, mach_bits v1, mach_bits v2); | ||
|
||
unit softfloat_f32add(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f32sub(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f32mul(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f32div(mach_bits rm, mach_bits v1, mach_bits v2); | ||
|
||
unit softfloat_f64add(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f64sub(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f64mul(mach_bits rm, mach_bits v1, mach_bits v2); | ||
unit softfloat_f64div(mach_bits rm, mach_bits v1, mach_bits v2); | ||
|
||
unit softfloat_f16muladd(mach_bits rm, mach_bits v1, mach_bits v2, | ||
mach_bits softfloat_float_flags(unit); | ||
|
||
mach_bits softfloat_f16add(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f16sub(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f16mul(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f16div(mach_bits rm, mach_bits v1, mach_bits v2); | ||
|
||
mach_bits softfloat_f32add(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f32sub(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f32mul(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f32div(mach_bits rm, mach_bits v1, mach_bits v2); | ||
|
||
mach_bits softfloat_f64add(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f64sub(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f64mul(mach_bits rm, mach_bits v1, mach_bits v2); | ||
mach_bits softfloat_f64div(mach_bits rm, mach_bits v1, mach_bits v2); | ||
|
||
mach_bits softfloat_f16muladd(mach_bits rm, mach_bits v1, mach_bits v2, | ||
mach_bits v3); | ||
unit softfloat_f32muladd(mach_bits rm, mach_bits v1, mach_bits v2, | ||
mach_bits softfloat_f32muladd(mach_bits rm, mach_bits v1, mach_bits v2, | ||
mach_bits v3); | ||
unit softfloat_f64muladd(mach_bits rm, mach_bits v1, mach_bits v2, | ||
mach_bits softfloat_f64muladd(mach_bits rm, mach_bits v1, mach_bits v2, | ||
mach_bits v3); | ||
|
||
unit softfloat_f16sqrt(mach_bits rm, mach_bits v); | ||
unit softfloat_f32sqrt(mach_bits rm, mach_bits v); | ||
unit softfloat_f64sqrt(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_f16toi32(mach_bits rm, mach_bits v); | ||
unit softfloat_f16toui32(mach_bits rm, mach_bits v); | ||
unit softfloat_f16toi64(mach_bits rm, mach_bits v); | ||
unit softfloat_f16toui64(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_f32toi32(mach_bits rm, mach_bits v); | ||
unit softfloat_f32toui32(mach_bits rm, mach_bits v); | ||
unit softfloat_f32toi64(mach_bits rm, mach_bits v); | ||
unit softfloat_f32toui64(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_f64toi32(mach_bits rm, mach_bits v); | ||
unit softfloat_f64toui32(mach_bits rm, mach_bits v); | ||
unit softfloat_f64toi64(mach_bits rm, mach_bits v); | ||
unit softfloat_f64toui64(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_i32tof16(mach_bits rm, mach_bits v); | ||
unit softfloat_ui32tof16(mach_bits rm, mach_bits v); | ||
unit softfloat_i64tof16(mach_bits rm, mach_bits v); | ||
unit softfloat_ui64tof16(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_i32tof32(mach_bits rm, mach_bits v); | ||
unit softfloat_ui32tof32(mach_bits rm, mach_bits v); | ||
unit softfloat_i64tof32(mach_bits rm, mach_bits v); | ||
unit softfloat_ui64tof32(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_i32tof64(mach_bits rm, mach_bits v); | ||
unit softfloat_ui32tof64(mach_bits rm, mach_bits v); | ||
unit softfloat_i64tof64(mach_bits rm, mach_bits v); | ||
unit softfloat_ui64tof64(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_f16tof32(mach_bits rm, mach_bits v); | ||
unit softfloat_f16tof64(mach_bits rm, mach_bits v); | ||
unit softfloat_f32tof64(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_f32tof16(mach_bits rm, mach_bits v); | ||
unit softfloat_f64tof16(mach_bits rm, mach_bits v); | ||
unit softfloat_f64tof32(mach_bits rm, mach_bits v); | ||
|
||
unit softfloat_f16lt(mach_bits v1, mach_bits v2); | ||
unit softfloat_f16lt_quiet(mach_bits v1, mach_bits v2); | ||
unit softfloat_f16le(mach_bits v1, mach_bits v2); | ||
unit softfloat_f16le_quiet(mach_bits v1, mach_bits v2); | ||
unit softfloat_f16eq(mach_bits v1, mach_bits v2); | ||
unit softfloat_f32lt(mach_bits v1, mach_bits v2); | ||
unit softfloat_f32lt_quiet(mach_bits v1, mach_bits v2); | ||
unit softfloat_f32le(mach_bits v1, mach_bits v2); | ||
unit softfloat_f32le_quiet(mach_bits v1, mach_bits v2); | ||
unit softfloat_f32eq(mach_bits v1, mach_bits v2); | ||
unit softfloat_f64lt(mach_bits v1, mach_bits v2); | ||
unit softfloat_f64lt_quiet(mach_bits v1, mach_bits v2); | ||
unit softfloat_f64le(mach_bits v1, mach_bits v2); | ||
unit softfloat_f64le_quiet(mach_bits v1, mach_bits v2); | ||
unit softfloat_f64eq(mach_bits v1, mach_bits v2); | ||
|
||
unit softfloat_f16roundToInt(mach_bits rm, mach_bits v, bool exact); | ||
unit softfloat_f32roundToInt(mach_bits rm, mach_bits v, bool exact); | ||
unit softfloat_f64roundToInt(mach_bits rm, mach_bits v, bool exact); | ||
mach_bits softfloat_f16sqrt(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f32sqrt(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f64sqrt(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_f16toi32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f16toui32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f16toi64(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f16toui64(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_f32toi32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f32toui32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f32toi64(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f32toui64(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_f64toi32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f64toui32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f64toi64(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f64toui64(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_i32tof16(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_ui32tof16(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_i64tof16(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_ui64tof16(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_i32tof32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_ui32tof32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_i64tof32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_ui64tof32(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_i32tof64(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_ui32tof64(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_i64tof64(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_ui64tof64(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_f16tof32(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f16tof64(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f32tof64(mach_bits rm, mach_bits v); | ||
|
||
mach_bits softfloat_f32tof16(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f64tof16(mach_bits rm, mach_bits v); | ||
mach_bits softfloat_f64tof32(mach_bits rm, mach_bits v); | ||
|
||
bool softfloat_f16lt(mach_bits v1, mach_bits v2); | ||
bool softfloat_f16lt_quiet(mach_bits v1, mach_bits v2); | ||
bool softfloat_f16le(mach_bits v1, mach_bits v2); | ||
bool softfloat_f16le_quiet(mach_bits v1, mach_bits v2); | ||
bool softfloat_f16eq(mach_bits v1, mach_bits v2); | ||
bool softfloat_f32lt(mach_bits v1, mach_bits v2); | ||
bool softfloat_f32lt_quiet(mach_bits v1, mach_bits v2); | ||
bool softfloat_f32le(mach_bits v1, mach_bits v2); | ||
bool softfloat_f32le_quiet(mach_bits v1, mach_bits v2); | ||
bool softfloat_f32eq(mach_bits v1, mach_bits v2); | ||
bool softfloat_f64lt(mach_bits v1, mach_bits v2); | ||
bool softfloat_f64lt_quiet(mach_bits v1, mach_bits v2); | ||
bool softfloat_f64le(mach_bits v1, mach_bits v2); | ||
bool softfloat_f64le_quiet(mach_bits v1, mach_bits v2); | ||
bool softfloat_f64eq(mach_bits v1, mach_bits v2); | ||
|
||
mach_bits softfloat_f16roundToInt(mach_bits rm, mach_bits v, bool exact); | ||
mach_bits softfloat_f32roundToInt(mach_bits rm, mach_bits v, bool exact); | ||
mach_bits softfloat_f64roundToInt(mach_bits rm, mach_bits v, bool exact); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.