panfrost/midgard/disasm: Check for certain tag errors
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 19 Jul 2019 18:02:56 +0000 (11:02 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 22 Jul 2019 15:20:34 +0000 (08:20 -0700)
Midgard bundles contain a tag, as well as a copy of the tag of the next
bundle to facilitate prefetch. Do some simple static analysis to detect
certain tag errors (particularly on shaders without branching).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/disassemble.c

index 50598c3958ef1d6ef77f026a9f7cd09cef3f8bd0..7fb5d202cc3a1f4213444518b83a2bc7eb2e1d2c 100644 (file)
@@ -1266,12 +1266,30 @@ disassemble_midgard(uint8_t *code, size_t size)
 
         bool prefetch_flag = false;
 
+        int last_next_tag = -1;
+
         unsigned i = 0;
 
         while (i < num_words) {
                 unsigned tag = words[i] & 0xF;
+                unsigned next_tag = (words[i] >> 4) & 0xF;
                 unsigned num_quad_words = midgard_word_size[tag];
 
+                /* Check the tag */
+                if (last_next_tag > 1) {
+                        if (last_next_tag != tag) {
+                                printf("/* TAG ERROR got ");
+                                print_tag_short(tag);
+                                printf(" expected ");
+                                print_tag_short(last_next_tag);
+                                printf(" */ ");
+                        }
+                } else {
+                        /* TODO: Check ALU case */
+                }
+
+                last_next_tag = next_tag;
+
                 switch (midgard_word_types[tag]) {
                 case midgard_word_type_texture:
                         print_texture_word(&words[i], tabs);