Commit Graph

26 Commits

Author SHA1 Message Date
c37e311384 Merge main into #278: keep both new decode tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-12-01 23:13:03 +01:00
aa0687837f Merge remote-tracking branch 'upstream/main' into fix/decode-ds-llvm-parity 2026-11-30 14:04:40 +00:00
79a5d7838c rdna2_decode: decode 16-bit integer inline constants 240..248 as binary16 hex (DECODE-VOP16-INT-INLINE) 2026-11-28 09:13:33 +00:00
b7f1371c05 rdna2_decode: align DS single-offset and ds_swizzle_b32 ROTATE/FFT formatting with LLVM
Fixes all 19 remaining mismatches against LLVM 21.1.8 gfx10_ds.txt (1,708/1,708
decoded vectors exact):
- ds_condxchg32_rtn_b64 (6 vectors): checking '2_ in name' falsely matched
  '32_', printing offset0/offset1 instead of a single 16-bit offset. Restrict
  2-address detection to ds_read2 / ds_write2 / ds_wrxchg2 prefixes.
- ds_swizzle_b32 (13 vectors): match LLVM AMDGPUInstPrinter::printSwizzle by
  omitting offset: when offset16 == 0, printing offset:swizzle(ROTATE,dir,size)
  for 0xC000..0xDFFF, and printing offset:swizzle(FFT,mask) for 0xE000..0xFFFF.
2026-11-28 09:12:40 +00:00
0079b5ddff Merge pull request #637 from jarvixaiassistant-glitch/fix/decode-mac-legacy-target
rdna2_decode: decode VOP2 0x06 and VOP3 0x106 as v_mac_legacy_f32 on gfx101* (DECODE-MAC-LEGACY-TARGET)
2026-11-25 22:22:03 +01:00
2bfcb4fe71 Merge pull request #633 from jarvixaiassistant-glitch/fix/decode-mimg-llvm-parity
rdna2_decode: align MIMG addr, atomic TFE/cmpswap, and r128 widths with LLVM (DECODE-MIMG-PARITY)
2026-11-25 22:21:14 +01:00
b71c0a61b8 rdna2_isa_tables: add gfx1013 VOP3 0x16b v_mul_lo_i32 (BUILD-1529) 2026-11-25 12:30:57 +05:00
cec2c7074c tests: GPU readback for 38 scalar ALU ops on run-time operands (GPU-SALU-EXT)
No fixture in runtime/test/shaders ran s_sub_i32, s_andn2_b32, s_orn2_b32, s_xor_b32, s_ashr_i32, s_mul_hi_u32,
s_lshl3_add_u32, s_lshl4_add_u32, s_pack_ll_b32_b16, s_pack_hh_b32_b16, s_abs_i32, s_bcnt0_i32_b32, s_bitset0_b32,
s_bitset1_b32, s_brev_b32, s_flbit_i32, s_flbit_i32_b32, s_sext_i32_i8, the six s_cmp_*_i32, s_cmp_gt_u32,
s_cmp_le_u32, s_bitcmp0_b32, s_bitcmp1_b32, s_addk_i32, s_mulk_i32, s_cmovk_i32, s_ashr_i64, s_lshl_b64, s_lshr_b64,
s_bcnt0_i32_b64, s_bitset0_b64, s_cmov_b64 or s_ff0_i32_b64.

cs_w32_salu_ext gets sixteen operand words in s4..s19 from VKC_SGPRS, so each op reaches the driver as SPIR-V and
is not folded by the translator as an op on literals is. One thread stores every destination and four words of SCC
bits: SCC after each op that writes it, run on operands that set it and on operands that clear it, each compare
both ways, and SCC after each op that must keep it, set to 1 and to 0 in turn before them.

The 73 expected words are literals in check.py, derived in the fixture's header. tests/test_gpu_salu_ext.py
recomputes them from the fixture's own instruction lines with the reference of tools/salu_diff.py, checks that
every op that writes SCC is seen with both values, and checks the readback and both runners' verdicts.

The fixture is the first in the folder with bit 15 set in the immediate of a signed SOPK op (s_addk_i32 s52,
0x8000). tools/rdna2_decode.py gives that immediate sign-extended and llvm-mc 23.1.4 prints the same word as
0x8000, so test_parity_with_llvm_mc_on_shader_fixtures failed on it. That test now compares the immediates of the
ten signed SOPK ops as the 16 bits they are, as it already does for SOPP branch offsets, and a hand-encoded test
pins which of the sixteen ops the decoder sign-extends.

No translator, decoder or runtime change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 12:40:29 -06:00
2da938a92c rdna2_decode: decode VOP2 0x06 and VOP3 0x106 as v_mac_legacy_f32 on gfx101*
tools/rdna2_decode.py already renamed VOP3 0x140 from v_fma_legacy_f32 to
v_mad_legacy_f32 when mcpu starts with gfx101, but left VOP2 0x06 and VOP3
0x106 unconditionally named v_fmac_legacy_f32 even for the default gfx1013
console target.

Per LLVM 21 VOP2Instructions.td and docs/design.md, VOP2 0x06 and VOP3 0x106
are v_mac_legacy_f32 on gfx101* (translated by rdna2spirv.py) and
v_fmac_legacy_f32 on gfx103* (intentionally rejected as Unsupported).
Decoding them as v_fmac_legacy_f32 on gfx1013 broke end-to-end python
disassembly -> rdna2spirv translation and caused 56 mismatches across LLVM's
gfx10_vop2.txt (18) and gfx10_vop3.txt (38).

Rename VOP2 0x06 and VOP3 0x106 to v_mac_legacy_f32 on gfx101* and add unit
plus end-to-end gfx1013 (translates and evaluates to 8.0) and gfx1030
(rejected as Unsupported) tests in tests/test_rdna2_decode.py.

AI-assisted: yes (JARVIX: Antigravity + DeepSeek V4 Flash + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B).
2026-11-24 10:39:58 +00:00
450cd81054 rdna2_decode: align MIMG addr, atomic TFE/cmpswap, and r128 widths with LLVM
Cross-checking tools/rdna2_decode.py against all 291 GFX10/GFX1030 image_*
vectors in LLVM's disassembler suite (gfx10_mimg.txt, gfx10_mimg_features.txt,
gfx1030_new.txt) found 72 mismatches across three areas:

1. _mimg_addr_count():
   - Handle a16 on image_bvh_intersect_ray (8 VGPRs) and
     image_bvh64_intersect_ray (9 VGPRs), and on image_get_lod.
   - Stop substring-matching _l inside image_msaa_load, _b inside
     image_{load,store}_by{2,4}, and _c/_d inside image_sample_*cd*.
   - Include the mip VGPR for all *_mip* load/store variants
     (image_load_mip_pck, image_load_mip_pck_sgn, image_store_mip_pck, etc.).
   - Parse sample/gather modifiers as underscore-delimited tokens so _cl and
     _o before _g16 are seen, and pack _g16 gradients as alignTo<2>(grad_coords)
     matching LLVM AMDGPU::getAddrSizeMIMGOp.
   - Pack (coords + lod/cl/mip) under a16 as (packable + 1) // 2 so odd-coord
     dims (1D/3D/2D_ARRAY/CUBE) do not overcount by 1 VGPR.
2. _mimg_data_count():
   - Add +1 VGPR for tfe on image_atomic_* instead of returning early.
   - Return 2 VGPRs for image_atomic_{f,}cmpswap with dmask:0x1 (LLVM has no
     1-VGPR cmpswap variant).
3. MIMG rsrc_w:
   - Keep 8 SGPRs (SReg_256_XNULL) for non-BVH MIMG instructions even with
     r128; only image_bvh*_intersect_ray use 4 SGPRs (SReg_128_XNULL).

All 291/291 LLVM GFX10/GFX1030 MIMG vectors now decode with 0 mismatches.

AI-assisted: yes (JARVIX: Antigravity + DeepSeek V4 Flash + NVIDIA NIM Nemotron-3.5-Lightning & Nemotron-3-Ultra-550B).
2026-11-24 10:29:17 +00:00
86da7be469 rdna2_decode: permlane16 op_sel and the exp null target match llvm-mc and shader_ir (DECODE-LLVM-PARITY)
test_parity_with_llvm_mc_on_shader_fixtures fails with llvm-mc 21.1.8
on two fixtures. CI does not see it: the jobs that run this file have
no llvm-mc, so the test skips.

- v_permlane16_b32 and v_permlanex16_b32 use op_sel bits 0 and 1 as FI
  and BOUND_CTRL. llvm-mc prints op_sel:[FI,BOUND_CTRL], and nothing
  when both are 0, whatever bits 2 and 3 hold. The decoder printed the
  generic [s0,s1,s2,dst] list (cs_w32_permlane_fi.asm).
- shader_ir.parse_line reads the `null` export target as the special
  register. decode_bytes gave it as a target, so a decoded `exp null`
  did not equal its own printed line parsed back (ps_w64_a_discard.asm).

Two unit tests pin both with hand-assembled words, so they run without
llvm-mc too.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 15:58:38 +08:00
c932457840 rdna2spirv: recover native SDWA inline float from LLVM 19 listings
LLVM 19 prints an 8-byte integer-to-half SDWA conversion as a 12-byte instruction with an extra literal dword. Recover the native source and byte length when the opcode, selector, other bytes and printed literal agree, and keep following instruction offsets correct.

Carried from the source-only patch by Sigtryggur-Mani-Gudmundsson:
b17a81c3d9/tests/sdwa-inline

AI-assisted.
2026-11-23 23:45:05 -06:00
b35a82662e rdna2_decode: fix SCRATCH vaddr off and direct-to-LDS VDST omission 2026-11-23 16:19:46 -05:00
abb7f4401c rdna2_decode: s_ttracedata_imm keeps its SIMM16 operand (#6795)
Squash-merged after diff review of PR #6795 - rdna2_decode: s_ttracedata_imm keeps its SIMM16 operand
2026-11-23 09:54:38 -06:00
891358bbea Stream Python shader text disassembly to lower peak memory (#4943)
Squash-merged after review of PR #4943 - Stream Python shader text disassembly to lower peak memory
2026-11-23 08:11:04 -06:00
c4d495c010 Integrate decoder fixes and retain exhaustive SDWA operand coverage 2026-11-22 23:10:57 +01:00
dfcbd362bc Decode VOP3 legacy MAD/FMA according to the shader target 2026-11-22 23:05:56 +01:00
3ccfe33a7b Decode MIMG atomic data register width from dmask 2026-11-22 23:05:45 +01:00
53e6e5c130 Read the MIMG SLC bit independently of the sampler operand 2026-11-22 23:05:45 +01:00
f843b8f8be Decode mixed-precision FMA sign modifiers on their source operands 2026-11-22 23:05:45 +01:00
998128ec7c rdna2_decode: decode SDWA scalar inline constants via _src()
When an SDWA VOP1/VOPC/VOP2 instruction sets the scalar-source bit
(s0_is_sgpr / s1_is_sgpr), the 8-bit source field encodes the full
scalar operand space (SGPRs 0..105, specials 106..127, inline integer
constants 128..208, inline float constants 240..248, etc.), not only
registers 0..127.

Use _src(..., 1, None) instead of _sreg(..., 1) across all three SDWA
decoders (VOP1, VOPC, VOP2) so inline constants such as 1.0 (242) and
2.0 (244) in runtime/test/shaders/ps_sdwa_f16_const.asm decode as fimm
instead of raw sreg_242. Add regression test covering VOP1/VOPC/VOP2
SDWA inline float/int constants and SGPR sources.
2026-11-22 22:07:06 +01:00
e4a2233a5d rdna2_decode: decode SOPP branch offsets as signed 16-bit and format negatives as decimal
Addresses review feedback on PR #2038 (@borislisandro):
- Sign-extend SOPP branch simm16 offsets with _s16(simm16) so backward branches decode
  as negative integers (e.g. -4, -20) matching shader_ir/llvm-mc 21/22 instead of 0xfffc.
- Format negative immediates (< 0) as decimal rather than broken '0x-...' hex.
- Clarify module docstring (shader_ir-compatible .s text) and update unit tests
  (normalizing SOPP branch immediates mod 16-bit for LLVM 18 vs 21/22 parity).
2026-11-22 21:23:34 +01:00
1ca544a30e rdna2_decode: pure-Python RDNA2 binary ISA decoder (#1901) 2026-11-22 21:23:34 +01:00
9e069b02bf Decode inline constants in SDWA scalar source slots 2026-11-22 21:11:10 +01:00
4da88513aa rdna2_decode: decode SOPP branch offsets as signed 16-bit and format negatives as decimal
Addresses review feedback on PR #2038 (@borislisandro):
- Sign-extend SOPP branch simm16 offsets with _s16(simm16) so backward branches decode
  as negative integers (e.g. -4, -20) matching shader_ir/llvm-mc 21/22 instead of 0xfffc.
- Format negative immediates (< 0) as decimal rather than broken '0x-...' hex.
- Clarify module docstring (shader_ir-compatible .s text) and update unit tests
  (normalizing SOPP branch immediates mod 16-bit for LLVM 18 vs 21/22 parity).
2026-11-22 19:12:05 +01:00
29fecf1b01 rdna2_decode: pure-Python RDNA2 binary ISA decoder (#1901) 2026-11-22 19:11:13 +01:00