Add a fixup pass for cpuid values when validating XML.

This commit is contained in:
Henry de Valence 2019-02-06 20:08:48 -08:00 committed by gnzlbg
parent 19e23d1b15
commit 94dd5f26e0

View file

@ -273,15 +273,25 @@ fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> {
.flat_map(|c| c.to_lowercase())
.collect::<String>();
// The XML file names IFMA as "avx512ifma52", while Rust calls
// it "avx512ifma". Fix this mismatch by replacing the Intel
// name with the Rust name.
let fixup_cpuid = |cpuid: String| match cpuid.as_ref() {
"avx512ifma52" => String::from("avx512ifma"),
_ => cpuid,
};
let fixed_cpuid = fixup_cpuid(cpuid);
let rust_feature = rust
.target_feature
.expect(&format!("no target feature listed for {}", rust.name));
if rust_feature.contains(&cpuid) {
if rust_feature.contains(&fixed_cpuid) {
continue;
}
bail!(
"intel cpuid `{}` not in `{}` for {}",
cpuid,
fixed_cpuid,
rust_feature,
rust.name
)