Mesa (master): aubinator: Make the iterator store a pointer to structure descriptions.

Kenneth Graunke kwg at kemper.freedesktop.org
Mon Mar 20 21:57:53 UTC 2017


Module: Mesa
Branch: master
Commit: b2c0c1d9a5c6b1dd55d4e06f504e1ce9fe823c32
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b2c0c1d9a5c6b1dd55d4e06f504e1ce9fe823c32

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sun Mar 19 21:22:20 2017 -0700

aubinator: Make the iterator store a pointer to structure descriptions.

When the iterator encounters a structure field, it now looks up the
gen_group for that structure definition and saves a pointer to it.

This lets us drop a lot of ridiculous code in the caller, which looked
at item->value (<struct NAME dword>), strtok'd the structure name back
out, and looked it up itself.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

---

 src/intel/tools/aubinator.c | 32 ++++++--------------------------
 src/intel/tools/decoder.c   |  5 ++++-
 src/intel/tools/decoder.h   |  1 +
 3 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index fc2efd3e46..0c941322d6 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -102,30 +102,11 @@ print_dword_header(struct gen_field_iterator *iter, uint64_t offset)
            offset + 4 * iter->dword, iter->p[iter->dword], iter->dword);
 }
 
-static char *
-print_iterator_values(struct gen_field_iterator *iter)
-{
-    char *token = NULL;
-    if (strstr(iter->value, "struct") == NULL) {
-       fprintf(outfile, "    %s: %s\n", iter->name, iter->value);
-    } else {
-        token = strtok(iter->value, " ");
-        if (token != NULL) {
-            token = strtok(NULL, " ");
-        } else {
-            token = NULL;
-        }
-        fprintf(outfile, "    %s:<struct %s>\n", iter->name, token);
-    }
-    return token;
-}
-
 static void
 decode_group(struct gen_spec *spec, struct gen_group *strct,
              const uint32_t *p, int starting_dword)
 {
    struct gen_field_iterator iter;
-   char *token = NULL;
    int last_dword = 0;
    uint64_t offset = 0;
 
@@ -141,13 +122,12 @@ decode_group(struct gen_spec *spec, struct gen_group *strct,
          print_dword_header(&iter, offset);
          last_dword = iter.dword;
       }
-      if (iter.dword >= starting_dword)
-         token = print_iterator_values(&iter);
-      if (token != NULL) {
-         print_dword_header(&iter, offset);
-         struct gen_group *struct_val = gen_spec_find_struct(spec, token);
-         decode_group(spec, struct_val, &p[iter.dword], 0);
-         token = NULL;
+      if (iter.dword >= starting_dword) {
+         fprintf(outfile, "    %s: %s\n", iter.name, iter.value);
+         if (iter.struct_desc) {
+            print_dword_header(&iter, offset + 4 * iter.dword);
+            decode_group(spec, iter.struct_desc, &p[iter.dword], 0);
+         }
       }
    }
 }
diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c
index 8838eb2500..a8534d7c0c 100644
--- a/src/intel/tools/decoder.c
+++ b/src/intel/tools/decoder.c
@@ -753,6 +753,7 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
    f = iter->group->fields[iter->i++];
    iter->name = f->name;
    iter->dword = f->start / 32;
+   iter->struct_desc = NULL;
 
    if ((f->end - f->start) > 32)
       v.qw = ((uint64_t) iter->p[iter->dword+1] << 32) | iter->p[iter->dword];
@@ -794,7 +795,9 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
       break;
    case GEN_TYPE_STRUCT:
       snprintf(iter->value, sizeof(iter->value),
-               "<struct %s %d>", f->type.gen_struct->name, iter->dword);
+               "<struct %s>", f->type.gen_struct->name);
+      iter->struct_desc =
+         gen_spec_find_struct(iter->group->spec, f->type.gen_struct->name);
       break;
    case GEN_TYPE_UFIXED:
       snprintf(iter->value, sizeof(iter->value),
diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h
index 700ce21f03..576b0e0859 100644
--- a/src/intel/tools/decoder.h
+++ b/src/intel/tools/decoder.h
@@ -54,6 +54,7 @@ struct gen_field_iterator {
    struct gen_group *group;
    const char *name;
    char value[128];
+   struct gen_group *struct_desc;
    const uint32_t *p;
    int dword; /**< current field starts at &p[dword] */
    int i;




More information about the mesa-commit mailing list