mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-16 00:00:49 +00:00
Add calling convention to function signatures
This commit is contained in:
parent
cc4b1871d0
commit
f42ca84480
@ -8,6 +8,7 @@ use crate::{
|
||||
|
||||
use cranelift_codegen::entity::EntityRef;
|
||||
use cranelift_codegen::ir::{self, Ebb, Function, InstBuilder};
|
||||
use cranelift_codegen::isa::CallConv;
|
||||
use cranelift_codegen::{cursor::FuncCursor, isa};
|
||||
use cranelift_frontend::{FunctionBuilder, Position, Variable};
|
||||
use cranelift_wasm::{self, FuncTranslator};
|
||||
@ -322,8 +323,10 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
|
||||
|
||||
fn feed_signatures(&mut self, signatures: Map<SigIndex, FuncSig>) -> Result<(), CodegenError> {
|
||||
self.signatures = Some(Arc::new(signatures));
|
||||
let call_conv = self.isa.frontend_config().default_call_conv;
|
||||
for (_sig_idx, func_sig) in self.signatures.as_ref().unwrap().iter() {
|
||||
self.clif_signatures.push(Converter(func_sig).into());
|
||||
self.clif_signatures
|
||||
.push(convert_func_sig(func_sig, call_conv));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -345,6 +348,22 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_func_sig(sig: &FuncSig, call_conv: CallConv) -> ir::Signature {
|
||||
ir::Signature {
|
||||
params: sig
|
||||
.params()
|
||||
.iter()
|
||||
.map(|params| Converter(*params).into())
|
||||
.collect::<Vec<_>>(),
|
||||
returns: sig
|
||||
.returns()
|
||||
.iter()
|
||||
.map(|returns| Converter(*returns).into())
|
||||
.collect::<Vec<_>>(),
|
||||
call_conv,
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CompileError> for CodegenError {
|
||||
fn from(other: CompileError) -> CodegenError {
|
||||
CodegenError {
|
||||
|
@ -9,7 +9,6 @@ use std::sync::Arc;
|
||||
|
||||
use wasmer_runtime_core::cache::{Artifact, Error as CacheError};
|
||||
|
||||
use cranelift_codegen::isa::CallConv;
|
||||
use wasmer_runtime_core::{
|
||||
backend::{Backend, CompilerConfig},
|
||||
error::CompileResult,
|
||||
@ -169,26 +168,6 @@ impl From<Converter<ir::Signature>> for FuncSig {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Converter<&FuncSig>> for ir::Signature {
|
||||
fn from(sig: Converter<&FuncSig>) -> Self {
|
||||
ir::Signature {
|
||||
params: sig
|
||||
.0
|
||||
.params()
|
||||
.iter()
|
||||
.map(|params| Converter(*params).into())
|
||||
.collect::<Vec<_>>(),
|
||||
returns: sig
|
||||
.0
|
||||
.returns()
|
||||
.iter()
|
||||
.map(|returns| Converter(*returns).into())
|
||||
.collect::<Vec<_>>(),
|
||||
call_conv: CallConv::SystemV, // TODO should come from isa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Converter<ir::Type>> for Type {
|
||||
fn from(ty: Converter<ir::Type>) -> Self {
|
||||
match ty.0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user