Add V128 type
This commit is contained in:
@@ -32,6 +32,7 @@ fn into_valtype(ty: &wasmparser::Type) -> ValType {
|
||||
I64 => ValType::I64,
|
||||
F32 => ValType::F32,
|
||||
F64 => ValType::F64,
|
||||
V128 => ValType::V128,
|
||||
AnyFunc => ValType::FuncRef,
|
||||
AnyRef => ValType::AnyRef,
|
||||
_ => unimplemented!("types in into_valtype"),
|
||||
|
||||
@@ -45,6 +45,7 @@ pub enum ValType {
|
||||
I64,
|
||||
F32,
|
||||
F64,
|
||||
V128,
|
||||
AnyRef, /* = 128 */
|
||||
FuncRef,
|
||||
}
|
||||
@@ -70,6 +71,7 @@ impl ValType {
|
||||
ValType::I64 => ir::types::I64,
|
||||
ValType::F32 => ir::types::F32,
|
||||
ValType::F64 => ir::types::F64,
|
||||
ValType::V128 => ir::types::I8X16,
|
||||
_ => unimplemented!("get_cranelift_type other"),
|
||||
}
|
||||
}
|
||||
@@ -80,6 +82,7 @@ impl ValType {
|
||||
ir::types::I64 => ValType::I64,
|
||||
ir::types::F32 => ValType::F32,
|
||||
ir::types::F64 => ValType::F64,
|
||||
ir::types::I8X16 => ValType::V128,
|
||||
_ => unimplemented!("from_cranelift_type other"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ pub enum RuntimeValue {
|
||||
F32(u32),
|
||||
/// A runtime value with type f64.
|
||||
F64(u64),
|
||||
/// A runtime value with type v128
|
||||
V128([u8; 16]),
|
||||
}
|
||||
|
||||
impl RuntimeValue {
|
||||
@@ -30,6 +32,7 @@ impl RuntimeValue {
|
||||
RuntimeValue::I64(_) => ir::types::I64,
|
||||
RuntimeValue::F32(_) => ir::types::F32,
|
||||
RuntimeValue::F64(_) => ir::types::F64,
|
||||
RuntimeValue::V128(_) => ir::types::I8X16,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +86,7 @@ impl fmt::Display for RuntimeValue {
|
||||
RuntimeValue::I64(x) => write!(f, "{}: i64", x),
|
||||
RuntimeValue::F32(x) => write!(f, "{}: f32", x),
|
||||
RuntimeValue::F64(x) => write!(f, "{}: f64", x),
|
||||
RuntimeValue::V128(x) => write!(f, "{:?}: v128", x.to_vec()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,6 +178,7 @@ pub fn invoke(
|
||||
RuntimeValue::I64(x) => ptr::write(ptr as *mut i64, *x),
|
||||
RuntimeValue::F32(x) => ptr::write(ptr as *mut u32, *x),
|
||||
RuntimeValue::F64(x) => ptr::write(ptr as *mut u64, *x),
|
||||
RuntimeValue::V128(x) => ptr::write(ptr as *mut [u8; 16], *x),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,6 +215,7 @@ pub fn invoke(
|
||||
ir::types::I64 => RuntimeValue::I64(ptr::read(ptr as *const i64)),
|
||||
ir::types::F32 => RuntimeValue::F32(ptr::read(ptr as *const u32)),
|
||||
ir::types::F64 => RuntimeValue::F64(ptr::read(ptr as *const u64)),
|
||||
ir::types::I8X16 => RuntimeValue::V128(ptr::read(ptr as *const [u8; 16])),
|
||||
other => panic!("unsupported value type {:?}", other),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -252,8 +252,8 @@ mod test_vmtable_definition {
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[repr(C, align(8))]
|
||||
pub struct VMGlobalDefinition {
|
||||
storage: [u8; 8],
|
||||
// If more elements are added here, remember to add offset_of tests below!
|
||||
storage: [u8; 8], // TODO this may need to be 16
|
||||
// If more elements are added here, remember to add offset_of tests below!
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -15,7 +15,7 @@ fn runtime_value(v: Value) -> RuntimeValue {
|
||||
Value::I64(x) => RuntimeValue::I64(x),
|
||||
Value::F32(x) => RuntimeValue::F32(x.to_bits()),
|
||||
Value::F64(x) => RuntimeValue::F64(x.to_bits()),
|
||||
Value::V128(_) => unimplemented!("SIMD"),
|
||||
Value::V128(x) => RuntimeValue::V128(x.to_le_bytes()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +374,15 @@ impl WastContext {
|
||||
});
|
||||
}
|
||||
}
|
||||
RuntimeValue::V128(_) => {
|
||||
return Err(WastFileError {
|
||||
filename: filename.to_string(),
|
||||
line,
|
||||
error: WastError::Type(format!(
|
||||
"unexpected vector type in NaN test"
|
||||
)),
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -426,6 +435,15 @@ impl WastContext {
|
||||
});
|
||||
}
|
||||
}
|
||||
RuntimeValue::V128(_) => {
|
||||
return Err(WastFileError {
|
||||
filename: filename.to_string(),
|
||||
line,
|
||||
error: WastError::Type(format!(
|
||||
"unexpected vector type in NaN test",
|
||||
)),
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user