Skip to content

Commit

Permalink
add wasm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Apr 4, 2021
1 parent 15babf5 commit 1e8e134
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
4 changes: 3 additions & 1 deletion crates/core_arch/src/core_arch_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ others at:
* [`powerpc64`]
* [`nvptx`]
* [`wasm32`]
* [`wasm64`]

[`x86`]: x86/index.html
[`x86_64`]: x86_64/index.html
Expand All @@ -201,7 +202,8 @@ others at:
[`powerpc`]: powerpc/index.html
[`powerpc64`]: powerpc64/index.html
[`nvptx`]: nvptx/index.html
[`wasm32`]: wasm32/index.html
[`wasm32`]: wasm/index.html
[`wasm64`]: wasm/index.html

# Examples

Expand Down
2 changes: 1 addition & 1 deletion crates/core_arch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
extended_key_value_attributes
)]
#![cfg_attr(test, feature(test, abi_vectorcall))]
#![cfg_attr(all(test, target_arch = "wasm32"), feature(wasm_simd))]
#![cfg_attr(all(test, wasm), feature(wasm_simd))]
#![deny(clippy::missing_inline_in_public_items)]
#![allow(
clippy::inline_always,
Expand Down
33 changes: 22 additions & 11 deletions crates/core_arch/src/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ pub mod arch {

/// Platform-specific intrinsics for the `wasm32` platform.
///
/// See the [module documentation](../index.html) for more details.
#[cfg(any(target_arch = "wasm32", doc))]
#[doc(cfg(target_arch = "wasm32"))]
#[stable(feature = "simd_wasm32", since = "1.33.0")]
pub mod wasm32 {
#[stable(feature = "simd_wasm32", since = "1.33.0")]
pub use crate::core_arch::wasm::*;
}

/// Platform-specific intrinsics for `wasm32` and `wasm64` platforms.
///
/// This module provides intrinsics specific to the WebAssembly
/// architecture. Here you'll find intrinsics specific to WebAssembly that
/// aren't otherwise surfaced somewhere in a cross-platform abstraction of
Expand Down Expand Up @@ -120,10 +131,10 @@ pub mod arch {
/// example. You'd write a function such as:
///
/// ```rust,ignore
/// #[cfg(target_arch = "wasm32")]
/// #[cfg(wasm)]
/// #[target_feature(enable = "simd128")]
/// unsafe fn uses_simd() {
/// use std::arch::wasm32::*;
/// use std::arch::wasm::*;
/// // ...
/// }
/// ```
Expand Down Expand Up @@ -163,12 +174,12 @@ pub mod arch {
/// generated in your program. This means to generate a binary without SIMD
/// you'll need to avoid both options above plus calling into any intrinsics
/// in this module.
#[cfg(any(target_arch = "wasm32", doc))]
#[doc(cfg(target_arch = "wasm32"))]
#[stable(feature = "simd_wasm32", since = "1.33.0")]
pub mod wasm32 {
#[stable(feature = "simd_wasm32", since = "1.33.0")]
pub use crate::core_arch::wasm32::*;
#[cfg(any(wasm, doc))]
#[doc(cfg(wasm))]
#[stable(feature = "", since = "0.0.0")]
pub mod wasm {
#[stable(feature = "", since = "0.0.0")]
pub use crate::core_arch::wasm::*;
}

/// Platform-specific intrinsics for the `mips` platform.
Expand Down Expand Up @@ -238,9 +249,9 @@ mod aarch64;
#[doc(cfg(any(target_arch = "arm", target_arch = "aarch64")))]
mod arm;

#[cfg(any(target_arch = "wasm32", doc))]
#[doc(cfg(target_arch = "wasm32"))]
mod wasm32;
#[cfg(any(wasm, doc))]
#[doc(cfg(wasm))]
mod wasm;

#[cfg(any(target_arch = "mips", target_arch = "mips64", doc))]
#[doc(cfg(any(target_arch = "mips", target_arch = "mips64")))]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
use stdarch_test::assert_instr;

extern "C" {
#[link_name = "llvm.wasm.memory.grow.i32"]
fn llvm_memory_grow(mem: u32, pages: i32) -> i32;
#[link_name = "llvm.wasm.memory.size.i32"]
fn llvm_memory_size(mem: u32) -> i32;
#[link_name = "llvm.wasm.memory.grow"]
fn llvm_memory_grow(mem: u32, pages: isize) -> isize;
#[link_name = "llvm.wasm.memory.size"]
fn llvm_memory_size(mem: u32) -> isize;
}

/// Corresponding intrinsic to wasm's [`memory.size` instruction][instr]
Expand Down Expand Up @@ -51,6 +51,6 @@ pub fn memory_size<const MEM: u32>() -> usize {
pub fn memory_grow<const MEM: u32>(delta: usize) -> usize {
unsafe {
static_assert!(MEM: u32 where MEM == 0);
llvm_memory_grow(MEM, delta as i32) as isize as usize
llvm_memory_grow(MEM, delta as isize) as usize
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! WASM32 intrinsics
//! WebAssembly intrinsics

#[cfg(test)]
use stdarch_test::assert_instr;
Expand Down
File renamed without changes.

0 comments on commit 1e8e134

Please sign in to comment.