-
Notifications
You must be signed in to change notification settings - Fork 271
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
riscv: deprecate intrinsics that cannot be used from Rust #1478
Conversation
r? @Amanieu (rustbot has picked a reviewer for you, use r? to override) |
Since these are still unstable, do we want to just delete them instead of deprecating them? |
That would be fine for me, we might want to consult with some RISC-V stakeholders. Cc @coastalwhite (not sure whom else to ping) Also, we should have some place to document why they are missing. |
I think these instructions can be deleted. The This also kind of goes for @Amanieu is way more knowledgable about what is proper for stdarch, but I would say remove the Floating-Point CSR instructions. |
These intrinsics should also be deprecated / deleted from the riscv crate then. Observing exception state or changing rounding modes is fundamentally impossible in Rust (same as in C/C++). You have to do the entire sequence of operations in a single inline asm block, e.g. "change rounding mode, do some math, change rounding mode back".
|
In the context of a kernel you have to set the rounding mode during startup to the default value if the boot protocol doesn't guarantee that it has this value and when switching tasks you have to restore the right floating point configuration for the task you are switching too. Kernels are generally compiled with usage of floating point instructions disabled, so there is no way for the compiler to observe that the rounding mode changed, rather it is effectively just a general purpose register which the compiler is not allowed to clobber, and thus there shouldn't be any UB. |
Sure there's always some super special situations that are exceptions. Technically this needs guarantees we do not provide (rustc will not synthesize float operations if you don't use any float operations), but practically this will work. However I assume mostly people using these intrinsics are not currently aware that they have to be in such a super special case or else what they are doing is wrong. |
If you enable the soft float abi and disable the floating point instruction target features (as you would for a kernel) then having the compiler emit float instructions would be a miscompilation that can cause crashes or worse. |
Sure, if the feature is entirely disabled we do promise not to use those instructions. |
☔ The latest upstream changes (presumably 68b3ddf) made this pull request unmergeable. Please resolve the merge conflicts. |
0415045
to
f2be5b9
Compare
I did that now. |
f2be5b9
to
35353b9
Compare
This is the RISC-V version of #1454.