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