mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 13:48:26 +00:00
Fixed LLVM with new compiler structure
This commit is contained in:
@@ -9,10 +9,10 @@ use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
||||
use wasm_common::entity::{EntityRef, PrimaryMap, SecondaryMap};
|
||||
use wasm_common::Features;
|
||||
use wasm_common::{FuncIndex, FuncType, LocalFuncIndex, MemoryIndex, TableIndex};
|
||||
use wasmer_compiler::FunctionBodyData;
|
||||
use wasmer_compiler::TrapInformation;
|
||||
use wasmer_compiler::{Compilation, CompileError, CompiledFunction, Compiler};
|
||||
use wasmer_compiler::{CompilerConfig, ModuleTranslationState, Target};
|
||||
use wasmer_compiler::{FunctionBody, FunctionBodyData};
|
||||
use wasmer_runtime::{MemoryPlan, Module, TablePlan, TrapCode};
|
||||
|
||||
use inkwell::targets::{InitializationConfig, Target as InkwellTarget};
|
||||
@@ -98,7 +98,7 @@ impl Compiler for LLVMCompiler {
|
||||
fn compile_wasm_trampolines(
|
||||
&self,
|
||||
signatures: &[FuncType],
|
||||
) -> Result<Vec<CompiledFunction>, CompileError> {
|
||||
) -> Result<Vec<FunctionBody>, CompileError> {
|
||||
signatures
|
||||
.par_iter()
|
||||
.map_init(FuncTrampoline::new, |func_trampoline, sig| {
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
use crate::config::LLVMConfig;
|
||||
use crate::translator::intrinsics::{func_type_to_llvm, type_to_llvm, Intrinsics};
|
||||
use crate::translator::intrinsics::{func_type_to_llvm, Intrinsics};
|
||||
use inkwell::{
|
||||
context::Context,
|
||||
module::{Linkage, Module},
|
||||
passes::PassManager,
|
||||
targets::FileType,
|
||||
types::{BasicType, FunctionType},
|
||||
values::FunctionValue,
|
||||
AddressSpace,
|
||||
context::Context, module::Linkage, passes::PassManager, targets::FileType, types::BasicType,
|
||||
values::FunctionValue, AddressSpace,
|
||||
};
|
||||
use wasm_common::entity::SecondaryMap;
|
||||
use wasm_common::{FuncType, Type};
|
||||
use wasmer_compiler::{
|
||||
Compilation, CompileError, CompiledFunction, CompiledFunctionUnwindInfo, Compiler,
|
||||
FunctionAddressMap, SourceLoc,
|
||||
};
|
||||
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use wasmer_compiler::{CompileError, CompiledFunctionUnwindInfo, FunctionBody};
|
||||
|
||||
pub struct FuncTrampoline {
|
||||
ctx: Context,
|
||||
@@ -34,7 +22,7 @@ impl FuncTrampoline {
|
||||
&mut self,
|
||||
ty: &FuncType,
|
||||
config: &LLVMConfig,
|
||||
) -> Result<CompiledFunction, CompileError> {
|
||||
) -> Result<FunctionBody, CompileError> {
|
||||
let mut module = self.ctx.create_module("");
|
||||
let target_triple = config.target_triple();
|
||||
let target_machine = config.target_machine();
|
||||
@@ -107,21 +95,9 @@ impl FuncTrampoline {
|
||||
// TODO: remove debugging
|
||||
//dbg!(&bytes);
|
||||
|
||||
let address_map = FunctionAddressMap {
|
||||
instructions: vec![],
|
||||
start_srcloc: SourceLoc::default(),
|
||||
end_srcloc: SourceLoc::default(),
|
||||
body_offset: 0,
|
||||
body_len: 0, // TODO
|
||||
};
|
||||
|
||||
Ok(CompiledFunction {
|
||||
address_map,
|
||||
Ok(FunctionBody {
|
||||
body: bytes,
|
||||
jt_offsets: SecondaryMap::new(),
|
||||
unwind_info: CompiledFunctionUnwindInfo::None,
|
||||
relocations: vec![],
|
||||
traps: vec![],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ use inkwell::{
|
||||
passes::PassManager,
|
||||
//targets::{CodeModel, InitializationConfig, RelocMode, Target, TargetMachine, TargetTriple},
|
||||
targets::FileType,
|
||||
types::{
|
||||
BasicType, BasicTypeEnum, FloatMathType, FunctionType, IntType, PointerType, VectorType,
|
||||
},
|
||||
types::{BasicType, BasicTypeEnum, FloatMathType, IntType, PointerType, VectorType},
|
||||
values::{
|
||||
BasicValue, BasicValueEnum, FloatValue, FunctionValue, IntValue, PhiValue, PointerValue,
|
||||
VectorValue,
|
||||
@@ -39,7 +37,8 @@ use wasm_common::{
|
||||
};
|
||||
use wasmer_compiler::wasmparser::{self, BinaryReader, MemoryImmediate, Operator};
|
||||
use wasmer_compiler::{
|
||||
to_wasm_error, wasm_unsupported, CompileError, CompiledFunction, WasmResult,
|
||||
to_wasm_error, wasm_unsupported, CompileError, CompiledFunction, CompiledFunctionFrameInfo,
|
||||
FunctionBody, WasmResult,
|
||||
};
|
||||
use wasmer_compiler::{
|
||||
CompiledFunctionUnwindInfo, FunctionAddressMap, FunctionBodyData, Relocation, RelocationKind,
|
||||
@@ -364,12 +363,16 @@ impl FuncTranslator {
|
||||
};
|
||||
|
||||
Ok(CompiledFunction {
|
||||
address_map,
|
||||
body: bytes,
|
||||
body: FunctionBody {
|
||||
body: bytes,
|
||||
unwind_info: CompiledFunctionUnwindInfo::None,
|
||||
},
|
||||
jt_offsets: SecondaryMap::new(),
|
||||
unwind_info: CompiledFunctionUnwindInfo::None,
|
||||
relocations,
|
||||
traps: vec![],
|
||||
frame_info: CompiledFunctionFrameInfo {
|
||||
address_map,
|
||||
traps: vec![],
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user