summaryrefslogtreecommitdiff
path: root/crates/types
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2025-04-23 20:54:03 +0200
committerGitHub <noreply@github.com>2025-04-23 20:54:03 +0200
commitc1a8cfad737cc79772b44a99088bcccd0ab6ee02 (patch)
treea6e56a08d2063612c3eb2afb0189a688af137f29 /crates/types
parent1252a8936eb2a69496efc849f3eb59e72b964920 (diff)
parent3664c8b79918ffad109ccec32336d38c299f1351 (diff)
Merge pull request #39 from explodingcamera/feat/simd
initial simd support
Diffstat (limited to 'crates/types')
-rw-r--r--crates/types/src/instructions.rs11
-rw-r--r--crates/types/src/lib.rs2
-rw-r--r--crates/types/src/value.rs8
3 files changed, 11 insertions, 10 deletions
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs
index 899be65..9db5ed5 100644
--- a/crates/types/src/instructions.rs
+++ b/crates/types/src/instructions.rs
@@ -4,7 +4,6 @@ use crate::{ConstIdx, DataAddr, ElemAddr, ExternAddr, MemAddr};
/// Represents a memory immediate in a WebAssembly memory instruction.
#[derive(Debug, Copy, Clone, PartialEq)]
#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))]
-
pub struct MemoryArg([u8; 12]);
impl MemoryArg {
@@ -36,6 +35,7 @@ pub enum ConstInstruction {
I64Const(i64),
F32Const(f32),
F64Const(f64),
+ V128Const(i128),
GlobalGet(GlobalAddr),
RefFunc(Option<FuncAddr>),
RefExtern(Option<ExternAddr>),
@@ -206,18 +206,17 @@ pub enum Instruction {
F32x4ExtractLane(u8), F32x4ReplaceLane(u8),
F64x2ExtractLane(u8), F64x2ReplaceLane(u8),
- V128Not, V128And, V128AndNot, V128Or, V128Xor, V128Bitselect, V128AnyTrue,
-
- I8x16Splat, I8x16Swizzle, I8x16Eq, I8x16Ne, I8x16LtS, I8x16LtU, I8x16GtS, I8x16GtU, I8x16LeS, I8x16LeU, I8x16GeS, I8x16GeU,
+ V128Not, V128And, V128AndNot, V128Or, V128Xor, V128Bitselect, V128AnyTrue, I8x16Swizzle,
+ I8x16Splat, I8x16Eq, I8x16Ne, I8x16LtS, I8x16LtU, I8x16GtS, I8x16GtU, I8x16LeS, I8x16LeU, I8x16GeS, I8x16GeU,
I16x8Splat, I16x8Eq, I16x8Ne, I16x8LtS, I16x8LtU, I16x8GtS, I16x8GtU, I16x8LeS, I16x8LeU, I16x8GeS, I16x8GeU,
I32x4Splat, I32x4Eq, I32x4Ne, I32x4LtS, I32x4LtU, I32x4GtS, I32x4GtU, I32x4LeS, I32x4LeU, I32x4GeS, I32x4GeU,
- I64x2Splat, I64x2Eq, I64x2Ne, I64x2LtS, I64x2GtS, I64x2LeS, I64x2GeS,
+ I64x2Splat, I64x2Eq, I64x2Ne, I64x2LtS, I64x2GtS, I64x2LeS, I64x2GeS,
F32x4Splat, F32x4Eq, F32x4Ne, F32x4Lt, F32x4Gt, F32x4Le, F32x4Ge,
F64x2Splat, F64x2Eq, F64x2Ne, F64x2Lt, F64x2Gt, F64x2Le, F64x2Ge,
I8x16Abs, I8x16Neg, I8x16AllTrue, I8x16Bitmask, I8x16Shl, I8x16ShrS, I8x16ShrU, I8x16Add, I8x16Sub, I8x16MinS, I8x16MinU, I8x16MaxS, I8x16MaxU,
I16x8Abs, I16x8Neg, I16x8AllTrue, I16x8Bitmask, I16x8Shl, I16x8ShrS, I16x8ShrU, I16x8Add, I16x8Sub, I16x8MinS, I16x8MinU, I16x8MaxS, I16x8MaxU,
- I32x4Abs, I32x4Neg, I32x4AllTrue, I32x4Bitmask, I32x4Shl, I32x4ShrS, I32x4ShrU, I32x4Add, I32x4Sub, I32x4MinS, I32x4MinU, I32x4MaxS, I32x4MaxU,
+ I32x4Abs, I32x4Neg, I32x4AllTrue, I32x4Bitmask, I32x4Shl, I32x4ShrS, I32x4ShrU, I32x4Add, I32x4Sub, I32x4MinS, I32x4MinU, I32x4MaxS, I32x4MaxU,
I64x2Abs, I64x2Neg, I64x2AllTrue, I64x2Bitmask, I64x2Shl, I64x2ShrS, I64x2ShrU, I64x2Add, I64x2Sub, I64x2Mul,
I8x16NarrowI16x8S, I8x16NarrowI16x8U, I8x16AddSatS, I8x16AddSatU, I8x16SubSatS, I8x16SubSatU, I8x16AvgrU,
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs
index d9f2234..470c631 100644
--- a/crates/types/src/lib.rs
+++ b/crates/types/src/lib.rs
@@ -259,7 +259,7 @@ pub struct WasmFunction {
#[derive(Debug, Clone, PartialEq, Default)]
#[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))]
pub struct WasmFunctionData {
- pub v128_constants: Box<[u128]>,
+ pub v128_constants: Box<[i128]>,
}
/// A WebAssembly Module Export
diff --git a/crates/types/src/value.rs b/crates/types/src/value.rs
index 01a31d5..a9498cc 100644
--- a/crates/types/src/value.rs
+++ b/crates/types/src/value.rs
@@ -17,7 +17,7 @@ pub enum WasmValue {
/// A 64-bit float.
F64(f64),
// /// A 128-bit vector
- V128(u128),
+ V128(i128),
RefExtern(ExternRef),
RefFunc(FuncRef),
@@ -112,6 +112,7 @@ impl WasmValue {
Self::I64(i) => ConstInstruction::I64Const(*i),
Self::F32(i) => ConstInstruction::F32Const(*i),
Self::F64(i) => ConstInstruction::F64Const(*i),
+ Self::V128(i) => ConstInstruction::V128Const(*i),
Self::RefFunc(i) => ConstInstruction::RefFunc(i.addr()),
_ => unimplemented!("no const_instr for {:?}", self),
}
@@ -137,6 +138,7 @@ impl WasmValue {
match (self, other) {
(Self::I32(a), Self::I32(b)) => a == b,
(Self::I64(a), Self::I64(b)) => a == b,
+ (Self::V128(a), Self::V128(b)) => a == b,
(Self::RefExtern(addr), Self::RefExtern(addr2)) => addr == addr2,
(Self::RefFunc(addr), Self::RefFunc(addr2)) => addr == addr2,
(Self::F32(a), Self::F32(b)) => {
@@ -190,7 +192,7 @@ impl WasmValue {
}
#[doc(hidden)]
- pub fn as_v128(&self) -> Option<u128> {
+ pub fn as_v128(&self) -> Option<i128> {
match self {
Self::V128(i) => Some(*i),
_ => None,
@@ -309,4 +311,4 @@ macro_rules! impl_conversion_for_wasmvalue {
}
}
-impl_conversion_for_wasmvalue! { i32 => I32, i64 => I64, f32 => F32, f64 => F64, u128 => V128, ExternRef => RefExtern, FuncRef => RefFunc }
+impl_conversion_for_wasmvalue! { i32 => I32, i64 => I64, f32 => F32, f64 => F64, i128 => V128, ExternRef => RefExtern, FuncRef => RefFunc }