Skip to content

Commit 1181fd4

Browse files
authored
Add a rudimentary wasm64 module with intrinsics (#1240)
1 parent 299b5e2 commit 1181fd4

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

crates/core_arch/src/mod.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ pub mod arch {
162162
pub use crate::core_arch::wasm32::*;
163163
}
164164

165+
/// Platform-specific intrinsics for the `wasm64` platform.
166+
///
167+
/// See the [module documentation](../index.html) for more details.
168+
#[cfg(any(target_arch = "wasm64", doc))]
169+
#[doc(cfg(target_arch = "wasm64"))]
170+
#[stable(feature = "simd_wasm32", since = "1.33.0")]
171+
pub mod wasm64 {
172+
#[stable(feature = "simd_wasm32", since = "1.33.0")]
173+
pub use crate::core_arch::wasm32::*;
174+
}
175+
165176
/// Platform-specific intrinsics for the `mips` platform.
166177
///
167178
/// See the [module documentation](../index.html) for more details.
@@ -229,8 +240,8 @@ mod aarch64;
229240
#[doc(cfg(any(target_arch = "arm")))]
230241
mod arm;
231242

232-
#[cfg(any(target_arch = "wasm32", doc))]
233-
#[doc(cfg(target_arch = "wasm32"))]
243+
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64", doc))]
244+
#[doc(cfg(any(target_arch = "wasm32", target_arch = "wasm64")))]
234245
mod wasm32;
235246

236247
#[cfg(any(target_arch = "mips", target_arch = "mips64", doc))]

crates/core_arch/src/wasm32/memory.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
use stdarch_test::assert_instr;
33

44
extern "C" {
5-
#[link_name = "llvm.wasm.memory.grow.i32"]
6-
fn llvm_memory_grow(mem: u32, pages: i32) -> i32;
7-
#[link_name = "llvm.wasm.memory.size.i32"]
8-
fn llvm_memory_size(mem: u32) -> i32;
5+
#[link_name = "llvm.wasm.memory.grow"]
6+
fn llvm_memory_grow(mem: u32, pages: usize) -> usize;
7+
#[link_name = "llvm.wasm.memory.size"]
8+
fn llvm_memory_size(mem: u32) -> usize;
99
}
1010

1111
/// Corresponding intrinsic to wasm's [`memory.size` instruction][instr]
@@ -27,7 +27,7 @@ extern "C" {
2727
#[doc(alias("memory.size"))]
2828
pub fn memory_size<const MEM: u32>() -> usize {
2929
static_assert!(MEM: u32 where MEM == 0);
30-
unsafe { llvm_memory_size(MEM) as usize }
30+
unsafe { llvm_memory_size(MEM) }
3131
}
3232

3333
/// Corresponding intrinsic to wasm's [`memory.grow` instruction][instr]
@@ -53,6 +53,6 @@ pub fn memory_size<const MEM: u32>() -> usize {
5353
pub fn memory_grow<const MEM: u32>(delta: usize) -> usize {
5454
unsafe {
5555
static_assert!(MEM: u32 where MEM == 0);
56-
llvm_memory_grow(MEM, delta as i32) as isize as usize
56+
llvm_memory_grow(MEM, delta)
5757
}
5858
}

0 commit comments

Comments
 (0)