Add V128 to wasmer runtime. Unimplemented in clif-backend. Other backends don't build.

This commit is contained in:
Nick Lewycky 2019-07-02 14:55:10 -07:00
parent 0a1bdd449e
commit df5c12cbe1
6 changed files with 23 additions and 6 deletions

View File

@ -107,6 +107,7 @@ impl From<Converter<ir::Type>> for Type {
ir::types::I64 => Type::I64, ir::types::I64 => Type::I64,
ir::types::F32 => Type::F32, ir::types::F32 => Type::F32,
ir::types::F64 => Type::F64, ir::types::F64 => Type::F64,
ir::types::I32X4 => Type::V128,
_ => panic!("unsupported wasm type"), _ => panic!("unsupported wasm type"),
} }
} }
@ -119,6 +120,7 @@ impl From<Converter<Type>> for ir::Type {
Type::I64 => ir::types::I64, Type::I64 => ir::types::I64,
Type::F32 => ir::types::F32, Type::F32 => ir::types::F32,
Type::F64 => ir::types::F64, Type::F64 => ir::types::F64,
Type::V128 => ir::types::I32X4,
} }
} }
} }
@ -130,6 +132,7 @@ impl From<Converter<Type>> for ir::AbiParam {
Type::I64 => ir::AbiParam::new(ir::types::I64), Type::I64 => ir::AbiParam::new(ir::types::I64),
Type::F32 => ir::AbiParam::new(ir::types::F32), Type::F32 => ir::AbiParam::new(ir::types::F32),
Type::F64 => ir::AbiParam::new(ir::types::F64), Type::F64 => ir::AbiParam::new(ir::types::F64),
Type::V128 => ir::AbiParam::new(ir::types::I32X4),
} }
} }
} }

View File

@ -204,6 +204,7 @@ fn wasm_ty_to_clif(ty: Type) -> ir::types::Type {
Type::I64 => ir::types::I64, Type::I64 => ir::types::I64,
Type::F32 => ir::types::F32, Type::F32 => ir::types::F32,
Type::F64 => ir::types::F64, Type::F64 => ir::types::F64,
Type::V128 => ir::types::I32X4,
} }
} }

View File

@ -50,6 +50,7 @@ impl Global {
Value::I64(x) => x as u64, Value::I64(x) => x as u64,
Value::F32(x) => x.to_bits() as u64, Value::F32(x) => x.to_bits() as u64,
Value::F64(x) => x.to_bits(), Value::F64(x) => x.to_bits(),
Value::V128(_) => unimplemented!(),
}, },
}; };
@ -79,6 +80,7 @@ impl Global {
Value::I64(x) => x as u64, Value::I64(x) => x as u64,
Value::F32(x) => x.to_bits() as u64, Value::F32(x) => x.to_bits() as u64,
Value::F64(x) => x.to_bits(), Value::F64(x) => x.to_bits(),
Value::V128(_) => unimplemented!(),
}, },
}; };
*self.storage.borrow_mut() = local_global; *self.storage.borrow_mut() = local_global;
@ -99,6 +101,7 @@ impl Global {
Type::I64 => Value::I64(data as i64), Type::I64 => Value::I64(data as i64),
Type::F32 => Value::F32(f32::from_bits(data as u32)), Type::F32 => Value::F32(f32::from_bits(data as u32)),
Type::F64 => Value::F64(f64::from_bits(data)), Type::F64 => Value::F64(f64::from_bits(data)),
Type::V128 => unimplemented!(),
} }
} }

View File

@ -551,6 +551,7 @@ fn call_func_with_index(
Value::I64(i) => *i as u64, Value::I64(i) => *i as u64,
Value::F32(f) => f.to_bits() as u64, Value::F32(f) => f.to_bits() as u64,
Value::F64(f) => f.to_bits(), Value::F64(f) => f.to_bits(),
Value::V128(_) => unimplemented!(),
}) })
.collect(); .collect();
@ -595,6 +596,7 @@ fn call_func_with_index(
Type::I64 => Value::I64(raw as i64), Type::I64 => Value::I64(raw as i64),
Type::F32 => Value::F32(f32::from_bits(raw as u32)), Type::F32 => Value::F32(f32::from_bits(raw as u32)),
Type::F64 => Value::F64(f64::from_bits(raw)), Type::F64 => Value::F64(f64::from_bits(raw)),
Type::V128 => unimplemented!(),
}; };
match signature.returns() { match signature.returns() {

View File

@ -380,12 +380,7 @@ pub fn wp_type_to_type(ty: WpType) -> Result<Type, BinaryReaderError> {
WpType::I64 => Type::I64, WpType::I64 => Type::I64,
WpType::F32 => Type::F32, WpType::F32 => Type::F32,
WpType::F64 => Type::F64, WpType::F64 => Type::F64,
WpType::V128 => { WpType::V128 => Type::V128,
return Err(BinaryReaderError {
message: "the wasmer llvm backend does not yet support the simd extension",
offset: -1isize as usize,
});
}
_ => panic!("broken invariant, invalid type"), _ => panic!("broken invariant, invalid type"),
}) })
} }
@ -396,6 +391,7 @@ pub fn type_to_wp_type(ty: Type) -> WpType {
Type::I64 => WpType::I64, Type::I64 => WpType::I64,
Type::F32 => WpType::F32, Type::F32 => WpType::F32,
Type::F64 => WpType::F64, Type::F64 => WpType::F64,
Type::V128 => WpType::V128,
} }
} }

View File

@ -12,6 +12,8 @@ pub enum Type {
F32, F32,
/// The `f64` type. /// The `f64` type.
F64, F64,
/// The `v128` type.
V128,
} }
impl std::fmt::Display for Type { impl std::fmt::Display for Type {
@ -34,6 +36,8 @@ pub enum Value {
F32(f32), F32(f32),
/// The `f64` type. /// The `f64` type.
F64(f64), F64(f64),
/// The `v128` type.
V128(u128),
} }
impl Value { impl Value {
@ -43,6 +47,7 @@ impl Value {
Value::I64(_) => Type::I64, Value::I64(_) => Type::I64,
Value::F32(_) => Type::F32, Value::F32(_) => Type::F32,
Value::F64(_) => Type::F64, Value::F64(_) => Type::F64,
Value::V128(_) => Type::V128,
} }
} }
@ -52,6 +57,7 @@ impl Value {
Value::I64(x) => x as u64, Value::I64(x) => x as u64,
Value::F32(x) => f32::to_bits(x) as u64, Value::F32(x) => f32::to_bits(x) as u64,
Value::F64(x) => f64::to_bits(x), Value::F64(x) => f64::to_bits(x),
Value::V128(_) => unimplemented!(),
} }
} }
} }
@ -80,6 +86,12 @@ impl From<f64> for Value {
} }
} }
impl From<u128> for Value {
fn from(v: u128) -> Self {
Value::V128(v)
}
}
pub unsafe trait NativeWasmType: Copy + Into<Value> pub unsafe trait NativeWasmType: Copy + Into<Value>
where where
Self: Sized, Self: Sized,