diff --git a/lib/clif-backend/src/module.rs b/lib/clif-backend/src/module.rs index 14adb1547..91e14bf7c 100644 --- a/lib/clif-backend/src/module.rs +++ b/lib/clif-backend/src/module.rs @@ -107,6 +107,7 @@ impl From> for Type { ir::types::I64 => Type::I64, ir::types::F32 => Type::F32, ir::types::F64 => Type::F64, + ir::types::I32X4 => Type::V128, _ => panic!("unsupported wasm type"), } } @@ -119,6 +120,7 @@ impl From> for ir::Type { Type::I64 => ir::types::I64, Type::F32 => ir::types::F32, Type::F64 => ir::types::F64, + Type::V128 => ir::types::I32X4, } } } @@ -130,6 +132,7 @@ impl From> for ir::AbiParam { Type::I64 => ir::AbiParam::new(ir::types::I64), Type::F32 => ir::AbiParam::new(ir::types::F32), Type::F64 => ir::AbiParam::new(ir::types::F64), + Type::V128 => ir::AbiParam::new(ir::types::I32X4), } } } diff --git a/lib/clif-backend/src/trampoline.rs b/lib/clif-backend/src/trampoline.rs index 09ee4cf74..f75ef5ad5 100644 --- a/lib/clif-backend/src/trampoline.rs +++ b/lib/clif-backend/src/trampoline.rs @@ -204,6 +204,7 @@ fn wasm_ty_to_clif(ty: Type) -> ir::types::Type { Type::I64 => ir::types::I64, Type::F32 => ir::types::F32, Type::F64 => ir::types::F64, + Type::V128 => ir::types::I32X4, } } diff --git a/lib/runtime-core/src/global.rs b/lib/runtime-core/src/global.rs index ac485cc4f..16a75d6a7 100644 --- a/lib/runtime-core/src/global.rs +++ b/lib/runtime-core/src/global.rs @@ -50,6 +50,7 @@ impl Global { Value::I64(x) => x as u64, Value::F32(x) => x.to_bits() as u64, Value::F64(x) => x.to_bits(), + Value::V128(_) => unimplemented!(), }, }; @@ -79,6 +80,7 @@ impl Global { Value::I64(x) => x as u64, Value::F32(x) => x.to_bits() as u64, Value::F64(x) => x.to_bits(), + Value::V128(_) => unimplemented!(), }, }; *self.storage.borrow_mut() = local_global; @@ -99,6 +101,7 @@ impl Global { Type::I64 => Value::I64(data as i64), Type::F32 => Value::F32(f32::from_bits(data as u32)), Type::F64 => Value::F64(f64::from_bits(data)), + Type::V128 => unimplemented!(), } } diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index cf09b48e7..d2a6c04e4 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -551,6 +551,7 @@ fn call_func_with_index( Value::I64(i) => *i as u64, Value::F32(f) => f.to_bits() as u64, Value::F64(f) => f.to_bits(), + Value::V128(_) => unimplemented!(), }) .collect(); @@ -595,6 +596,7 @@ fn call_func_with_index( Type::I64 => Value::I64(raw as i64), Type::F32 => Value::F32(f32::from_bits(raw as u32)), Type::F64 => Value::F64(f64::from_bits(raw)), + Type::V128 => unimplemented!(), }; match signature.returns() { diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index 9f911f036..0f365ac2e 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -380,12 +380,7 @@ pub fn wp_type_to_type(ty: WpType) -> Result { WpType::I64 => Type::I64, WpType::F32 => Type::F32, WpType::F64 => Type::F64, - WpType::V128 => { - return Err(BinaryReaderError { - message: "the wasmer llvm backend does not yet support the simd extension", - offset: -1isize as usize, - }); - } + WpType::V128 => Type::V128, _ => panic!("broken invariant, invalid type"), }) } @@ -396,6 +391,7 @@ pub fn type_to_wp_type(ty: Type) -> WpType { Type::I64 => WpType::I64, Type::F32 => WpType::F32, Type::F64 => WpType::F64, + Type::V128 => WpType::V128, } } diff --git a/lib/runtime-core/src/types.rs b/lib/runtime-core/src/types.rs index 0c8f08d1a..ac3df0343 100644 --- a/lib/runtime-core/src/types.rs +++ b/lib/runtime-core/src/types.rs @@ -12,6 +12,8 @@ pub enum Type { F32, /// The `f64` type. F64, + /// The `v128` type. + V128, } impl std::fmt::Display for Type { @@ -34,6 +36,8 @@ pub enum Value { F32(f32), /// The `f64` type. F64(f64), + /// The `v128` type. + V128(u128), } impl Value { @@ -43,6 +47,7 @@ impl Value { Value::I64(_) => Type::I64, Value::F32(_) => Type::F32, Value::F64(_) => Type::F64, + Value::V128(_) => Type::V128, } } @@ -52,6 +57,7 @@ impl Value { Value::I64(x) => x as u64, Value::F32(x) => f32::to_bits(x) as u64, Value::F64(x) => f64::to_bits(x), + Value::V128(_) => unimplemented!(), } } } @@ -80,6 +86,12 @@ impl From for Value { } } +impl From for Value { + fn from(v: u128) -> Self { + Value::V128(v) + } +} + pub unsafe trait NativeWasmType: Copy + Into where Self: Sized,