[Mesa-dev] [PATCH 07/33] intel: decoder: split out getting the next field and decoding it

Lionel Landwerlin lionel.g.landwerlin at intel.com
Mon Oct 30 16:58:20 UTC 2017


Due to the new way we handle fields, we need *not* to forget the first
field when decoding instructions. The issue was that the advance
function was called first and skipped the first field.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/common/gen_decoder.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index 8336269b183..4ce3a577f96 100644
--- a/src/intel/common/gen_decoder.c
+++ b/src/intel/common/gen_decoder.c
@@ -829,17 +829,14 @@ iter_advance_field(struct gen_field_iterator *iter)
    return true;
 }
 
-bool
-gen_field_iterator_next(struct gen_field_iterator *iter)
+static void
+gen_field_decode(struct gen_field_iterator *iter)
 {
    union {
       uint64_t qw;
       float f;
    } v;
 
-   if (!iter_advance_field(iter))
-      return false;
-
    if (iter->field->name)
       strncpy(iter->name, iter->field->name, sizeof(iter->name));
    else
@@ -920,8 +917,6 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
       snprintf(iter->value + length, sizeof(iter->value) - length,
                " (%s)", enum_name);
    }
-
-   return true;
 }
 
 void
@@ -933,9 +928,25 @@ gen_field_iterator_init(struct gen_field_iterator *iter,
    memset(iter, 0, sizeof(*iter));
 
    iter->group = group;
-   iter->field = group->fields;
+   if (group->fields)
+      iter->field = group->fields;
+   else
+      iter->field = group->next->fields;
    iter->p = p;
    iter->print_colors = print_colors;
+
+   gen_field_decode(iter);
+}
+
+bool
+gen_field_iterator_next(struct gen_field_iterator *iter)
+{
+   if (!iter_advance_field(iter))
+      return false;
+
+   gen_field_decode(iter);
+
+   return true;
 }
 
 static void
@@ -969,7 +980,7 @@ gen_print_group(FILE *outfile, struct gen_group *group,
    int last_dword = -1;
 
    gen_field_iterator_init(&iter, group, p, color);
-   while (gen_field_iterator_next(&iter)) {
+   do {
       if (last_dword != iter.dword) {
          for (int i = last_dword + 1; i <= iter.dword; i++)
             print_dword_header(outfile, &iter, offset, i);
@@ -983,5 +994,5 @@ gen_print_group(FILE *outfile, struct gen_group *group,
                             &p[iter.dword], color);
          }
       }
-   }
+   } while (gen_field_iterator_next(&iter));
 }
-- 
2.15.0.rc2



More information about the mesa-dev mailing list