Fixes #13: Enable conditional compilation of ISAs through features;
This commit is contained in:
committed by
Dan Gohman
parent
049f067168
commit
a45b814de8
@@ -13,43 +13,8 @@ mod shared;
|
||||
mod srcgen;
|
||||
mod unique_table;
|
||||
|
||||
pub fn isa_from_arch(arch: &str) -> Result<Vec<isa::Isa>, String> {
|
||||
isa::Isa::from_arch(arch)
|
||||
.ok_or_else(|| format!("no supported isa found for arch `{}`", arch))
|
||||
.and_then(|isa| Ok(vec![isa]))
|
||||
}
|
||||
|
||||
pub fn isas_from_targets(targets: Vec<&str>) -> Result<Vec<isa::Isa>, String> {
|
||||
type R<'a> = Vec<(&'a str, Option<isa::Isa>)>;
|
||||
|
||||
let (known, unknown): (R, R) = targets
|
||||
.into_iter()
|
||||
.map(|target| (target, isa::Isa::from_name(target)))
|
||||
.partition(|(_, opt_isa)| opt_isa.is_some());
|
||||
|
||||
if !unknown.is_empty() {
|
||||
let unknown_targets = unknown
|
||||
.into_iter()
|
||||
.map(|(target, _)| target)
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
return Err(format!("unknown isa targets: {}", unknown_targets));
|
||||
}
|
||||
|
||||
let isas = if known.is_empty() {
|
||||
isa::Isa::all().to_vec()
|
||||
} else {
|
||||
known
|
||||
.into_iter()
|
||||
.map(|(_, opt_isa)| opt_isa.unwrap())
|
||||
.collect()
|
||||
};
|
||||
|
||||
Ok(isas)
|
||||
}
|
||||
|
||||
pub fn all_isas() -> Result<Vec<isa::Isa>, String> {
|
||||
isas_from_targets(vec![])
|
||||
pub fn isa_from_arch(arch: &str) -> Result<isa::Isa, String> {
|
||||
isa::Isa::from_arch(arch).ok_or_else(|| format!("no supported isa found for arch `{}`", arch))
|
||||
}
|
||||
|
||||
/// Generates all the Rust source files used in Cranelift from the meta-language.
|
||||
|
||||
Reference in New Issue
Block a user