Skip to content

Translator: s_flbit_i32_b64 and s_flbit_i32_i64 - #733

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
LouisRiverstone:salu-flbit-64
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
LouisRiverstone:salu-flbit-64

Conversation

@LouisRiverstone

Copy link
Copy Markdown
Contributor

tools/rdna2spirv.py raises Unsupported on s_flbit_i32_b64 and s_flbit_i32_i64, the 64-bit leading-bit counts. They aren't in the translated corpus, so this is future-proofing. Claimed in #374.

Change

  • tools/rdna2spirv.py: both count from bit 63 down. SCC is not written.
    • s_flbit_i32_b64 counts the 0 bits before the first 1: 31 − FindUMsb(hi) when the high half isn't 0, else 63 − FindUMsb(lo), and −1 when S0 is 0.
    • s_flbit_i32_i64 counts the bits before the first one that differs from the sign bit, like v_ffbh_i32 / s_flbit_i32 in 64 bits. It's the b64 count of ~S0 when S0 is negative, and −1 for 0 and −1.
    • The pair is 64-bit data, as for s_lshl_b64. A source that lane_masks.py marks as a lane mask stays Unsupported (Translator: wave64 lane masks used as integers read back as per-lane bools; wave64 inferred from mnemonics #210). S0 can also be a 64-bit inline constant.
  • tests/semantic/test_salu_flbit_64.py (new, stdlib unittest) checks against a plain-Python reference:
    • 14 edge pairs: 0, ±1, the sign bit alone, the half boundaries and −2
    • SCC kept from 0 and 1
    • 30 seeded cases with long runs of leading zeros or ones
    • inline sources
    • exec rejected
    • D leaves exp as 16-bit halves ORed into 0x40000000, so no export channel can be a NaN pattern.

Tested

  • python -I -m unittest discover -s tests/semantic: all pass. Without the translator change, the new file has errors (Unsupported).
  • python -m compileall -q tools tests passes. Not run on a GPU, and no game files used.

AI-assisted (Claude Code): it wrote the change and the tests, and ran the checks listed above.

Both raised Unsupported. b64 counts the 0 bits above the top 1 of the 64-bit
S0; i64 does the same for ~S0 when S0 is negative (the bits before the first
one that differs from the sign); -1 when there is none. SCC is not written.
Built from FindUMsb of each half. The pair is 64-bit data, as for
s_lshl_b64; a lane-mask source stays Unsupported (ItsNotRexed#210).

tests/semantic/test_salu_flbit_64.py checks both against a plain-Python
reference.
main pins 48557ea again since the ItsNotRexed#666-ItsNotRexed#698 merge round, while
tools/rpf9dump/Program.cs (3816356) already uses ArchiveEntry.ResourceDrawableOffset
from 917e9b9, so the Windows 'check' job fails to compile rpf9dump on every
PR. Same one-line change as ItsNotRexed#713 / ItsNotRexed#732; whichever lands first, this merges
cleanly.
@LouisRiverstone

Copy link
Copy Markdown
Contributor Author

CI note: the Windows check job failed here because main pins third_party/rpf9-explorer at 48557ea again since the #666–#698 merge round, while tools/rpf9dump/Program.cs (3816356) already uses ArchiveEntry.ResourceDrawableOffset from 917e9b9, so rpf9dump does not compile on any PR. I added the same one-line re-pin to 917e9b9 that #713 / #732 make (a separate commit, nothing else in it), so this PR gets a clean run; whichever lands first, the other merges cleanly.

@ItsNotRexed
ItsNotRexed merged commit 91d05cf into ItsNotRexed:main Nov 22, 2026
9 checks passed
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