diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2025-03-01 19:49:41 +0100 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2025-03-01 19:49:41 +0100 |
| commit | afc76e44457975e3d20b3a490c5029dec6f4983a (patch) | |
| tree | 9a16dd224ac3278f1f291fcad3675223c096071c /crates/types | |
| parent | 741a3d6e94970f097d0cd19cbe9f9a7266b67fb4 (diff) | |
feat: add most basic simd instructions
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types')
| -rw-r--r-- | crates/types/src/instructions.rs | 1 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 2 | ||||
| -rw-r--r-- | crates/types/src/value.rs | 8 |
3 files changed, 7 insertions, 4 deletions
diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 24116e8..593af2f 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -36,6 +36,7 @@ pub enum ConstInstruction { I64Const(i64), F32Const(f32), F64Const(f64), + V128Const(i128), GlobalGet(GlobalAddr), RefFunc(Option<FuncAddr>), RefExtern(Option<ExternAddr>), 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 } |
