mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 13:18:04 +02:00
pan/bi: Fix M1/M2 decoding in disassembler
C's definition of the % operator has a footgun around sign conversion. Avoid it and just use bitwise arithemtic instead like the hardware would, fixing the disassembly and making buggy assembly more obvious. Fixes:08a9e5e3e8("pan/bi: Decode M values in disasm") Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8723> (cherry picked from commita69c73988b)
This commit is contained in:
parent
26f5850810
commit
4169bef1b6
2 changed files with 10 additions and 8 deletions
|
|
@ -1093,7 +1093,7 @@
|
|||
"description": "pan/bi: Fix M1/M2 decoding in disassembler",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"master_sha": null,
|
||||
"because_sha": "08a9e5e3e892e9acc7fcfc2cefb45990efa62e40"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -614,15 +614,17 @@ static bool dump_clause(FILE *fp, uint32_t *words, unsigned *size, unsigned offs
|
|||
consts.raw[const_idx + 1] = const1;
|
||||
|
||||
/* Calculate M values from A, B and 4-bit
|
||||
* unsigned arithmetic */
|
||||
* unsigned arithmetic. Mathematically it
|
||||
* should be (A - B) % 16 but we use this
|
||||
* alternate form to avoid sign issues */
|
||||
|
||||
signed A1 = bits(words[2], 0, 4);
|
||||
signed B1 = bits(words[3], 28, 32);
|
||||
signed A2 = bits(words[1], 0, 4);
|
||||
signed B2 = bits(words[2], 28, 32);
|
||||
unsigned A1 = bits(words[2], 0, 4);
|
||||
unsigned B1 = bits(words[3], 28, 32);
|
||||
unsigned A2 = bits(words[1], 0, 4);
|
||||
unsigned B2 = bits(words[2], 28, 32);
|
||||
|
||||
unsigned M1 = (A1 - B1) % 16;
|
||||
unsigned M2 = (A2 - B2) % 16;
|
||||
unsigned M1 = (16 + A1 - B1) & 0xF;
|
||||
unsigned M2 = (16 + A2 - B2) & 0xF;
|
||||
|
||||
decode_M(&consts.mods[const_idx], M1, M2, false);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue