The VOP1/VOP3 op saturates each signed i16 half of SRC0 to unsigned
8-bit and packs the pair into the low 16 bits of VDST, preserving the
high half (GFX9+ partial write; LLVM VOP1Inst_t16, Mesa ACO
instr_is_16bit). Neg/abs/clamp/omod are refused; _sdwa restricts to the
documented source/destination selects; _e32 rejects all modifiers.
Adds a hand-written fixture and a semantic test driving the SPIR-V
through spirv_mini_interp against a plain-Python reference (lane edge
values, SGPR/literal sources, sdwa selects, refused modifiers), the
docs/design.md contract row, and drops the op from the
fssm_crosscheck unhandled list. The two tests that used the mnemonic
as the still-unsupported canary now use v_mullit_f32.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
v_mqsad_u32_u8 raised Unsupported. Four masked byte-SADs with full 32-bit
accumulators (RDNA ISA pseudocode): D[k] = S2[k] + v_msad_u8 of S0's 32-bit
window at byte k against S1. S0 is a 64-bit pair, S2 and D four VGPRs.
clamp is rejected.
tests/semantic/test_alu_mqsad_u32.py checks it against a plain-Python
reference. test_translate.py and test_f16_op_sel.py used it as their example
of an unsupported instruction; they now use v_sat_pk_u8_i16.
All five raised Unsupported. They add the sum of absolute differences of the
sources' bytes / halves / words to S2 (unsigned, wrapping at 32 bits), as in
the RDNA ISA pseudocode; v_sad_hi_u8 shifts the byte sum left by 16 and
v_msad_u8 skips the bytes where S1's byte is 0. clamp is rejected, not
guessed.
tests/semantic/test_alu_sad.py checks all five against a plain-Python
reference. test_translate.py and test_f16_op_sel.py used v_sad_u8 as their
example of an unsupported instruction; they now use v_mqsad_u32_u8.
v_subrev_f16 (VOP2 0x34 on GFX10) raised Unsupported. Translate it with the
other f16 VOP2/VOP3 ops, swapping the two operands of the subtraction: op_sel
still names src0/src1 and the destination half, neg/abs/clamp apply as for
v_sub_f16, and the half that is not written is kept.
Tests: tests/semantic/test_alu_subrev_f16.py (VOP2 and VOP3 forms, every
op_sel combination, neg and clamp, and a seeded comparison with v_sub_f16 on
swapped operands), plus v_subrev_f16 rows in the f16 op_sel tables.
tests/spirv_interp.py runs the straight-line, single-lane SPIR-V the translator
emits for branch-free shaders (binary32 rounding after every op, GLSL.std.450
subset, Function/Output variables). Unknown opcodes raise NotImplementedError.
- test_values.py: 49 value checks over the supported instruction families, with
references written in plain Python from the ISA definitions.
- test_f16_op_sel_values.py: 84 value checks for op_sel on f16 VOP3 ops (all
select combinations, neg/abs/clamp, fmac).
- listing.py: hand-written listing helper. shader_ir.parse_file treats the first
line of a listing as its header, so the helper writes one; test_f16_op_sel.py
used to lose its first instruction and now uses the helper.
None of these need llvm-mc or spirv-tools. Mutation-checked: breaking the
op_sel source index or the destination merge makes them fail.
v_fma_f16, v_med3_f16, v_add/sub/mul/max/min_f16, the f16 unary ops and v_fmac_f16
used to raise Unsupported when op_sel was present. Source bit i now reads the high
half of source i and the last bit writes the high half of the destination, the
other half being kept (Mesa ACO can_use_opsel, RDNA2 ISA VOP3 OP_SEL).
The f16 read/write sequences move into f16_in/f16_out/opsel_bits. Output without
op_sel is unchanged apart from SSA numbering.
Tests: tests/test_f16_op_sel.py uses hand-written listings (no llvm-mc needed).