Skip to content

Commit 1ae64ec

Browse files
committed
Small refactorings in x86-intel.rs
remove `PRINT_MISSING_LISTS` as it was unused rename `PRINT_MISSING_LISTS_MARKDOWN`
1 parent 89031ac commit 1ae64ec

File tree

1 file changed

+18
-65
lines changed

1 file changed

+18
-65
lines changed

crates/stdarch-verify/tests/x86-intel.rs

+18-65
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use std::io::{BufWriter, Write};
88
use serde::Deserialize;
99

1010
const PRINT_INSTRUCTION_VIOLATIONS: bool = false;
11-
const PRINT_MISSING_LISTS: bool = false;
12-
const PRINT_MISSING_LISTS_MARKDOWN: bool = false;
13-
const SS: u8 = (8 * core::mem::size_of::<usize>()) as u8;
11+
const GENERATE_MISSING_X86_MD: bool = false;
12+
const SS: u8 = (8 * size_of::<usize>()) as u8;
1413

1514
struct Function {
1615
name: &'static str,
@@ -291,16 +290,13 @@ fn verify_all_signatures() {
291290
"__cpuid" |
292291
"__get_cpuid_max" |
293292
// Not listed with intel, but manually verified
294-
"cmpxchg16b"
295-
=> continue,
293+
"cmpxchg16b" |
296294
// Intel requires the mask argument for _mm_shuffle_ps to be an
297295
// unsigned integer, but all other _mm_shuffle_.. intrinsics
298296
// take a signed-integer. This breaks `_MM_SHUFFLE` for
299-
// `_mm_shuffle_ps`:
300-
name@"_mm_shuffle_ps" => {
301-
map.remove(name);
302-
continue;
303-
},
297+
// `_mm_shuffle_ps`
298+
"_mm_shuffle_ps"
299+
=> continue,
304300
_ => {}
305301
}
306302

@@ -331,10 +327,7 @@ fn verify_all_signatures() {
331327
}
332328
assert!(all_valid);
333329

334-
if PRINT_MISSING_LISTS {
335-
print_missing(&map, io::stdout()).unwrap();
336-
}
337-
if PRINT_MISSING_LISTS_MARKDOWN {
330+
if GENERATE_MISSING_X86_MD {
338331
print_missing(
339332
&map,
340333
BufWriter::new(File::create("../core_arch/missing-x86.md").unwrap()),
@@ -367,23 +360,16 @@ fn print_missing(map: &HashMap<&str, Vec<&Intrinsic>>, mut f: impl Write) -> io:
367360

368361
for (k, v) in &mut missing {
369362
v.sort_by_key(|intrinsic| &intrinsic.name); // sort to make the order of everything same
370-
if PRINT_MISSING_LISTS_MARKDOWN {
371-
writeln!(f, "\n<details><summary>{k:?}</summary><p>\n")?;
372-
for intel in v {
373-
let url = format!(
374-
"https://software.intel.com/sites/landingpage\
363+
writeln!(f, "\n<details><summary>{k:?}</summary><p>\n")?;
364+
for intel in v {
365+
let url = format!(
366+
"https://software.intel.com/sites/landingpage\
375367
/IntrinsicsGuide/#text={}",
376-
intel.name
377-
);
378-
writeln!(f, " * [ ] [`{}`]({url})", intel.name)?;
379-
}
380-
writeln!(f, "</p></details>\n")?;
381-
} else {
382-
writeln!(f, "\n{k:?}\n")?;
383-
for intel in v {
384-
writeln!(f, "\t{}", intel.name)?;
385-
}
368+
intel.name
369+
);
370+
writeln!(f, " * [ ] [`{}`]({url})", intel.name)?;
386371
}
372+
writeln!(f, "</p></details>\n")?;
387373
}
388374

389375
f.flush()
@@ -454,51 +440,18 @@ fn check_target_features(rust: &Function, intel: &Intrinsic) -> Result<(), Strin
454440
continue;
455441
}
456442

457-
let cpuid = cpuid.to_lowercase();
443+
let cpuid = cpuid.to_lowercase().replace('_', "");
458444

459445
// Fix mismatching feature names:
460-
let fixup_cpuid = |cpuid: String| match cpuid.as_ref() {
446+
let fixed_cpuid = match cpuid.as_ref() {
461447
// The XML file names IFMA as "avx512ifma52", while Rust calls
462448
// it "avx512ifma".
463449
"avx512ifma52" => String::from("avx512ifma"),
464-
// The XML file names BITALG as "avx512_bitalg", while Rust calls
465-
// it "avx512bitalg".
466-
"avx512_bitalg" => String::from("avx512bitalg"),
467-
// The XML file names VBMI as "avx512_vbmi", while Rust calls
468-
// it "avx512vbmi".
469-
"avx512_vbmi" => String::from("avx512vbmi"),
470-
// The XML file names VBMI2 as "avx512_vbmi2", while Rust calls
471-
// it "avx512vbmi2".
472-
"avx512_vbmi2" => String::from("avx512vbmi2"),
473-
// The XML file names VNNI as "avx512_vnni", while Rust calls
474-
// it "avx512vnni".
475-
"avx512_vnni" => String::from("avx512vnni"),
476-
// The XML file names BF16 as "avx512_bf16", while Rust calls
477-
// it "avx512bf16".
478-
"avx512_bf16" => String::from("avx512bf16"),
479-
// The XML file names FP16 as "avx512_fp16", while Rust calls
480-
// it "avx512fp16".
481-
"avx512_fp16" => String::from("avx512fp16"),
482-
// The XML file names AVX-VNNI as "avx_vnni", while Rust calls
483-
// it "avxvnni"
484-
"avx_vnni" => String::from("avxvnni"),
485-
// The XML file names AVX-VNNI_INT8 as "avx_vnni_int8", while Rust calls
486-
// it "avxvnniint8"
487-
"avx_vnni_int8" => String::from("avxvnniint8"),
488-
// The XML file names AVX-NE-CONVERT as "avx_ne_convert", while Rust calls
489-
// it "avxvnni"
490-
"avx_ne_convert" => String::from("avxneconvert"),
491-
// The XML file names AVX-IFMA as "avx_ifma", while Rust calls
492-
// it "avxifma"
493-
"avx_ifma" => String::from("avxifma"),
494-
// The XML file names AVX-VNNI_INT16 as "avx_vnni_int16", while Rust calls
495-
// it "avxvnniint16"
496-
"avx_vnni_int16" => String::from("avxvnniint16"),
497450
"xss" => String::from("xsaves"),
498451
_ => cpuid,
499452
};
500453

501-
intel_cpuids.insert(fixup_cpuid(cpuid));
454+
intel_cpuids.insert(fixed_cpuid);
502455
}
503456

504457
if intel_cpuids.contains("gfni") {

0 commit comments

Comments
 (0)