From 618d0542830bf478f23da8216bd0df62e9f5ce18 Mon Sep 17 00:00:00 2001 From: Rafael Antognolli Date: Fri, 12 Jul 2019 16:13:56 -0700 Subject: [PATCH] intel/gen_decoder: Add array field. We currently use the group->next pointer to iterate through the tags. This change them to be a type of field, so we can descend into them while iterating, and then go back to the original position. Will be useful when we want to decode 's inside 's, and when there are more 's after a tag. Reviewed-by: Lionel Landwerlin --- src/intel/common/gen_decoder.c | 23 ++++++++++++++++++++--- src/intel/common/gen_decoder.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c index 0bbcc8e..cb182b1 100644 --- a/src/intel/common/gen_decoder.c +++ b/src/intel/common/gen_decoder.c @@ -339,6 +339,20 @@ create_field(struct parser_context *ctx, const char **atts) return field; } +static struct gen_field * +create_array_field(struct parser_context *ctx, struct gen_group *array) +{ + struct gen_field *field; + + field = rzalloc(ctx->group, struct gen_field); + field->parent = ctx->group; + + field->array = array; + field->start = field->array->array_offset; + + return field; +} + static struct gen_value * create_value(struct parser_context *ctx, const char **atts) { @@ -356,9 +370,11 @@ create_value(struct parser_context *ctx, const char **atts) static struct gen_field * create_and_append_field(struct parser_context *ctx, - const char **atts) + const char **atts, + struct gen_group *array) { - struct gen_field *field = create_field(ctx, atts); + struct gen_field *field = array ? + create_array_field(ctx, array) : create_field(ctx, atts); struct gen_field *prev = NULL, *list = ctx->group->fields; while (list && field->start > list->start) { @@ -419,9 +435,10 @@ start_element(void *data, const char *element_name, const char **atts) struct gen_group *group = create_group(ctx, "", atts, ctx->group, false); previous_group->next = group; + ctx->last_field = create_and_append_field(ctx, NULL, group); ctx->group = group; } else if (strcmp(element_name, "field") == 0) { - ctx->last_field = create_and_append_field(ctx, atts); + ctx->last_field = create_and_append_field(ctx, atts, NULL); } else if (strcmp(element_name, "enum") == 0) { ctx->enoom = create_enum(ctx, name, atts); } else if (strcmp(element_name, "value") == 0) { diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h index 9ef253c..c71095f 100644 --- a/src/intel/common/gen_decoder.h +++ b/src/intel/common/gen_decoder.h @@ -175,6 +175,7 @@ union gen_field_value { struct gen_field { struct gen_group *parent; struct gen_field *next; + struct gen_group *array; char *name; int start, end; -- 2.7.4