Remove some dead code in the cranelift-wasm crate (#5290)

* Remove some dead code in the cranelift-wasm crate

* Remove some more dead code
This commit is contained in:
Alex Crichton
2022-11-17 10:28:11 -06:00
committed by GitHub
parent 56daa8a199
commit 9bf2a8e663
2 changed files with 1 additions and 83 deletions

View File

@@ -9,50 +9,6 @@ use cranelift_frontend::FunctionBuilder;
use serde::{Deserialize, Serialize};
use wasmparser::{FuncValidator, WasmFuncType, WasmModuleResources};
/// WebAssembly table element. Can be a function or a scalar type.
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub enum TableElementType {
/// A scalar type.
Val(ir::Type),
/// A function.
Func,
}
/// Helper function translating wasmparser types to Cranelift types when possible.
pub fn type_to_type<PE: TargetEnvironment + ?Sized>(
ty: wasmparser::ValType,
environ: &PE,
) -> WasmResult<ir::Type> {
match ty {
wasmparser::ValType::I32 => Ok(ir::types::I32),
wasmparser::ValType::I64 => Ok(ir::types::I64),
wasmparser::ValType::F32 => Ok(ir::types::F32),
wasmparser::ValType::F64 => Ok(ir::types::F64),
wasmparser::ValType::V128 => Ok(ir::types::I8X16),
wasmparser::ValType::ExternRef | wasmparser::ValType::FuncRef => {
Ok(environ.reference_type(ty.try_into()?))
}
}
}
/// Helper function translating wasmparser possible table types to Cranelift types when possible,
/// or None for Func tables.
pub fn tabletype_to_type<PE: TargetEnvironment + ?Sized>(
ty: wasmparser::ValType,
environ: &PE,
) -> WasmResult<Option<ir::Type>> {
match ty {
wasmparser::ValType::I32 => Ok(Some(ir::types::I32)),
wasmparser::ValType::I64 => Ok(Some(ir::types::I64)),
wasmparser::ValType::F32 => Ok(Some(ir::types::F32)),
wasmparser::ValType::F64 => Ok(Some(ir::types::F64)),
wasmparser::ValType::V128 => Ok(Some(ir::types::I8X16)),
wasmparser::ValType::ExternRef => Ok(Some(environ.reference_type(ty.try_into()?))),
wasmparser::ValType::FuncRef => Ok(None),
}
}
/// Get the parameter and result types for the given Wasm blocktype.
pub fn blocktype_params_results<'a, T>(
validator: &'a FuncValidator<T>,