summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>2017-08-02 22:33:28 +0100
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>2017-11-01 13:19:20 +0000
commitf5e5ca1e210c2e0f505ea154ca553275157dda73 (patch)
tree25e0a6ef667d1383b886ed3740d699f455b86108
parentffa011d1e3e6f57ce8a546c6a5210b15bde582d1 (diff)
intel: decoder: split out getting the next field and decoding it
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@intel.com> Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
-rw-r--r--src/intel/common/gen_decoder.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index 4ef285667d..ac7c94f41e 100644
--- a/src/intel/common/gen_decoder.c
+++ b/src/intel/common/gen_decoder.c
@@ -837,17 +837,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
@@ -928,8 +925,6 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
snprintf(iter->value + length, sizeof(iter->value) - length,
" (%s)", enum_name);
}
-
- return true;
}
void
@@ -941,9 +936,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
@@ -977,7 +988,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);
@@ -991,5 +1002,5 @@ gen_print_group(FILE *outfile, struct gen_group *group,
&p[iter.dword], color);
}
}
- }
+ } while (gen_field_iterator_next(&iter));
}