Remove backend code

This commit is contained in:
Syrus
2019-12-20 19:31:35 -08:00
parent 94bcea909b
commit 303d44cb0f
2 changed files with 1 additions and 71 deletions

View File

@ -52,7 +52,7 @@ cc = "1.0"
[features] [features]
debug = [] debug = []
trace = ["debug"] trace = ["debug"]
# backend flags used in conditional compilation of Backend::variants # backend flags no longer used
"backend-cranelift" = [] "backend-cranelift" = []
"backend-singlepass" = [] "backend-singlepass" = []
"backend-llvm" = [] "backend-llvm" = []

View File

@ -22,60 +22,6 @@ pub mod sys {
} }
pub use crate::sig_registry::SigRegistry; pub use crate::sig_registry::SigRegistry;
/// Enum used to select which compiler should be used to generate code.
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
pub enum Backend {
Cranelift,
Singlepass,
LLVM,
Auto,
}
impl Backend {
/// Get a list of the currently enabled (via feature flag) backends.
pub fn variants() -> &'static [&'static str] {
&[
#[cfg(feature = "backend-cranelift")]
"cranelift",
#[cfg(feature = "backend-singlepass")]
"singlepass",
#[cfg(feature = "backend-llvm")]
"llvm",
"auto",
]
}
/// Stable string representation of the backend.
/// It can be used as part of a cache key, for example.
pub fn to_string(&self) -> &'static str {
match self {
Backend::Cranelift => "cranelift",
Backend::Singlepass => "singlepass",
Backend::LLVM => "llvm",
Backend::Auto => "auto",
}
}
}
impl Default for Backend {
fn default() -> Self {
Backend::Cranelift
}
}
impl std::str::FromStr for Backend {
type Err = String;
fn from_str(s: &str) -> Result<Backend, String> {
match s.to_lowercase().as_str() {
"singlepass" => Ok(Backend::Singlepass),
"cranelift" => Ok(Backend::Cranelift),
"llvm" => Ok(Backend::LLVM),
"auto" => Ok(Backend::Auto),
_ => Err(format!("The backend {} doesn't exist", s)),
}
}
}
/// The target architecture for code generation. /// The target architecture for code generation.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum Architecture { pub enum Architecture {
@ -104,22 +50,6 @@ pub struct InlineBreakpoint {
pub ty: InlineBreakpointType, pub ty: InlineBreakpointType,
} }
#[cfg(test)]
mod backend_test {
use super::*;
use std::str::FromStr;
#[test]
fn str_repr_matches() {
// if this test breaks, think hard about why it's breaking
// can we avoid having these be different?
for &backend in &[Backend::Cranelift, Backend::LLVM, Backend::Singlepass] {
assert_eq!(backend, Backend::from_str(backend.to_string()).unwrap());
}
}
}
/// This type cannot be constructed from /// This type cannot be constructed from
/// outside the runtime crate. /// outside the runtime crate.
pub struct Token { pub struct Token {