Simplified compiler config names

This commit is contained in:
Syrus
2020-06-18 01:36:25 -07:00
parent 1002a2765c
commit 422051ebe5
18 changed files with 56 additions and 59 deletions

View File

@@ -1,4 +1,4 @@
use crate::config::LLVMConfig;
use crate::config::LLVM;
use crate::trampoline::FuncTrampoline;
use crate::translator::FuncTranslator;
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
@@ -14,19 +14,19 @@ use wasmer_compiler::{
/// A compiler that compiles a WebAssembly module with LLVM, translating the Wasm to LLVM IR,
/// optimizing it and then translating to assembly.
pub struct LLVMCompiler {
config: LLVMConfig,
config: LLVM,
}
impl LLVMCompiler {
/// Creates a new LLVM compiler
pub fn new(config: &LLVMConfig) -> LLVMCompiler {
pub fn new(config: &LLVM) -> LLVMCompiler {
LLVMCompiler {
config: config.clone(),
}
}
/// Gets the config for this Compiler
fn config(&self) -> &LLVMConfig {
fn config(&self) -> &LLVM {
&self.config
}
}

View File

@@ -39,7 +39,7 @@ pub trait LLVMCallbacks: Send + Sync {
}
#[derive(Clone)]
pub struct LLVMConfig {
pub struct LLVM {
pub(crate) enable_nan_canonicalization: bool,
pub(crate) enable_verifier: bool,
pub(crate) opt_level: OptimizationLevel,
@@ -49,7 +49,7 @@ pub struct LLVMConfig {
pub(crate) middlewares: Vec<Arc<dyn FunctionMiddlewareGenerator>>,
}
impl LLVMConfig {
impl LLVM {
/// Creates a new configuration object with the default configuration
/// specified.
pub fn new() -> Self {
@@ -176,7 +176,7 @@ impl LLVMConfig {
}
}
impl CompilerConfig for LLVMConfig {
impl CompilerConfig for LLVM {
/// Emit code suitable for dlopen.
fn enable_pic(&mut self) {
// TODO: although we can emit PIC, the object file parser does not yet
@@ -195,8 +195,8 @@ impl CompilerConfig for LLVMConfig {
}
}
impl Default for LLVMConfig {
fn default() -> LLVMConfig {
impl Default for LLVM {
fn default() -> LLVM {
Self::new()
}
}

View File

@@ -22,5 +22,5 @@ mod translator;
pub use crate::compiler::LLVMCompiler;
pub use crate::config::{
CompiledFunctionKind, InkwellMemoryBuffer, InkwellModule, LLVMCallbacks, LLVMConfig,
CompiledFunctionKind, InkwellMemoryBuffer, InkwellModule, LLVMCallbacks, LLVM,
};

View File

@@ -1,4 +1,4 @@
use crate::config::{CompiledFunctionKind, LLVMConfig};
use crate::config::{CompiledFunctionKind, LLVM};
use crate::object_file::load_object_file;
use crate::translator::abi::{
func_type_to_llvm, get_vmctx_ptr_param, is_sret, pack_values_for_register_return,
@@ -38,7 +38,7 @@ impl FuncTrampoline {
pub fn trampoline(
&mut self,
ty: &FunctionType,
config: &LLVMConfig,
config: &LLVM,
) -> Result<FunctionBody, CompileError> {
// The function type, used for the callbacks.
let function = CompiledFunctionKind::FunctionCallTrampoline(ty.clone());
@@ -127,7 +127,7 @@ impl FuncTrampoline {
pub fn dynamic_trampoline(
&mut self,
ty: &FunctionType,
config: &LLVMConfig,
config: &LLVM,
) -> Result<FunctionBody, CompileError> {
// The function type, used for the callbacks
let function = CompiledFunctionKind::DynamicFunctionTrampoline(ty.clone());

View File

@@ -22,7 +22,7 @@ use inkwell::{
};
use smallvec::SmallVec;
use crate::config::{CompiledFunctionKind, LLVMConfig};
use crate::config::{CompiledFunctionKind, LLVM};
use crate::object_file::load_object_file;
use wasm_common::entity::{PrimaryMap, SecondaryMap};
use wasm_common::{
@@ -72,7 +72,7 @@ impl FuncTranslator {
module_translation: &ModuleTranslationState,
local_func_index: &LocalFunctionIndex,
function_body: &FunctionBodyData,
config: &LLVMConfig,
config: &LLVM,
memory_plans: &PrimaryMap<MemoryIndex, MemoryPlan>,
_table_plans: &PrimaryMap<TableIndex, TablePlan>,
func_names: &SecondaryMap<FunctionIndex, String>,