Make cranelift-wasm's type_to_type easier to optimize.

This commit is contained in:
Dan Gohman
2018-10-26 11:24:43 -07:00
parent 87e683b1f4
commit bf569b70dc

View File

@@ -92,13 +92,13 @@ pub struct Memory {
/// Helper function translating wasmparser types to Cranelift types when possible.
pub fn type_to_type(ty: wasmparser::Type) -> Result<ir::Type, ()> {
match ty {
wasmparser::Type::I32 => Ok(ir::types::I32),
wasmparser::Type::I64 => Ok(ir::types::I64),
wasmparser::Type::F32 => Ok(ir::types::F32),
wasmparser::Type::F64 => Ok(ir::types::F64),
_ => Err(()),
}
Ok(match ty {
wasmparser::Type::I32 => ir::types::I32,
wasmparser::Type::I64 => ir::types::I64,
wasmparser::Type::F32 => ir::types::F32,
wasmparser::Type::F64 => ir::types::F64,
_ => return Err(()),
})
}
/// Turns a `wasmparser` `f32` into a `Cranelift` one.