use super::{ArchInfo, tables::riscv_uarch};
pub fn detect_from_uarch_str(s: &str) -> ArchInfo {
match riscv_uarch::RISCV_UARCH_STR
.iter()
.find(|&&(needle, _, _)| needle == s)
{
Some(&(_, name, vendor)) => ArchInfo {
vendor: Some(vendor.to_string()),
uarch: Some(name.to_string()),
soc: None,
process_nm: None,
features: Vec::new(),
},
None => ArchInfo::default(),
}
}
pub fn detect_from_marchid(marchid: u64) -> ArchInfo {
match riscv_uarch::RISCV_UARCH_MARCHID
.iter()
.find(|&&(id, _, _)| id == marchid)
{
Some(&(_, name, vendor)) => ArchInfo {
vendor: Some(vendor.to_string()),
uarch: Some(name.to_string()),
soc: None,
process_nm: None,
features: Vec::new(),
},
None => ArchInfo::default(),
}
}
pub fn soc_from_compatible(compatible: &str) -> Option<&'static str> {
let lower = compatible.to_ascii_lowercase();
riscv_uarch::RISCV_SOCS
.iter()
.find(|(needle, _)| lower.contains(needle))
.map(|(_, name)| *name)
}