From: Lionel Landwerlin Date: Tue, 1 May 2018 21:14:12 +0000 (+0100) Subject: intel: decoder: identify groups with fixed length X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f128f7850e64829b8b1399ef0bdfd1eec7f4504;p=mesa.git intel: decoder: identify groups with fixed length & elements always have fixed length. The get_length() method implies that we're dealing with an instruction in which the length is encoded into the variable data but the field iterator uses it without checking what kind of gen_group it is dealing with. Let's make get_length() report the correct length regardless of the gen_group (register, struct or instruction). Signed-off-by: Lionel Landwerlin Reviewed-by: Kenneth Graunke --- diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c index 7c462a0be4e..93fa4864ee3 100644 --- a/src/intel/common/gen_decoder.c +++ b/src/intel/common/gen_decoder.c @@ -151,7 +151,8 @@ static struct gen_group * create_group(struct parser_context *ctx, const char *name, const char **atts, - struct gen_group *parent) + struct gen_group *parent, + bool fixed_length) { struct gen_group *group; @@ -161,6 +162,7 @@ create_group(struct parser_context *ctx, group->spec = ctx->spec; group->variable = false; + group->fixed_length = fixed_length; for (int i = 0; atts[i]; i += 2) { char *p; @@ -370,18 +372,19 @@ start_element(void *data, const char *element_name, const char **atts) minor = 0; ctx->spec->gen = gen_make_gen(major, minor); - } else if (strcmp(element_name, "instruction") == 0 || - strcmp(element_name, "struct") == 0) { - ctx->group = create_group(ctx, name, atts, NULL); + } else if (strcmp(element_name, "instruction") == 0) { + ctx->group = create_group(ctx, name, atts, NULL, false); + } else if (strcmp(element_name, "struct") == 0) { + ctx->group = create_group(ctx, name, atts, NULL, true); } else if (strcmp(element_name, "register") == 0) { - ctx->group = create_group(ctx, name, atts, NULL); + ctx->group = create_group(ctx, name, atts, NULL, true); get_register_offset(atts, &ctx->group->register_offset); } else if (strcmp(element_name, "group") == 0) { struct gen_group *previous_group = ctx->group; while (previous_group->next) previous_group = previous_group->next; - struct gen_group *group = create_group(ctx, "", atts, ctx->group); + struct gen_group *group = create_group(ctx, "", atts, ctx->group, false); previous_group->next = group; ctx->group = group; } else if (strcmp(element_name, "field") == 0) { @@ -713,6 +716,9 @@ gen_group_find_field(struct gen_group *group, const char *name) int gen_group_get_length(struct gen_group *group, const uint32_t *p) { + if (group && group->fixed_length) + return group->dw_length; + uint32_t h = p[0]; uint32_t type = field_value(h, 29, 31); diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h index f28ac7d27af..7d3bedca5b5 100644 --- a/src/intel/common/gen_decoder.h +++ b/src/intel/common/gen_decoder.h @@ -104,6 +104,7 @@ struct gen_group { uint32_t group_offset, group_count; uint32_t group_size; bool variable; + bool fixed_length; /* True for & */ struct gen_group *parent; struct gen_group *next;