diff --git a/lib/clif-backend/src/code.rs b/lib/clif-backend/src/code.rs new file mode 100644 index 000000000..28257621e --- /dev/null +++ b/lib/clif-backend/src/code.rs @@ -0,0 +1,91 @@ +use crate::signal::Caller; +use wasmer_runtime_core::{ + backend::{Backend, CacheGen, Token}, + cache::{Artifact, Error as CacheError}, + codegen::*, + module::{ModuleInfo, ModuleInner}, + structures::Map, + types::{FuncIndex, FuncSig, SigIndex}, +}; +use wasmparser::Type as WpType; + +pub struct CraneliftModuleCodeGenerator {} + +impl ModuleCodeGenerator + for CraneliftModuleCodeGenerator +{ + fn new() -> Self { + unimplemented!() + } + + fn backend_id() -> Backend { + unimplemented!() + } + + fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> { + unimplemented!() + } + + fn next_function(&mut self) -> Result<&mut CraneliftFunctionCodeGenerator, CodegenError> { + unimplemented!() + } + + fn finalize( + self, + _module_info: &ModuleInfo, + ) -> Result<(Caller, Box), CodegenError> { + unimplemented!() + } + + fn feed_signatures(&mut self, _signatures: Map) -> Result<(), CodegenError> { + unimplemented!() + } + + fn feed_function_signatures( + &mut self, + _assoc: Map, + ) -> Result<(), CodegenError> { + unimplemented!() + } + + fn feed_import_function(&mut self) -> Result<(), CodegenError> { + unimplemented!() + } + + unsafe fn from_cache(_cache: Artifact, _: Token) -> Result { + unimplemented!() + } +} + +pub struct CraneliftFunctionCodeGenerator {} + +impl FunctionCodeGenerator for CraneliftFunctionCodeGenerator { + fn feed_return(&mut self, _ty: WpType) -> Result<(), CodegenError> { + unimplemented!() + } + + fn feed_param(&mut self, _ty: WpType) -> Result<(), CodegenError> { + unimplemented!() + } + + fn feed_local(&mut self, _ty: WpType, _n: usize) -> Result<(), CodegenError> { + unimplemented!() + } + + fn begin_body(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> { + unimplemented!() + } + + fn feed_event(&mut self, _op: Event, _module_info: &ModuleInfo) -> Result<(), CodegenError> { + unimplemented!() + } + + fn finalize(&mut self) -> Result<(), CodegenError> { + unimplemented!() + } +} + +#[derive(Debug)] +pub struct CodegenError { + pub message: String, +} diff --git a/lib/clif-backend/src/lib.rs b/lib/clif-backend/src/lib.rs index 639249c34..a8cd0f448 100644 --- a/lib/clif-backend/src/lib.rs +++ b/lib/clif-backend/src/lib.rs @@ -1,6 +1,7 @@ #![deny(unused_imports, unused_variables)] mod cache; +mod code; mod func_env; mod libcalls; mod module; @@ -31,15 +32,15 @@ extern crate serde; use wasmparser::{self, WasmDecoder}; -pub struct CraneliftCompiler {} +pub struct OldCraneliftCompiler {} -impl CraneliftCompiler { +impl OldCraneliftCompiler { pub fn new() -> Self { Self {} } } -impl Compiler for CraneliftCompiler { +impl Compiler for OldCraneliftCompiler { /// Compiles wasm binary to a wasmer module. fn compile( &self, @@ -129,3 +130,12 @@ fn validate(bytes: &[u8]) -> CompileResult<()> { /// The current version of this crate pub const VERSION: &str = env!("CARGO_PKG_VERSION"); + +use wasmer_runtime_core::codegen::SimpleStreamingCompilerGen; + +pub type CraneliftCompiler = SimpleStreamingCompilerGen< + code::CraneliftModuleCodeGenerator, + code::CraneliftFunctionCodeGenerator, + signal::Caller, + code::CodegenError, +>;