panfrost: Verify and print brx condition in disasm
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 18 Feb 2019 04:29:20 +0000 (04:29 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 21 Feb 2019 07:09:06 +0000 (07:09 +0000)
The condition code in extended branches is repeated 8 times for unclear
reasons; accordingly, the code would be disassembled as "unknown5555",
"unknownAAAA", etc. This patch correctly masks off the lower two bits to
find the true code to print, verifying that the code is repeated as
believed to be necessary (providing some assurance for compiler quality
and an assert trip in case we encounter a shader in the wild that breaks
the convention).

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/midgard/disassemble.c

index 7e5c5803f75da61fbb5294bb5d8d1282d19d5ffc..66d32d942c4f47c80a29ceaeb3e9fe468a5ba6da 100644 (file)
@@ -478,7 +478,16 @@ print_extended_branch_writeout_field(uint8_t *words)
         printf("brx.");
 
         print_branch_op(br.op);
-        print_branch_cond(br.cond);
+
+        /* Condition repeated 8 times in all known cases. Check this. */
+
+        unsigned cond = br.cond & 0x3;
+
+        for (unsigned i = 0; i < 16; i += 2) {
+                assert(((br.cond >> i) & 0x3) == cond);
+        }
+
+        print_branch_cond(cond);
 
         if (br.unknown)
                 printf(".unknown%d", br.unknown);