Repository navigation
shader: use named operand codes in gfx1013_isa.cpp and gfx1013_pixel.cpp - #3916
Conversation
Replace the nine 255 comparisons in probe_instruction with operand::literal from src/gfx1013_registers.h. They test whether a VOP1/VOP2/VOPC, SOP1, SOPC, SOP2, VOP3 or VOP3P source field selects the trailing literal dword, which adds one word to the instruction size. The file is inside namespace x2w::gfx1013, so operand:: needs no qualifier. The values and types are unchanged, so every decoded size is identical. Left as they are: the DPP and SDWA selectors 233, 234, 249 and 250 (the header has no names for them), field masks and opcodes. The five mutation anchors are on other lines.
Name the literal operand (255) and the inline integer bounds (128, 192, 193, 208) in the v_mov_b32 source decode of decode_color with the constants from src/gfx1013_registers.h. The function is a file-static outside namespace x2w, so the file aliases x2w::gfx1013. The values and types are unchanged, so the decoded colour is identical. The lines that tests/cmake/gfx1013_pixel.cmake uses as mutation anchors stay numeric: src >= 256 && vgpr[src - 256] with its body, dst = src - 128, dst = 192u - src and the float table. The 240..247 float range is also left as is.
R0Y00
left a comment
There was a problem hiding this comment.
The Linux check on 94737740 fails two source-contract checks after the operand codes were renamed:
tests/gfx1013_isa_meta_check.pystill expectssrc == 233 || src == 234 || src == 249 || src == 250 || src == 255.tests/gfx1013_pixel_meta_check.pystill expectssrc == 255.
Please update the assertions to recognize the named codes while retaining coverage of their numeric values and the literal-operand decoding paths. Both scripts should pass on the revised head.
The source-contract checks still looked for the numeric spellings that the register-name slices replaced: - gfx1013_isa_meta_check.py: the ext_src255 and vop3_literal model anchors and two contract needles now use operand::literal, the SOP1, SOPC and SOP2 literal checks are pinned too, and the header include is required. - gfx1013_pixel_meta_check.py: the literal_255 model anchor and the contract needle now use gfx1013::operand::literal; the named inline integer ranges, the include and the namespace alias are pinned. - gfx1013_compute_clear_meta_check.py: the mbcnt_hi_src model anchor uses gfx1013::operand::vgpr_base after R0Y00#3913, and the four renamed sites and the include are pinned. Each script now also reads src/gfx1013_registers.h and checks the numeric values behind the names it relies on (literal 255; zero 128, int_pos_last 192, int_neg_first 193, int_neg_last 208; sgpr_count 128, vgpr_base 256), so the encodings stay covered. The test cases, the models and the CMake mutation anchors are unchanged.
|
Thank you for the review. Fixed in
Validation
|
R0Y00
left a comment
There was a problem hiding this comment.
Re-reviewed 409fa33. The updated checks recognize the named operand codes and assert their exact original values. The decoding branches still exercise literal and inline immediates. In Ubuntu 22.04 with GCC, I ran all three scripts with python3 -B: gfx1013_isa_meta_check.py (81 cases, 13/13 mutations caught), gfx1013_pixel_meta_check.py (136 cases, 13/13), and gfx1013_compute_clear_meta_check.py (38 cases, 8/8). This addresses my Linux CI change request.
Problem
src/gfx1013_isa.cppandsrc/gfx1013_pixel.cppstill write operand codes as bare numbers: 255 for the literal operand, and 128, 192, 193 and 208 for the inline integer bounds. #3830 addedsrc/gfx1013_registers.hto keep the register code, operand and translator slot meanings apart. #3901, #3905, #3910 and #3913 convertedgfx1013_graphics_wqm.inl,gfx1013_sampled_pixel.cpp,gfx1013_vertex_id.cppandgfx1013_compute_clear.cpp.Change
This is the sixth slice. Both files are small, so they share one PR with one commit each. No behaviour change.
780298ed8replaces the nine== 255comparisons inprobe_instruction(src/gfx1013_isa.cpp, +7/-5) withoperand::literal. Each one compares an already extracted source field (VOP1/VOP2/VOPC, SOP1, SOPC, SOP2, VOP3/VOP3P) against the code that selects the trailing literal dword. The file is insidenamespace x2w::gfx1013, sooperand::needs no qualifier. The VOP3 line is wrapped because it became longer; its operands and evaluation order are unchanged.947377404names the literal and the inline integer bounds in thev_mov_b32source decode ofdecode_color(src/gfx1013_pixel.cpp, +6/-3):operand::literal,operand::zero..operand::int_pos_lastandoperand::int_neg_first..operand::int_neg_last.decode_coloris a file-static function outsidenamespace x2w, so the file addsnamespace gfx1013 = x2w::gfx1013;.constexpr unsignedwith the same values as the numbers they replace, so the decoded instruction sizes and the decoded colours are unchanged.& 255and& 511. They are bit masks, not operand codes.gfx1013_isa.cpp, the source codes233,234,249and250on the same line as the first literal comparison. The header has no constants for them, and adding some is out of scope here.gfx1013_pixel.cpp, the lines thattests/cmake/gfx1013_pixel.cmakeuses as mutation anchors:src >= 256 && vgpr[src - 256],dst = src - 128;,dst = 192u - src;and the float table. The test configuration stops if an anchor is no longer found, so these stay as they are.240..247float range. The header'soperand::float_lastis 248, so it is not a like-for-like replacement.string(REPLACE ...), five intests/cmake/gfx1013_isa.cmakeand five intests/cmake/gfx1013_pixel.cmake) target lines this change does not touch.gfx1013_registers.his header-only and already insrc.Validation
Built on Windows with MSVC, head
947377404onmaind2e6a4ed9. The targeted set passed:gfx1013_isa_alland thegfx1013_isa_*cases.gfx1013_pixel_alland thegfx1013_pixel_*cases.*_mut,WILL_FAIL) still fail as expected, so the anchors still apply:gfx1013_isa_mtbuf_bit3_mut,gfx1013_isa_mimg_nsa_mut,gfx1013_isa_vop3_fallback_mut,gfx1013_isa_vop2_madmk_mutandgfx1013_isa_flat_segment_mut;gfx1013_pixel_inline_int_mut,gfx1013_pixel_inline_neg_mut,gfx1013_pixel_inline_float_mut,gfx1013_pixel_vgpr_copy_mutandgfx1013_pixel_endpgm_trailing_mut.mesh57_integer_alu, which also compilesgfx1013_isa.cpp.native_translator_corpus_dxilandnative_translator_corpus_ir.Translator corpus: the TSV built from
maind2e6a4ed9and the TSV built from this branch have the same SHA-256, so they are byte-identical.Each replaced site was also read a second time against the header to confirm the same value and meaning, and that the pixel inline integer ranges are unchanged.
Other open PRs
No open PR edits
gfx1013_isa.cpporgfx1013_pixel.cpp. Thegfx1013_direct_*.inlfrontends are still edited by many open PRs, so they will follow once that work lands.