Export wptype_to_type from wasmer_compiler.

Also fix up its error message when it fails.

Use it in compiler-llvm and remove one of compiler-llvm's copies of this function.
This commit is contained in:
Nick Lewycky
2020-06-02 11:06:15 -07:00
parent fa3242ce11
commit 04f2db1b82
4 changed files with 7 additions and 23 deletions

View File

@ -32,30 +32,13 @@ use wasm_common::{
FunctionIndex, FunctionType, GlobalIndex, LocalFunctionIndex, MemoryIndex, SignatureIndex,
TableIndex, Type,
};
use wasmer_compiler::wasmparser::{self, BinaryReader, MemoryImmediate, Operator};
use wasmer_compiler::wasmparser::{BinaryReader, MemoryImmediate, Operator};
use wasmer_compiler::{
to_wasm_error, wasm_unsupported, CompileError, CompiledFunction, CustomSections,
FunctionBodyData, RelocationTarget, WasmResult,
to_wasm_error, wptype_to_type, CompileError, CompiledFunction, CustomSections,
FunctionBodyData, RelocationTarget,
};
use wasmer_runtime::{MemoryPlan, ModuleInfo, TablePlan};
// TODO
fn wptype_to_type(ty: wasmparser::Type) -> WasmResult<Type> {
match ty {
wasmparser::Type::I32 => Ok(Type::I32),
wasmparser::Type::I64 => Ok(Type::I64),
wasmparser::Type::F32 => Ok(Type::F32),
wasmparser::Type::F64 => Ok(Type::F64),
wasmparser::Type::V128 => Ok(Type::V128),
wasmparser::Type::AnyRef => Ok(Type::AnyRef),
wasmparser::Type::AnyFunc => Ok(Type::FuncRef),
ty => Err(wasm_unsupported!(
"wptype_to_irtype: parser wasm type {:?}",
ty
)),
}
}
// TODO: move this into inkwell.
fn const_zero(ty: BasicTypeEnum) -> BasicValueEnum {
match ty {