pan/bi: Sketch out instruction word packing
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 12 Mar 2020 18:33:32 +0000 (14:33 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 19 Mar 2020 03:23:07 +0000 (03:23 +0000)
Instructions are 78-bits with some seriously suspicious packing
requirements but hey, gotta save 'em bits.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4242>

src/panfrost/bifrost/bi_pack.c
src/panfrost/bifrost/bifrost.h

index 016046bcda0ecabf48c6143d7bd67c518d4da900..f59440192d4bee22102723274f89f55796e10462 100644 (file)
@@ -40,14 +40,60 @@ bi_pack_header(bi_clause *clause, bi_clause *next)
         return u;
 }
 
+static unsigned
+bi_pack_registers(bi_clause *clause, bi_bundle bundle)
+{
+        /* TODO */
+        return 0;
+}
+
+static unsigned
+bi_pack_fma(bi_clause *clause, bi_bundle bundle)
+{
+        /* TODO */
+        return BIFROST_FMA_NOP;
+}
+
+static unsigned
+bi_pack_add(bi_clause *clause, bi_bundle bundle)
+{
+        /* TODO */
+        return BIFROST_ADD_NOP;
+}
+
+struct bi_packed_bundle {
+        uint64_t lo;
+        uint64_t hi;
+};
+
+static struct bi_packed_bundle
+bi_pack_bundle(bi_clause *clause, bi_bundle bundle)
+{
+        unsigned reg = bi_pack_registers(clause, bundle);
+        uint64_t fma = bi_pack_fma(clause, bundle);
+        uint64_t add = bi_pack_add(clause, bundle);
+
+        struct bi_packed_bundle packed = {
+                .lo = reg | (fma << 35) | ((add & 0b111111) << 58),
+                .hi = add >> 6
+        };
+
+        return packed;
+}
+
 static void
 bi_pack_clause(bi_context *ctx, bi_clause *clause, bi_clause *next,
                 struct util_dynarray *emission)
 {
-        
+        struct bi_packed_bundle ins_1 = bi_pack_bundle(clause, clause->bundles[0]);
+        assert(clause->bundle_count == 1);
+
         struct bifrost_fmt1 quad_1 = {
                 .tag = BIFROST_FMT1_FINAL,
-                .header = bi_pack_header(clause, next) 
+                .header = bi_pack_header(clause, next),
+                .ins_1 = ins_1.lo,
+                .ins_2 = ins_1.hi & ((1 << 11) - 1),
+                .ins_0 = (ins_1.hi >> 11) & 0b111,
         };
 
         util_dynarray_append(emission, struct bifrost_fmt1, quad_1);
index 959c951e582dc00d00913af85f3b86ccfbdb2b61..803abe804f98f169159c9bfac330d7b127c443e0 100644 (file)
@@ -323,6 +323,9 @@ struct bifrost_branch {
 
 /* Clause packing */
 
+#define BIFROST_FMA_NOP (0x701960)
+#define BIFROST_ADD_NOP (0x3D960)
+
 struct bifrost_fmt1 {
         unsigned ins_0 : 3;
         unsigned tag : 5;