cranelift-simplejit: add a translation mechanism for LibCalls (#747)
This commit is contained in:
@@ -9,6 +9,10 @@ use cranelift_codegen::isa::TargetIsa;
|
||||
use cranelift_codegen::Context;
|
||||
use cranelift_codegen::{binemit, ir};
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::boxed::Box;
|
||||
use std::string::String;
|
||||
|
||||
/// A `Backend` implements the functionality needed to support a `Module`.
|
||||
///
|
||||
/// Two notable implementations of this trait are:
|
||||
@@ -127,3 +131,22 @@ where
|
||||
/// provide additional functionality through this result.
|
||||
fn finish(self) -> Self::Product;
|
||||
}
|
||||
|
||||
/// Default names for `ir::LibCall`s. A function by this name is imported into the object as
|
||||
/// part of the translation of a `ir::ExternalName::LibCall` variant.
|
||||
pub fn default_libcall_names() -> Box<Fn(ir::LibCall) -> String> {
|
||||
Box::new(move |libcall| match libcall {
|
||||
ir::LibCall::Probestack => "__cranelift_probestack".to_owned(),
|
||||
ir::LibCall::CeilF32 => "ceilf".to_owned(),
|
||||
ir::LibCall::CeilF64 => "ceil".to_owned(),
|
||||
ir::LibCall::FloorF32 => "floorf".to_owned(),
|
||||
ir::LibCall::FloorF64 => "floor".to_owned(),
|
||||
ir::LibCall::TruncF32 => "truncf".to_owned(),
|
||||
ir::LibCall::TruncF64 => "trunc".to_owned(),
|
||||
ir::LibCall::NearestF32 => "nearbyintf".to_owned(),
|
||||
ir::LibCall::NearestF64 => "nearbyint".to_owned(),
|
||||
ir::LibCall::Memcpy => "memcpy".to_owned(),
|
||||
ir::LibCall::Memset => "memset".to_owned(),
|
||||
ir::LibCall::Memmove => "memmove".to_owned(),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user