summaryrefslogtreecommitdiffstats
path: root/src/intel/common
diff options
context:
space:
mode:
authorRafael Antognolli <[email protected]>2019-07-12 16:13:56 -0700
committerRafael Antognolli <[email protected]>2019-07-23 17:45:19 +0000
commit618d0542830bf478f23da8216bd0df62e9f5ce18 (patch)
tree9dcc9e02483bf2b423346150354cd07998148c62 /src/intel/common
parent21bdd51942433b757720865f69c847fa42cee449 (diff)
intel/gen_decoder: Add array field.
We currently use the group->next pointer to iterate through the <group> 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 <group>'s inside <group>'s, and when there are more <field>'s after a <group> tag. Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/common')
-rw-r--r--src/intel/common/gen_decoder.c23
-rw-r--r--src/intel/common/gen_decoder.h1
2 files changed, 21 insertions, 3 deletions
diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index 0bbcc8e7aff..cb182b15722 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 9ef253c50ce..c71095f122b 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;