mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 14:10:43 +00:00
The decoder knew 25 hand-matched forms, so any other instruction stopped decoding with no record of what it was or how long it was. A two-stage generator now reduces AMD's public RDNA 2 XML to all 1,460 base forms, with a committed snapshot so CI can check the generated table offline. identify() finds any form's exact length, including literal, SDWA, DPP and NSA words, and the shaders CLI reports discovered against executable forms so metadata coverage is never read as GPU support. Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
55 lines
1.8 KiB
Rust
55 lines
1.8 KiB
Rust
//! Ties the decoder's declared semantic forms to what it decodes from LLVM-assembled fixtures.
|
|
|
|
use std::collections::BTreeSet;
|
|
use std::fs;
|
|
use std::path::Path;
|
|
|
|
use xenora_decoder::{Architecture, SEMANTIC_FORMS, decode};
|
|
use xenora_isa::meta::{FORMS, identify};
|
|
|
|
#[test]
|
|
fn declared_semantic_forms_are_exactly_those_decoded_from_fixtures() {
|
|
let directory = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/rdna2");
|
|
let mut decoded = BTreeSet::new();
|
|
for entry in fs::read_dir(directory).unwrap() {
|
|
let path = entry.unwrap().path();
|
|
if path.extension().is_none_or(|extension| extension != "bin") {
|
|
continue;
|
|
}
|
|
let binary = fs::read(&path).unwrap();
|
|
for instruction in decode(Architecture::Gfx1030, &binary).unwrap() {
|
|
let found = identify(&binary[instruction.offset..]).unwrap();
|
|
assert_eq!(
|
|
found.len,
|
|
usize::from(instruction.byte_len),
|
|
"{}",
|
|
path.display()
|
|
);
|
|
decoded.insert((found.form.name, found.form.family));
|
|
}
|
|
}
|
|
let declared: BTreeSet<_> = SEMANTIC_FORMS.into_iter().collect();
|
|
assert!(
|
|
decoded.is_subset(&declared),
|
|
"{:?}",
|
|
decoded.difference(&declared)
|
|
);
|
|
// Covered by inline words in tests/gfx1030.rs rather than fixture binaries.
|
|
let inline_only: BTreeSet<_> = declared
|
|
.difference(&decoded)
|
|
.map(|(name, _)| *name)
|
|
.collect();
|
|
assert_eq!(
|
|
inline_only,
|
|
BTreeSet::from(["IMAGE_SAMPLE_LZ", "S_CBRANCH_EXECZ", "S_CBRANCH_VCCZ"])
|
|
);
|
|
for (name, family) in SEMANTIC_FORMS {
|
|
assert!(
|
|
FORMS
|
|
.iter()
|
|
.any(|form| form.name == name && form.family == family),
|
|
"{name}"
|
|
);
|
|
}
|
|
}
|