diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c96209..e33120b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ remains unsupported. ### Fixed +- Fixed `xenora_isa::meta::identify` reading six VOP3 interpolation forms (`v_interp_p1_f32_e64`, `v_interp_p2_f32_e64`, `v_interp_mov_f32_e64`, `v_interp_p1ll_f16`, `v_interp_p1lv_f16`, `v_interp_p2_f16`) as 12 bytes when SRC0 is 255. In these forms SRC0 holds attribute bit-fields, not an operand selector (AMD RDNA 2 ISA guide section 10.4.2; XML operand type `OPR_ATTR`), so SRC0 = 255 no longer adds a literal word. The six corpus probes are now 8 bytes, as LLVM 23.1.6 also decodes them. The six pinned `mismatch` rows in the LLVM corpus check are gone: one now agrees fully, and five are `operand_flagged` (same instruction and length; LLVM flags an operand). - Updated `test_probe_static_analysis_does_not_execute_code`: the SIB store `mov [rsp + 0x20], rbx` at RVA 0x1004 is now genuinely supported by the native DBT (verified by the independent execution test above), so the probe reports no blocker for this program. diff --git a/crates/isa/src/meta.rs b/crates/isa/src/meta.rs index a4eba08..4cbef5a 100644 --- a/crates/isa/src/meta.rs +++ b/crates/isa/src/meta.rs @@ -355,9 +355,19 @@ pub fn identify(bytes: &[u8]) -> Result { } } EncodingFamily::Vop3 | EncodingFamily::Vop3Sdst | EncodingFamily::Vop3p => { - trailer.literal = [source("SRC0"), source("SRC1"), source("SRC2")] + // An attribute field (XML OPR_ATTR) is not an operand selector: in the + // VOP3 interpolation forms SRC0 holds {attr_word, attr_chan, attr} + // bit-fields (AMD RDNA 2 ISA guide, section 10.4.2), so 255 there + // does not select a literal. + trailer.literal = ["SRC0", "SRC1", "SRC2"] .into_iter() - .flatten() + .filter(|name| { + !form + .operands + .iter() + .any(|operand| operand.field == *name && operand.kind == "OPR_ATTR") + }) + .filter_map(source) .any(|value| value == SRC_LITERAL); } EncodingFamily::Mimg => { diff --git a/crates/isa/tests/llvm/corpus_disagreements.txt b/crates/isa/tests/llvm/corpus_disagreements.txt index 2ff1245..27a1773 100644 --- a/crates/isa/tests/llvm/corpus_disagreements.txt +++ b/crates/isa/tests/llvm/corpus_disagreements.txt @@ -2,11 +2,10 @@ # (neither `identified` nor `both_reject`), as `class hex`, sorted by hex. Pinned by meta_corpus.rs; # review each change against LLVM. operand_flagged 000000d60000000000000000000000000000000000000000 -mismatch 000000d6ff00000078563412000000000000000000000000 +operand_flagged 000000d6ff00000078563412000000000000000000000000 metadata_only 000000dd0000000000000000000000000000000000000000 operand_flagged 000001d60000000000000000000000000000000000000000 -mismatch 000001d6ff00000078563412000000000000000000000000 -mismatch 000002d6ff00000078563412000000000000000000000000 +operand_flagged 000001d6ff00000078563412000000000000000000000000 metadata_only 000008f10000000000000000000000000000000000000000 metadata_only 00000cf10000000000000000000000000000000000000000 metadata_only 000020dc0000000000000000000000000000000000000000 @@ -21,9 +20,9 @@ metadata_only 000038dc0000000000000000000000000000000000000000 metadata_only 00003cdc0000000000000000000000000000000000000000 metadata_only 000040dd0000000000000000000000000000000000000000 operand_flagged 000042d70000000000000000000000000000000000000000 -mismatch 000042d7ff00000078563412000000000000000000000000 +operand_flagged 000042d7ff00000078563412000000000000000000000000 operand_flagged 000043d70000000000000000000000000000000000000000 -mismatch 000043d7ff00000078563412000000000000000000000000 +operand_flagged 000043d7ff00000078563412000000000000000000000000 metadata_only 000044dd0000000000000000000000000000000000000000 metadata_only 000048dd0000000000000000000000000000000000000000 metadata_only 000048f10000000000000000000000000000000000000000 @@ -32,7 +31,7 @@ metadata_only 00004cf10000000000000000000000000000000000000000 metadata_only 000054dd0000000000000000000000000000000000000000 metadata_only 000058dd0000000000000000000000000000000000000000 operand_flagged 00005ad70000000000000000000000000000000000000000 -mismatch 00005ad7ff00000078563412000000000000000000000000 +operand_flagged 00005ad7ff00000078563412000000000000000000000000 metadata_only 00005cdd0000000000000000000000000000000000000000 operand_flagged 000060d70000000000000000000000000000000000000000 metadata_only 000060d80000000000000000000000000000000000000000 diff --git a/crates/isa/tests/meta.rs b/crates/isa/tests/meta.rs index 0c70237..99060d2 100644 --- a/crates/isa/tests/meta.rs +++ b/crates/isa/tests/meta.rs @@ -99,6 +99,32 @@ fn literal_sdwa_and_dpp_words_extend_the_length() { ); } +#[test] +fn vop3_interpolation_attribute_fields_never_select_a_literal() { + // AMD RDNA 2 ISA guide section 10.4.2: in the VOP3 interpolation forms SRC0 + // holds {attr_word, attr_chan, attr} bit-fields (XML OPR_ATTR), so SRC0 = 255 + // is attr 63, channel w (and attr_word 0) and the instruction is 8 bytes. + // LLVM 23.1.6 agrees (#235). + for (first, name) in [ + (0xd600_0000, "V_INTERP_P1_F32"), + (0xd601_0000, "V_INTERP_P2_F32"), + (0xd602_0000, "V_INTERP_MOV_F32"), + (0xd742_0000, "V_INTERP_P1LL_F16"), + (0xd743_0000, "V_INTERP_P1LV_F16"), + (0xd75a_0000, "V_INTERP_P2_F16"), + ] { + let found = identify(&words(&[first, 0x0000_00ff, 0x1234_5678])).unwrap(); + assert_eq!((found.form.name, found.len), (name, 8)); + assert!(!found.trailer.literal, "{name}"); + } + // A general VOP3 source with the same selector still takes the literal. + let add = identify(&words(&[0xd503_0000, 0x0000_00ff, 0x1234_5678])).unwrap(); + assert_eq!((add.form.name, add.len), ("V_ADD_F32", 12)); + // So does a VGPR-only source (LLVM reports these 12 bytes with an invalid operand). + let permlane = identify(&words(&[0xd777_0000, 0x0000_00ff, 0x1234_5678])).unwrap(); + assert_eq!((permlane.form.name, permlane.len), ("V_PERMLANE16_B32", 12)); +} + #[test] fn truncated_and_unassigned_inputs_are_rejected() { assert_eq!(identify(&[]), Err(IdentifyError::Truncated { needed: 4 })); diff --git a/crates/isa/tests/meta_corpus.rs b/crates/isa/tests/meta_corpus.rs index b20dc25..9810701 100644 --- a/crates/isa/tests/meta_corpus.rs +++ b/crates/isa/tests/meta_corpus.rs @@ -175,7 +175,7 @@ fn digest(lines: &[String]) -> u64 { const COUNTS: [[usize; 9]; 5] = [ [317, 0, 0, 0, 0, 0, 0, 0, 0], // asm [1365, 0, 0, 82, 0, 0, 0, 0, 18], // probe-zero - [1397, 6, 21, 0, 752, 0, 0, 0, 3], // probe-ext + [1398, 0, 21, 0, 752, 0, 0, 0, 8], // probe-ext [1236, 0, 0, 1678, 3, 2, 0, 0, 11], // probe-random [0, 0, 0, 0, 0, 0, 87, 0, 0], // truncation ];