mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-16 16:20:49 +00:00
Move backend_id to static str
This commit is contained in:
parent
cb5cf00442
commit
a1d8b9aa5b
@ -32,6 +32,8 @@ use wasmer_runtime_core::{
|
||||
};
|
||||
use wasmparser::Type as WpType;
|
||||
|
||||
static BACKEND_ID: &str = "cranelift";
|
||||
|
||||
pub struct CraneliftModuleCodeGenerator {
|
||||
isa: Box<dyn isa::TargetIsa>,
|
||||
signatures: Option<Arc<Map<SigIndex, FuncSig>>>,
|
||||
@ -58,8 +60,8 @@ impl ModuleCodeGenerator<CraneliftFunctionCodeGenerator, Caller, CodegenError>
|
||||
unimplemented!("cross compilation is not available for clif backend")
|
||||
}
|
||||
|
||||
fn backend_id() -> String {
|
||||
"cranelift".to_string()
|
||||
fn backend_id() -> &'static str {
|
||||
BACKEND_ID
|
||||
}
|
||||
|
||||
fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> {
|
||||
|
@ -45,6 +45,8 @@ use wasmer_runtime_core::{
|
||||
};
|
||||
use wasmparser::{BinaryReaderError, MemoryImmediate, Operator, Type as WpType};
|
||||
|
||||
static BACKEND_ID: &str = "llvm";
|
||||
|
||||
fn func_sig_to_llvm<'ctx>(
|
||||
context: &'ctx Context,
|
||||
intrinsics: &Intrinsics<'ctx>,
|
||||
@ -8721,8 +8723,8 @@ impl<'ctx> ModuleCodeGenerator<LLVMFunctionCodeGenerator<'ctx>, LLVMBackend, Cod
|
||||
}
|
||||
}
|
||||
|
||||
fn backend_id() -> String {
|
||||
"llvm".to_string()
|
||||
fn backend_id() -> &'static str {
|
||||
BACKEND_ID
|
||||
}
|
||||
|
||||
fn check_precondition(&mut self, _module_info: &ModuleInfo) -> Result<(), CodegenError> {
|
||||
|
@ -110,7 +110,7 @@ mod tests {
|
||||
baseline: true,
|
||||
msm: msm,
|
||||
base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize,
|
||||
backend: MCG::backend_id(),
|
||||
backend: MCG::backend_id().to_string(),
|
||||
runnable_module: instance.module.runnable_module.clone(),
|
||||
});
|
||||
true
|
||||
@ -152,7 +152,7 @@ mod tests {
|
||||
baseline: true,
|
||||
msm: msm,
|
||||
base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize,
|
||||
backend: MCG::backend_id(),
|
||||
backend: MCG::backend_id().to_string(),
|
||||
runnable_module: instance.module.runnable_module.clone(),
|
||||
});
|
||||
true
|
||||
|
@ -92,7 +92,7 @@ pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule,
|
||||
) -> Self;
|
||||
|
||||
/// Returns the backend id associated with this MCG.
|
||||
fn backend_id() -> String;
|
||||
fn backend_id() -> &'static str;
|
||||
|
||||
/// It sets if the current compiler requires validation before compilation
|
||||
fn requires_pre_validation() -> bool {
|
||||
@ -231,7 +231,7 @@ impl<
|
||||
validate_with_features(wasm, &compiler_config.features)?;
|
||||
}
|
||||
|
||||
let mut mcg = match MCG::backend_id().as_ref() {
|
||||
let mut mcg = match MCG::backend_id() {
|
||||
"llvm" => MCG::new_with_target(
|
||||
compiler_config.triple.clone(),
|
||||
compiler_config.cpu_name.clone(),
|
||||
|
@ -82,7 +82,7 @@ pub fn read_module<
|
||||
|
||||
func_assoc: Map::new(),
|
||||
signatures: Map::new(),
|
||||
backend: MCG::backend_id(),
|
||||
backend: MCG::backend_id().to_string(),
|
||||
|
||||
namespace_table: StringTable::new(),
|
||||
name_table: StringTable::new(),
|
||||
|
@ -59,6 +59,8 @@ pub const INLINE_BREAKPOINT_SIZE_X86_SINGLEPASS: usize = 7;
|
||||
/// Inline breakpoint size for aarch64.
|
||||
pub const INLINE_BREAKPOINT_SIZE_AARCH64_SINGLEPASS: usize = 12;
|
||||
|
||||
static BACKEND_ID: &str = "singlepass";
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
lazy_static! {
|
||||
/// Performs a System V call to `target` with [stack_top..stack_base] as the argument list, from right to left.
|
||||
@ -651,8 +653,8 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
|
||||
false
|
||||
}
|
||||
|
||||
fn backend_id() -> String {
|
||||
"singlepass".to_string()
|
||||
fn backend_id() -> &'static str {
|
||||
BACKEND_ID
|
||||
}
|
||||
|
||||
fn new_with_target(_: Option<String>, _: Option<String>, _: Option<String>) -> Self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user