summaryrefslogtreecommitdiffstats
path: root/src/intel/common
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2018-05-01 22:12:56 +0100
committerLionel Landwerlin <[email protected]>2018-05-02 17:10:37 +0100
commit3c416a50d8d203115012363b13a4083f1c6de069 (patch)
treeeb265c3b9ae0e677fa89f3a3f97506c812bae539 /src/intel/common
parent967aabca06fc48ee18e1f4fc534483d45bdcaa70 (diff)
intel: decoder: make the field iterator use more natural
while (iter_next()) { ... } instead of do { ... } while (iter_next()); Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/common')
-rw-r--r--src/intel/common/gen_decoder.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index 1b8123bf394..7c462a0be4e 100644
--- a/src/intel/common/gen_decoder.c
+++ b/src/intel/common/gen_decoder.c
@@ -981,25 +981,31 @@ gen_field_iterator_init(struct gen_field_iterator *iter,
memset(iter, 0, sizeof(*iter));
iter->group = group;
- if (group->fields)
- iter->field = group->fields;
- else
- iter->field = group->next->fields;
iter->p = p;
iter->p_bit = p_bit;
int length = gen_group_get_length(iter->group, iter->p);
iter->p_end = length > 0 ? &p[length] : NULL;
iter->print_colors = print_colors;
-
- bool result = iter_decode_field(iter);
- if (length >= 0)
- assert(result);
}
bool
gen_field_iterator_next(struct gen_field_iterator *iter)
{
+ /* Initial condition */
+ if (!iter->field) {
+ if (iter->group->fields)
+ iter->field = iter->group->fields;
+ else
+ iter->field = iter->group->next->fields;
+
+ bool result = iter_decode_field(iter);
+ if (iter->p_end)
+ assert(result);
+
+ return true;
+ }
+
if (!iter_advance_field(iter))
return false;
@@ -1040,7 +1046,7 @@ gen_print_group(FILE *outfile, struct gen_group *group, uint64_t offset,
int last_dword = -1;
gen_field_iterator_init(&iter, group, p, p_bit, color);
- do {
+ while (gen_field_iterator_next(&iter)) {
int iter_dword = iter.end_bit / 32;
if (last_dword != iter_dword) {
for (int i = last_dword + 1; i <= iter_dword; i++)
@@ -1055,5 +1061,5 @@ gen_print_group(FILE *outfile, struct gen_group *group, uint64_t offset,
&p[iter_dword], iter.start_bit % 32, color);
}
}
- } while (gen_field_iterator_next(&iter));
+ }
}