Skip to content
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

wasm32: Add relaxed simd instructions #1393

Merged
merged 2 commits into from
Mar 19, 2023

Conversation

alexcrichton
Copy link
Member

This commit adds intrinsics to the wasm32 to support the relaxed SIMD proposal. These are added with the same naming conventions of existing simd-related intrinsics for wasm which is similar to the instruction name but matches sign in a few places.

This additionally updates Wasmtime to execute tests with support for the relaxed simd proposal. No release has been made yet so this uses the dev release, and I can make a PR in April when the support in Wasmtime has been released to an official release. The wasmprinter crate is also updated to understand these instruction opcodes as well.

Documentation has been added for all intrinsics, but tests have only been added for some of them so far. I hope to follow-up later with more tests.

@rustbot
Copy link
Collaborator

rustbot commented Mar 9, 2023

r? @Amanieu

(rustbot has picked a reviewer for you, use r? to override)

This commit adds intrinsics to the `wasm32` to support the [relaxed SIMD
proposal][proposal]. These are added with the same naming conventions of
existing simd-related intrinsics for wasm which is similar to the
instruction name but matches sign in a few places.

This additionally updates Wasmtime to execute tests with support for the
relaxed simd proposal. No release has been made yet so this uses the
`dev` release, and I can make a PR in April when the support in Wasmtime
has been released to an official release. The `wasmprinter` crate is
also updated to understand these instruction opcodes as well.

Documentation has been added for all intrinsics, but tests have only
been added for some of them so far. I hope to follow-up later with more
tests.

[proposal]: https://github.com/WebAssembly/relaxed-simd
#[cfg_attr(test, assert_instr(f64x2.relaxed_madd))]
#[target_feature(enable = "relaxed-simd")]
#[doc(alias("f64x2.relaxed_madd"))]
pub fn f64x2_relaxed_madd(a: v128, b: v128, c: v128) -> v128 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std calls this mul_add, would it make sense to adopt the same naming convention here? (If not, maybe as an alias?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already deviate from the name of the instructions themselves so I think it's reasonable to have a different name here, especially because the doc aliases cover folks searching for the instruction itself.

Looking for prior inspiration, it appears that clang doesn't actually have support for relaxed simd instructions in the public wasm_simd128.h header. There is a __builtin_wasm_relaxed_madd_f32x4 intrinsic but I believe that's intended to be clang-specific and not used as a public interface. In that sense no inspiration to draw from.

I'd be a bit worried about the mouthful of f64x2_relaxed_neg_mul_add but I don't mind changing these to that. Also happy to defer to a later date and track this as part of a tracking issue.

@alexcrichton
Copy link
Member Author

ping @Amanieu, would you have a chance to look at this? I'd prefer to defer the naming question to a tracking issue for stabilization myself, but I can of course rename here-and-now too.

@Amanieu
Copy link
Member

Amanieu commented Mar 19, 2023

LGTM. I'm a bit uncomfortable depending on a dev version of wasmtime in CI, but it's fine for now as long as this is updated when a new version of wasmtime is released.

@Amanieu Amanieu merged commit ac277c5 into rust-lang:master Mar 19, 2023
@alexcrichton alexcrichton deleted the wasm-relaxed-simd branch April 20, 2023 15:16
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 11, 2024
tgross35 added a commit to tgross35/rust that referenced this pull request Jul 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 5, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants