Add "auto" backend to change the backend depending on the wasm file size

This commit is contained in:
Asami Doi
2019-11-22 19:02:57 +09:00
parent dfc7163b71
commit fd0df9946b
5 changed files with 34 additions and 10 deletions

View File

@ -28,6 +28,7 @@ pub enum Backend {
Cranelift,
Singlepass,
LLVM,
Auto,
}
impl Backend {
@ -40,6 +41,7 @@ impl Backend {
"singlepass",
#[cfg(feature = "backend-llvm")]
"llvm",
"auto",
]
}
@ -50,6 +52,7 @@ impl Backend {
Backend::Cranelift => "cranelift",
Backend::Singlepass => "singlepass",
Backend::LLVM => "llvm",
Backend::Auto => "auto",
}
}
}
@ -67,6 +70,7 @@ impl std::str::FromStr for Backend {
"singlepass" => Ok(Backend::Singlepass),
"cranelift" => Ok(Backend::Cranelift),
"llvm" => Ok(Backend::LLVM),
"auto" => Ok(Backend::Auto),
_ => Err(format!("The backend {} doesn't exist", s)),
}
}

View File

@ -265,6 +265,7 @@ fn requires_pre_validation(backend: Backend) -> bool {
Backend::Cranelift => true,
Backend::LLVM => true,
Backend::Singlepass => false,
Backend::Auto => false,
}
}