Skip to content

rdna2_decode: support GFX10.1 v_mul_lo_i32 - #3

Open
tahffo68hk-hash wants to merge 7 commits into
bobcatchris:fix/decoder-vop3-140-targetfrom
tahffo68hk-hash:fix/python-vop3-16b
Open

tahffo68hk-hash wants to merge 7 commits into
bobcatchris:fix/decoder-vop3-140-targetfrom
tahffo68hk-hash:fix/python-vop3-16b

Conversation

@tahffo68hk-hash

Copy link
Copy Markdown

Summary

Add the missing VOP3 0x16b operand entry. The Python decoder reuses the target passed through by ProjectLeonida#4928. GFX10.1 (gfx1010–gfx1013) decodes v_mul_lo_i32 with one VGPR destination and two sources. GFX10.3 (gfx1030–gfx1036) rejects the encoding and skips all of its words, including a literal when present. Synthetic regressions also check the adjacent 0x169, 0x16a, and 0x16c opcodes.

Tests

  • python -I tests/test_rdna2_decode.py -k vop3 -v reproduced missing GFX10.1 decoding and a literal interpreted as an instruction on GFX10.3 before the fix. Both regressions pass with the patch.
  • python -I tests/test_rdna2_decode.py -v — 13 passed, 1 skipped (local llvm-mc unavailable).
  • python -I tests/test_shader_disasm.py -v — 22 passed.
  • python -I tests/test_rdna2spirv_decode.py -v — 24 passed.
  • python -I tests/test_rdna2spirv_merge.py -v — 26 passed.
  • python -m compileall -q make_game.py tools tests and git diff --check — passed.

LLVM 21’s AMDGPU opcode definitions confirm 0x16b under isGFX10Before1030. Validation was CPU-only.

AI-assisted. Synthetic fixtures only.

概述

补上缺失的 VOP3 0x16b 操作数条目。Python 解码器复用 ProjectLeonida#4928 传入的目标架构。GFX10.1(gfx1010–gfx1013)将其解码为 v_mul_lo_i32,解析一个 VGPR 目标和两个源操作数。GFX10.3(gfx1030–gfx1036)会拒绝该编码并跳过它的所有字,包括存在的字面量。合成回归测试还检查了相邻的 0x169、0x16a 和 0x16c 操作码。

测试

  • python -I tests/test_rdna2_decode.py -k vop3 -v 在修复前复现了 GFX10.1 解码缺失及 GFX10.3 把字面量误当成指令的问题。两个回归用例在补丁上均通过。
  • python -I tests/test_rdna2_decode.py -v — 13 项通过,1 项跳过(本机缺少 llvm-mc)。
  • python -I tests/test_shader_disasm.py -v — 22 项通过。
  • python -I tests/test_rdna2spirv_decode.py -v — 24 项通过。
  • python -I tests/test_rdna2spirv_merge.py -v — 26 项通过。
  • python -m compileall -q make_game.py tools tests 和 git diff --check 均通过。

LLVM 21 的 AMDGPU 操作码定义 确认 0x16b 受 isGFX10Before1030 限制。本轮验证只在 CPU 上运行。

AI-assisted(AI 辅助)。Synthetic fixtures only(仅使用合成测试输入)。

bobcatchris and others added 5 commits November 23, 2026 00:33
The decoder's tables carry the GFX10.3 names, but one encoding has two names
depending on the target: GFX10.1 (the console, gfx1013) spells the legacy
multiply-accumulate ops without the fused prefix. llvm-mc prints
v_mac_legacy_f32 where the tables say v_fmac_legacy_f32 (VOP2 0x06, VOP3 0x106)
and v_mad_legacy_f32 where they say v_fma_legacy_f32 (VOP3 0x140). Thread the
target through decode_bytes() and disasm_bytes() (default gfx1013), name those
three opcodes per target, and pass shader_disasm's --mcpu to its Python backend.
The new target parameter accepted anything: `--backend python --mcpu gfx1100`
(the Python tools need no llvm-mc, so nothing else rejected it) decoded RDNA2
tables and reported the shader "clean", with the GFX10.3 opcode names for a
GFX11 target. decode_bytes() now raises for a target outside gfx101*/gfx103*,
and the CLI stops with exit 2 before it reads a shader.
`gfx101`/`gfx103` prefixes let near-misses through, and llvm-mc accepts
gfx1014 and gfx1037 as CPU names without complaint, so nothing else rejects
them either: `--backend python --mcpu gfx1037` exited 0 on main and would still
have been accepted with a prefix. The guard now lists the parts the tables
describe (gfx1010-1013, gfx1030-1036) and names them in the error.
A listing is only reusable for the target it was written for, but the check
was "non-empty file", so `--mcpu gfx1030 --skip-existing` kept a listing
disassembled as gfx1013 and reported it as reused, even though opcode 0x140 has
a different mnemonic there. Match the target recorded in the listing header.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8f1b3c8b-7f60-43a5-a836-e6af44318b89

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

The current parent and the unchanged v_mul_lo_i32 patch supply the resulting tree. Keep the prior published head as ancestry so the fork update can fast-forward.
@tahffo68hk-hash

Copy link
Copy Markdown
Author

I updated this patch for the rebased parent at 1d16b2a8. GitHub now reports that the original PR is mergeable, and its file diff still contains only the three files for GFX10.1 v_mul_lo_i32. The update to my fork was a fast-forward. Windows CPU checks passed: decoder 19 passed with one optional LLVM parity skip, disassembly CLI 31 passed, translator decode integration 26 passed. Synthetic fixtures only, AI-assisted.

我已将该补丁同步到重基后的父分支 1d16b2a8。GitHub 现已显示原 PR 可合并,文件差异仍只有 GFX10.1 v_mul_lo_i32 所需的三个文件。此次对我 fork 的推送是快进更新。Windows CPU 验证中,解码器 19 项通过、1 项可选 LLVM 对照跳过,反汇编 CLI 31 项通过,翻译器解码集成 26 项通过。仅用合成输入,AI 辅助。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants