Middleware for LLVM.

This commit is contained in:
losfair
2020-06-16 00:56:43 +08:00
parent 1144222d15
commit 1bbaafb819
2 changed files with 19 additions and 2 deletions

View File

@@ -8,7 +8,9 @@ use itertools::Itertools;
use std::sync::Arc;
use target_lexicon::Architecture;
use wasm_common::{FunctionType, LocalFunctionIndex};
use wasmer_compiler::{Compiler, CompilerConfig, Features, Target, Triple};
use wasmer_compiler::{
Compiler, CompilerConfig, Features, FunctionMiddlewareGenerator, Target, Triple,
};
/// The InkWell ModuleInfo type
pub type InkwellModule<'ctx> = inkwell::module::Module<'ctx>;
@@ -61,6 +63,9 @@ pub struct LLVMConfig {
/// phases in LLVM.
pub callbacks: Option<Arc<dyn LLVMCallbacks>>,
/// The middleware chain.
pub(crate) middlewares: Vec<Arc<dyn FunctionMiddlewareGenerator>>,
features: Features,
target: Target,
}
@@ -77,6 +82,7 @@ impl LLVMConfig {
features,
target,
callbacks: None,
middlewares: vec![],
}
}
fn reloc_mode(&self) -> RelocMode {
@@ -187,6 +193,11 @@ impl CompilerConfig for LLVMConfig {
fn compiler(&self) -> Box<dyn Compiler + Send> {
Box::new(LLVMCompiler::new(&self))
}
/// Pushes a middleware onto the back of the middleware chain.
fn push_middleware(&mut self, middleware: Arc<dyn FunctionMiddlewareGenerator>) {
self.middlewares.push(middleware);
}
}
impl Default for LLVMConfig {