mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
Add scaffold to use new code generator API for Cranelift
This commit is contained in:
parent
8d2a08a1be
commit
d9cd4fc3e0
91
lib/clif-backend/src/code.rs
Normal file
91
lib/clif-backend/src/code.rs
Normal file
@ -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<CraneliftFunctionCodeGenerator, Caller, CodegenError>
|
||||
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<dyn CacheGen>), CodegenError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn feed_signatures(&mut self, _signatures: Map<SigIndex, FuncSig>) -> Result<(), CodegenError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn feed_function_signatures(
|
||||
&mut self,
|
||||
_assoc: Map<FuncIndex, SigIndex>,
|
||||
) -> Result<(), CodegenError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn feed_import_function(&mut self) -> Result<(), CodegenError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
unsafe fn from_cache(_cache: Artifact, _: Token) -> Result<ModuleInner, CacheError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CraneliftFunctionCodeGenerator {}
|
||||
|
||||
impl FunctionCodeGenerator<CodegenError> 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,
|
||||
}
|
@ -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,
|
||||
>;
|
||||
|
Loading…
Reference in New Issue
Block a user