1#![deny(missing_docs)]
4#![no_std]
5
6#[cfg(not(feature = "std"))]
7#[macro_use]
8extern crate alloc as std;
9#[cfg(feature = "std")]
10#[macro_use]
11extern crate std;
12
13#[cfg(not(feature = "std"))]
14use hashbrown::{hash_map, HashMap};
15use std::borrow::ToOwned;
16use std::boxed::Box;
17#[cfg(feature = "std")]
18use std::collections::{hash_map, HashMap};
19use std::string::String;
20
21use cranelift_codegen::ir;
22
23mod data_context;
24mod module;
25mod traps;
26
27pub use crate::data_context::{DataDescription, Init};
28pub use crate::module::{
29 DataDeclaration, DataId, FuncId, FuncOrDataId, FunctionDeclaration, Linkage, Module,
30 ModuleDeclarations, ModuleError, ModuleReloc, ModuleRelocTarget, ModuleResult,
31};
32pub use crate::traps::TrapSite;
33
34pub const VERSION: &str = env!("CARGO_PKG_VERSION");
36
37pub fn default_libcall_names() -> Box<dyn Fn(ir::LibCall) -> String + Send + Sync> {
40 Box::new(move |libcall| match libcall {
41 ir::LibCall::Probestack => "__cranelift_probestack".to_owned(),
42 ir::LibCall::CeilF32 => "ceilf".to_owned(),
43 ir::LibCall::CeilF64 => "ceil".to_owned(),
44 ir::LibCall::FloorF32 => "floorf".to_owned(),
45 ir::LibCall::FloorF64 => "floor".to_owned(),
46 ir::LibCall::TruncF32 => "truncf".to_owned(),
47 ir::LibCall::TruncF64 => "trunc".to_owned(),
48 ir::LibCall::NearestF32 => "nearbyintf".to_owned(),
49 ir::LibCall::NearestF64 => "nearbyint".to_owned(),
50 ir::LibCall::FmaF32 => "fmaf".to_owned(),
51 ir::LibCall::FmaF64 => "fma".to_owned(),
52 ir::LibCall::Memcpy => "memcpy".to_owned(),
53 ir::LibCall::Memset => "memset".to_owned(),
54 ir::LibCall::Memmove => "memmove".to_owned(),
55 ir::LibCall::Memcmp => "memcmp".to_owned(),
56
57 ir::LibCall::ElfTlsGetAddr => "__tls_get_addr".to_owned(),
58 ir::LibCall::ElfTlsGetOffset => "__tls_get_offset".to_owned(),
59 ir::LibCall::X86Pshufb => "__cranelift_x86_pshufb".to_owned(),
60 })
61}