wasmer_compiler_singlepass/
config.rs1#![allow(unused_imports, dead_code)]
3
4use crate::compiler::SinglepassCompiler;
5use std::sync::Arc;
6use wasmer_compiler::{
7 types::target::{CpuFeature, Target},
8 Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware,
9};
10use wasmer_types::Features;
11
12#[derive(Debug, Clone)]
13pub struct Singlepass {
14 pub(crate) enable_nan_canonicalization: bool,
15 pub(crate) middlewares: Vec<Arc<dyn ModuleMiddleware>>,
17}
18
19impl Singlepass {
20 pub fn new() -> Self {
23 Self {
24 enable_nan_canonicalization: true,
25 middlewares: vec![],
26 }
27 }
28
29 pub fn canonicalize_nans(&mut self, enable: bool) -> &mut Self {
30 self.enable_nan_canonicalization = enable;
31 self
32 }
33}
34
35impl CompilerConfig for Singlepass {
36 fn enable_pic(&mut self) {
37 }
40
41 fn compiler(self: Box<Self>) -> Box<dyn Compiler> {
43 Box::new(SinglepassCompiler::new(*self))
44 }
45
46 fn default_features_for_target(&self, _target: &Target) -> Features {
48 let mut features = Features::default();
49 features.multi_value(false);
50 features
51 }
52
53 fn push_middleware(&mut self, middleware: Arc<dyn ModuleMiddleware>) {
55 self.middlewares.push(middleware);
56 }
57}
58
59impl Default for Singlepass {
60 fn default() -> Singlepass {
61 Self::new()
62 }
63}
64
65impl From<Singlepass> for Engine {
66 fn from(config: Singlepass) -> Self {
67 EngineBuilder::new(config).engine()
68 }
69}