Commit Graph

24 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
ad7c62edbd Merge pull request #1524 from jarvixaiassistant-glitch/fix/decode-ds-llvm-parity
rdna2_decode: align DS single-offset and ds_swizzle_b32 ROTATE/FFT formatting with LLVM (DECODE-DS-PARITY)
2026-12-01 09:39:30 +01:00
ed699ed767 rdna2_decode: name source operand 239 src_pops_exiting_wave_id, as llvm-mc does
The carry's new fixture ps_pops_wait_loop.asm reads it (s_add_i32), and
test_parity_with_llvm_mc_on_shader_fixtures failed where llvm-mc is installed:
the decoder gave raw src_239. rdna2spirv and shader_ir already expect the special name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 16:07:32 +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
d046559435 rdna2spirv, shader_disasm: VOPC compares in DPP form (SHADER-VOPC-DPP)
Three pipeline-library compute programs of 1.0.2.1 hold v_cmp_gt_f32 with a
DPP16 or DPP8 src0. llvm-mc has no gfx10 decoding for the pair, so the
listing dropped the words and the programs were refused.

shader_disasm.py prints the pair through a VOP2 stand-in that takes the same
DPP word, rdna2_decode.py decodes it directly, and Gen.dpp_insn translates
the compare for the forms where every lane writes its bit. Other forms and
v_cmpx are refused: what an unwritten lane does to VCC is not measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 23:41:08 +08: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
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
552a4c9779 rdna2spirv: support biased image_sample_*_b variants in non-PS stages (#6834)
Squash-merged after diff review of PR #6834 - rdna2spirv: support biased image_sample_*_b variants in non-PS stages
2026-11-23 09:54:29 -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
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