Skip to content

Improve PSP VFPU instruction parsing & add tests#255

Open
tclamb wants to merge 2 commits into
Kingcom:masterfrom
tclamb:master
Open

Improve PSP VFPU instruction parsing & add tests#255
tclamb wants to merge 2 commits into
Kingcom:masterfrom
tclamb:master

Conversation

@tclamb

@tclamb tclamb commented Jun 25, 2026

Copy link
Copy Markdown

I ran into a few issues with VFPU functions while iterating on mods. It seems like tokenizer changes may have broken a few of these instructions at some point? This commit fixes some discrepancies I found with the pspdev vfpu documentation, aligns prefix syntax with binutils/MWCC, and adds tests to prevent future regressions.

  • reworked vfim.s to accept float & int literals (previously took integer representations of IEEE754 float32s, e.g. 0x3f800000 for 1.0)
  • removed support for the invalid vsbn.{p,t,q} instructions
  • fixed vt size for vscl.{p,t,q} (is always scalar, regardless of vs & vd)
  • fixed vd size for the various pack/unpack instructions
  • renamed vuc2i.s to vuc2ifs.s
  • fixed various issues with vpfx{s,t,d} parsing
    • the sequence parser is greedy, so 1 would match before fractions like 1/3 (fixed)
    • numeric literals were not matched at all since the parser only expected identifier tokens (fixed)
    • requiring the operands to be wrapped with [/] breaks compatibility with other tooling (removed)
    • m is a write mask operand that prevents writing to a certain destination slot, not a modifier on a saturation operation (fixed)
    • 0-1/-1-1 syntax for the vpfxd saturation operations [0:1]/[-1:1] is not supported elsewhere, and the unbracketed 0:1/-1:1 syntax is not supported by MWCC (removed)
  • fixed 0 support in vrot.{p,t,q} (had expected an identifier token, not an integer)

I used MWCC to generate expected output for the added/modified tests.

@Kingcom

Kingcom commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Thanks a lot! This looks very nice. The original implementation of those instructions definitely didn't get enough testing... I think I mostly tried to copy what I saw in PPSSPP at the time.

Just one small thing, can you add a quick note at the top of the changelog in the Readme summarizing the breaking changes, maybe with a link to the documentation? Under a Current Development Version header or something like that.

tclamb added 2 commits June 29, 2026 17:35
- reworked `vfim.s` to accept float & int literals (previously took integer representations of IEEE754 `float32`s, e.g. `0x3f800000` for `1.0`)
- removed support for the invalid `vsbn.{p,t,q}` instructions
- fixed `vt` size for `vscl.{p,t,q}` (is always scalar, regardless of `vs` & `vd`)
- fixed `vd` size for the various pack/unpack instructions
- renamed `vuc2i.s` to `vuc2ifs.s`
- fixed various issues with `vpfx{s,t,d}` parsing
  - the sequence parser is greedy, so `1` would match before fractions like `1/3` (fixed)
  - numeric literals were not matched at all since the parser only expected identifier tokens (fixed)
  - requiring the operands to be wrapped with `[`/`]` breaks compatibility with other tooling (removed)
  - `m` is a write mask operand that prevents writing to a certain destination slot, not a modifier on a saturation operation (fixed)
  - `0-1`/`-1-1` syntax for the `vpfxd` saturation operations `[0:1]`/`[-1:1]` is not supported elsewhere, and the unbracketed `0:1`/`-1:1` syntax is not supported by MWCC (removed)
  - `vpfxd` supports unmodified slots with an empty operand
- fixed `0` support in `vrot.{p,t,q}` (had expected an identifier token, not an integer)

Used MWCC to generate expected output for the added/modified tests.
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