summaryrefslogtreecommitdiffstats
path: root/src/broadcom/cle
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-06-26 12:57:16 -0700
committerEric Anholt <[email protected]>2018-07-27 17:56:55 -0700
commita57770aa37f2c97125ed10e54e9385bcc38c3811 (patch)
tree043989b833ed715119823e54d9958b20f2ee3678 /src/broadcom/cle
parent95bafeeabfeb1d8348191fa66ed2e5c3b730c54b (diff)
v3d: Dump fields in CLIF output in increasing offset order.
Previously, we emitted in XML order, which I happen to type in the decreasing offset order of the specifications. However, the CLIF parser wants increasing offsets.
Diffstat (limited to 'src/broadcom/cle')
-rw-r--r--src/broadcom/cle/v3d_decoder.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/broadcom/cle/v3d_decoder.c b/src/broadcom/cle/v3d_decoder.c
index 725561cef85..ed39ec48fc5 100644
--- a/src/broadcom/cle/v3d_decoder.c
+++ b/src/broadcom/cle/v3d_decoder.c
@@ -511,6 +511,13 @@ skip:
ctx->parse_depth++;
}
+static int
+field_offset_compare(const void *a, const void *b)
+{
+ return ((*(const struct v3d_field **)a)->start -
+ (*(const struct v3d_field **)b)->start);
+}
+
static void
end_element(void *data, const char *name)
{
@@ -549,6 +556,13 @@ end_element(void *data, const char *name)
else if (strcmp(name, "register") == 0)
spec->registers[spec->nregisters++] = group;
+ /* Sort the fields in increasing offset order. The XML might
+ * be specified in any order, but we'll want to iterate from
+ * the bottom.
+ */
+ qsort(group->fields, group->nfields, sizeof(*group->fields),
+ field_offset_compare);
+
assert(spec->ncommands < ARRAY_SIZE(spec->commands));
assert(spec->nstructs < ARRAY_SIZE(spec->structs));
assert(spec->nregisters < ARRAY_SIZE(spec->registers));