-
Notifications
You must be signed in to change notification settings - Fork 170
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
Simplify softfloat interface #289
Conversation
@Timmmm The clang-format pre-commit check is failing. Could you make sure that your PR follows the style (i.e., that you run clang-format)? Thx. |
1093071
to
0f1ac67
Compare
Ooops, fixed now. |
The test failures are due to the OCaml emulator not building and are expected, as noted in the PR message. |
I don't understand what's wrong with static linking, and wrapping random external code in an anonymous namespace is a "you pick up the pieces when it breaks" scenario, but using the return value directly is indeed cleaner if it works. However, you seem to be doing three different things in the one commit, which makes it harder to review. Please separate out the return value change, the flags accrual change (to avoid the callback) and the flags getter change. |
0f1ac67
to
4c6d4fd
Compare
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. This commit only applies the changes to f16add/sub/mul/div to make review easier.
Copy/paste the changes in the previous commit to all softfloat methods.
4c6d4fd
to
979d6f2
Compare
Not static linking; static linkage. The Sail
This is me picking up the pieces! :-)
Fair point. It's actually a very small change but there are so many softfloat methods it's difficult to review like this. I've split it into two commits - the first has all the actual changes and updates the |
I appreciate the reasoning behind it, but having intermediate commits in the history that don't work is a no-no. |
Ok I can squash it before merging. The three changes you mentioned are tightly linked and the changes to the code are quite minimal and easy to review. I would rather not spend a lot of time making intermediate commits that only fix 1/3 of the issue! |
Actually the removal of write_fflags can probably be separated out fairly easily and it shouldn't require changes to OCaml. I'll make a separate PR for that. |
Ok the first part is #290 |
Part 2 here: #340 |
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).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 forwrite_fflags()
andupdate_softfloat_fflags()
.Tested with
run_fp_tests.sh
- all 82 tests pass.Note, I have not updated the OCaml or Lem parts yet because I wanted to get agreement before doing all that work.