freedreno/rnn: Make addvariant work for fields in the same reg
authorDanylo Piliaiev <dpiliaiev@igalia.com>
Thu, 11 May 2023 11:32:28 +0000 (13:32 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 12 Jul 2023 13:33:27 +0000 (13:33 +0000)
Previously if addvariant was processed after other fields in the reg
these fields would never get matched. Fix this by moving bitfields that
add variant to the beginning of the list.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23881>

src/freedreno/rnn/rnn.c

index 1533d45732dfe9a43733463708599d966ac2a614..e16a570d3009e738ef63d032febbeba2eb515155 100644 (file)
@@ -1224,8 +1224,19 @@ static void preptypeinfo(struct rnndb *db, struct rnntypeinfo *ti, char *prefix,
        if (ti->addvariant && ti->type != RNN_TTYPE_ENUM) {
                rnn_err(db, "%s: addvariant specified on non-enum type %s\n", prefix, ti->name);
        }
-       for (i = 0; i < ti->bitfieldsnum; i++)
+       for (i = 0; i < ti->bitfieldsnum; i++) {
                prepbitfield(db,  ti->bitfields[i], prefix, vi);
+               if (ti->bitfields[i]->typeinfo.addvariant) {
+                       for (int j = 0; j < i; j++) {
+                               if (!ti->bitfields[j]->typeinfo.addvariant) {
+                                       struct rnnbitfield *t = ti->bitfields[j];
+                                       ti->bitfields[j] = ti->bitfields[i];
+                                       ti->bitfields[i] = t;
+                                       break;
+                               }
+                       }
+               }
+       }
        for (i = 0; i < ti->valsnum; i++)
                prepvalue(db, ti->vals[i], prefix, vi);
 }