-
Notifications
You must be signed in to change notification settings - Fork 277
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
Add numeric instructions for Wasm not available in core
#1677
Conversation
ee6b75e
to
9f1540f
Compare
Oh nice! Seems reasonable to me :) I thought I had also seen some chatter on the Rust Zulip about making more floating-point methods available in libcore, so it might be good to sync up on that perhaps? I think it might also be best to start these out as unstable and then perhaps quickly follow up with a stabilization request with the rationale outlined? For code changes, perhaps the documentation of one of these functions could explain why it's available as an intrinsic and why you might not want to use it most of the time (e.g. the float methods all do the same thing). Other methods could then all link to that one instance of the documentation to avoid duplicating everything here. |
5c27494
to
59bf920
Compare
Couldn't find anything related on the quick, would appreciate a link if you have it on hand.
Sounds good, marked as unstable.
I just added a one-liner to each function and linked to the appropriate method in |
Took some digging as I also forgot, but I found:
I don't think that should hold this up personally though, but probably is worth considering for stabilization |
Ah, thanks. I was already aware of those and left a note in the OP. |
508fbcd
to
2b8eb66
Compare
CI seems to be unblocked again. |
This seems fine to add on nightly, but I wouldn't expect these to be actually stabilized: I would much prefer if we could have this functionality work directly on floats, even with If you still think this is worth it, please create a tracking issue and add the number the unstable attributes. |
2b8eb66
to
18ef3d9
Compare
Tracking issue created: rust-lang/rust#133908. |
@Amanieu friendly ping. |
Bump `stdarch` This bumps `stdarch` to rust-lang/stdarch@684de0d to get in rust-lang/stdarch#1677 (tracked in rust-lang#133908). From the [commit history](rust-lang/stdarch@e5e00aa...684de0d) I deduced that there shouldn't be any changes to Rust necessary. From past PRs I'm assuming that bumping `stdarch` like this is fine, but please let me know if this is somehow inappropriate or requires something more to be done!
Bump `stdarch` This bumps `stdarch` to rust-lang/stdarch@684de0d to get in rust-lang/stdarch#1677 (tracked in rust-lang#133908). From the [commit history](rust-lang/stdarch@e5e00aa...684de0d) I deduced that there shouldn't be any changes to Rust necessary. From past PRs I'm assuming that bumping `stdarch` like this is fine, but please let me know if this is somehow inappropriate or requires something more to be done! try-job: arm-android
Bump `stdarch` This bumps `stdarch` to rust-lang/stdarch@684de0d to get in rust-lang/stdarch#1677 (tracked in rust-lang#133908). From the [commit history](rust-lang/stdarch@e5e00aa...684de0d) I deduced that there shouldn't be any changes to Rust necessary. From past PRs I'm assuming that bumping `stdarch` like this is fine, but please let me know if this is somehow inappropriate or requires something more to be done! try-job: arm-android try-job: armhf-gnu
Bump `stdarch` This bumps `stdarch` to rust-lang/stdarch@684de0d to get in rust-lang/stdarch#1677 (tracked in rust-lang/rust#133908). From the [commit history](rust-lang/stdarch@e5e00aa...684de0d) I deduced that there shouldn't be any changes to Rust necessary. From past PRs I'm assuming that bumping `stdarch` like this is fine, but please let me know if this is somehow inappropriate or requires something more to be done! try-job: arm-android try-job: armhf-gnu
These wasm functions are available in `core::arch::wasm32` since [1], so we can use them while avoiding the possibly-recursive `intrinsics::*` calls (in practice none of those should always lower to libcalls on wasm, but that is up to LLVM). Since these require an unstable feature, they are still gated under `unstable-intrinsics`. [1]: rust-lang/stdarch#1677
These wasm functions are available in `core::arch::wasm32` since [1], so we can use them while avoiding the possibly-recursive `intrinsics::*` calls (in practice none of those should always lower to libcalls on wasm, but that is up to LLVM). Since these require an unstable feature, they are still gated under `unstable-intrinsics`. [1]: rust-lang/stdarch#1677
These wasm functions are available in `core::arch::wasm32` since [1], so we can use them while avoiding the possibly-recursive `intrinsics::*` calls (in practice none of those should always lower to libcalls on wasm, but that is up to LLVM). Since these require an unstable feature, they are still gated under `unstable-intrinsics`. [1]: rust-lang/stdarch#1677
Tracking issue: rust-lang/rust#133908
The recently added
wasm32v1-none
target comes withoutstd
. This has caused somef32
andf64
methods to not be available for this target:f32/f64::ceil()
f32/f64::floor()
f32/f64::trunc()
andf32/f64::fract()
f32/f64::round_ties_even()
f32/f64::sqrt()
However, all these methods are available in Wasm via instructions that are part of Wasm v1. This PR exposes these methods as platform specific intrinsics.
It should be noted that there is a tracking issue (rust-lang/rust#50145) for bringing
f32/f64::sqrt()
tocore
, which would make adding this instruction obsolete.I also made these functions insta-stable, is that alright? Should I make an ACP first? I'm also targetting v1.84, the release of the new
wasm32v1-none
target. Considering that the fork date is the 22nd, its unlikely this will make it in time.Cc @alexcrichton.