mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
isa: VOP3 interpolation attribute fields never select a literal
identify() treated SRC0 = 255 as the literal selector in every VOP3 form
with the LITERAL extension, so six interpolation forms (v_interp_p1_f32,
v_interp_p2_f32, v_interp_mov_f32 in VOP3, v_interp_p1ll_f16,
v_interp_p1lv_f16, v_interp_p2_f16) were read as 12 bytes. In these
forms SRC0 is not an operand selector: the RDNA 2 ISA guide, section
10.4.2, says SRC0 "is treated as a set of bit-fields" {attr_word,
attr_chan, attr}, and the XML gives its operand type as OPR_ATTR. LLVM
23.1.6 decodes all six as 8 bytes.
Fields typed OPR_ATTR are now skipped when looking for a literal. VGPR-
only sources are unchanged: LLVM still reads v_permlane16_b32 and
v_movrels_b32 with selector 255 as 12 bytes (invalid operand), and the
new test pins that too. The corpus check's six pinned mismatch rows
are gone: v_interp_mov_f32 now agrees fully and the other five are
operand_flagged (same form and length, LLVM flags the operand).
The new test fails on the old rule.
Fixes #235
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
This commit is contained in:
1 parent
0e7fa4aa93
commit
2ddd2a2485
5 files changed
+45
-9
No files matched your search
@@ -65,6 +65,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.
|
||||
|
||||
+12
-2
@@ -355,9 +355,19 @@ pub fn identify(bytes: &[u8]) -> Result<Identified, IdentifyError> {
|
||||
}
|
||||
}
|
||||
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 => {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }));
|
||||
|
||||
@@ -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
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user