Skip to content

Commit

Permalink
Expose wasmer::CraneliftOptLevel
Browse files Browse the repository at this point in the history
This is required to do something like

```rust
use wasmer::{Cranelift, CraneliftOptLevel};

let mut compiler = Cranelift::default();
compiler.opt_level(CraneliftOptLevel::None);
let engine = JIT::new(compiler).engine();
// ...
```
  • Loading branch information
webmaster128 committed Dec 17, 2020
1 parent bc0ba32 commit 85bb103
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ let store = Store::new(&engine);
pub use wasmer_compiler_singlepass::Singlepass;

#[cfg(feature = "cranelift")]
pub use wasmer_compiler_cranelift::Cranelift;
pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel};

#[cfg(feature = "llvm")]
pub use wasmer_compiler_llvm::LLVM;
Expand Down
14 changes: 7 additions & 7 deletions lib/compiler-cranelift/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use wasmer_compiler::{
/// Possible optimization levels for the Cranelift codegen backend.
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum OptLevel {
pub enum CraneliftOptLevel {
/// No optimizations performed, minimizes compilation time by disabling most
/// optimizations.
None,
Expand All @@ -33,7 +33,7 @@ pub struct Cranelift {
enable_verifier: bool,
enable_simd: bool,
enable_pic: bool,
opt_level: OptLevel,
opt_level: CraneliftOptLevel,
/// The middleware chain.
pub(crate) middlewares: Vec<Arc<dyn ModuleMiddleware>>,
}
Expand All @@ -45,7 +45,7 @@ impl Cranelift {
Self {
enable_nan_canonicalization: false,
enable_verifier: false,
opt_level: OptLevel::Speed,
opt_level: CraneliftOptLevel::Speed,
enable_pic: false,
enable_simd: true,
middlewares: vec![],
Expand All @@ -68,7 +68,7 @@ impl Cranelift {
}

/// The optimization levels when optimizing the IR.
pub fn opt_level(&mut self, opt_level: OptLevel) -> &mut Self {
pub fn opt_level(&mut self, opt_level: CraneliftOptLevel) -> &mut Self {
self.opt_level = opt_level;
self
}
Expand Down Expand Up @@ -156,9 +156,9 @@ impl Cranelift {
"none"
} else {
match self.opt_level {
OptLevel::None => "none",
OptLevel::Speed => "speed",
OptLevel::SpeedAndSize => "speed_and_size",
CraneliftOptLevel::None => "none",
CraneliftOptLevel::Speed => "speed",
CraneliftOptLevel::SpeedAndSize => "speed_and_size",
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler-cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod trampoline;
mod translator;

pub use crate::compiler::CraneliftCompiler;
pub use crate::config::Cranelift;
pub use crate::config::{Cranelift, CraneliftOptLevel};
pub use crate::debug::{ModuleInfoMemoryOffset, ModuleInfoVmctxInfo, ValueLabelsRanges};
pub use crate::trampoline::make_trampoline_function_call;

Expand Down

0 comments on commit 85bb103

Please sign in to comment.