Refactor calling convention settings. (#304)
Add a calling-convention setting to the `Flags` used as part of the `TargetIsa`. This allows Cretonne code that generates calls to use the correct convention, such as when emitting libcalls during legalization or when the wasm frontend is decoding functions. This setting can be overridden per-function. This also adds "fast", "cold", and "fastcall" conventions, with "fast" as the new default. Note that "fast" and "cold" are not intended to be ABI-compatible across Cretonne versions. This will also ensure Windows users will get an `unimplemented!` rather than silent calling-convention mismatches, which reflects the fact that Windows calling conventions are not yet implemented. This also renames SpiderWASM, which isn't camel-case, to Baldrdash, which is, and which is also a more relevant name.
This commit is contained in:
@@ -271,6 +271,10 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
||||
}
|
||||
|
||||
impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
||||
fn flags(&self) -> &settings::Flags {
|
||||
&self.info.flags
|
||||
}
|
||||
|
||||
fn get_func_name(&self, func_index: FunctionIndex) -> ir::ExternalName {
|
||||
get_func_name(func_index)
|
||||
}
|
||||
|
||||
@@ -160,6 +160,9 @@ pub trait FuncEnvironment {
|
||||
/// [`translate_module`](fn.translate_module.html) function. These methods should not be called
|
||||
/// by the user, they are only for `cretonne-wasm` internal use.
|
||||
pub trait ModuleEnvironment<'data> {
|
||||
/// Get the flags for the current compilation.
|
||||
fn flags(&self) -> &Flags;
|
||||
|
||||
/// Return the name for the given function index.
|
||||
fn get_func_name(&self, func_index: FunctionIndex) -> ir::ExternalName;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//! The special case of the initialize expressions for table elements offsets or global variables
|
||||
//! is handled, according to the semantics of WebAssembly, to only specific expressions that are
|
||||
//! interpreted on the fly.
|
||||
use cretonne_codegen::ir::{self, AbiParam, CallConv, Signature};
|
||||
use cretonne_codegen::ir::{self, AbiParam, Signature};
|
||||
use environ::ModuleEnvironment;
|
||||
use std::str::from_utf8;
|
||||
use std::string::String;
|
||||
@@ -35,7 +35,7 @@ pub fn parse_function_signatures(
|
||||
ref params,
|
||||
ref returns,
|
||||
}) => {
|
||||
let mut sig = Signature::new(CallConv::SystemV);
|
||||
let mut sig = Signature::new(environ.flags().call_conv());
|
||||
sig.params.extend(params.iter().map(|ty| {
|
||||
let cret_arg: ir::Type = type_to_type(ty).expect(
|
||||
"only numeric types are supported in function signatures",
|
||||
|
||||
Reference in New Issue
Block a user