pan/bi: Add packing for register control field
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 18 Mar 2020 01:35:44 +0000 (21:35 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 19 Mar 2020 03:23:07 +0000 (03:23 +0000)
Filling in some gaps based on intuition from the bit patterns but this
should be vaguely right. More investigation needed down the line.

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 f59440192d4bee22102723274f89f55796e10462..71097aa6442d03a02d620283a6f63879489d9e4d 100644 (file)
@@ -40,8 +40,74 @@ bi_pack_header(bi_clause *clause, bi_clause *next)
         return u;
 }
 
+/* Represents the assignment of ports for a given bundle */
+
+struct bi_registers {
+        /* Register to assign to each port */
+        unsigned port[4];
+
+        /* Read ports can be disabled */
+        bool enabled[2];
+
+        /* Should we write FMA? what about ADD? If only a single port is
+         * enabled it is in port 2, else ADD/FMA is 2/3 respectively */
+        bool write_fma, write_add;
+
+        /* Should we read with port 3? */
+        bool read_port3;
+
+        /* Packed uniform/constant */
+        unsigned uniform_constant;
+
+        /* Whether writes are actually for the last instruction */
+        bool first_instruction;
+};
+
+/* Determines the register control field, ignoring the first? flag */
+
+static enum bifrost_reg_control
+bi_pack_register_ctrl_lo(struct bi_registers r)
+{
+        if (r.write_fma) {
+                if (r.write_add) {
+                        assert(!r.read_port3);
+                        return BIFROST_WRITE_ADD_P2_FMA_P3;
+                } else {
+                        if (r.read_port3)
+                                return BIFROST_WRITE_FMA_P2_READ_P3;
+                        else
+                                return BIFROST_WRITE_FMA_P2;
+                }
+        } else if (r.write_add) {
+                if (r.read_port3)
+                        return BIFROST_WRITE_ADD_P2_READ_P3;
+                else
+                        return BIFROST_WRITE_ADD_P2;
+        } else if (r.read_port3)
+                return BIFROST_READ_P3;
+        else
+                return BIFROST_REG_NONE;
+}
+
+/* Ditto but account for the first? flag this time */
+
+static enum bifrost_reg_control
+bi_pack_register_ctrl(struct bi_registers r)
+{
+        enum bifrost_reg_control ctrl = bi_pack_register_ctrl_lo(r);
+
+        if (r.first_instruction) {
+                if (ctrl == BIFROST_REG_NONE)
+                        ctrl = BIFROST_FIRST_NONE;
+                else
+                        ctrl |= BIFROST_FIRST_NONE;
+        }
+
+        return ctrl;
+}
+
 static unsigned
-bi_pack_registers(bi_clause *clause, bi_bundle bundle)
+bi_pack_registers(struct bi_registers regs)
 {
         /* TODO */
         return 0;
@@ -69,7 +135,7 @@ struct bi_packed_bundle {
 static struct bi_packed_bundle
 bi_pack_bundle(bi_clause *clause, bi_bundle bundle)
 {
-        unsigned reg = bi_pack_registers(clause, bundle);
+        unsigned reg = /*bi_pack_registers(clause, bundle)*/0;
         uint64_t fma = bi_pack_fma(clause, bundle);
         uint64_t add = bi_pack_add(clause, bundle);
 
index 803abe804f98f169159c9bfac330d7b127c443e0..2cd7f322341b751873833aba395cd9d8d65788b1 100644 (file)
@@ -338,4 +338,22 @@ struct bifrost_fmt1 {
 #define BIFROST_FMT1_FINAL           0b01001
 #define BIFROST_FMT1_CONSTANTS       0b00001
 
+enum bifrost_reg_control {
+        BIFROST_WRITE_FMA_P2         = 1,
+        BIFROST_WRITE_FMA_P2_READ_P3 = 2,
+        BIFROST_WRITE_FMA_P2_READ_P3_ALT = 3,
+        BIFROST_READ_P3              = 4,
+        BIFROST_WRITE_ADD_P2         = 5,
+        BIFROST_WRITE_ADD_P2_READ_P3 = 6,
+        BIFROST_WRITE_ADD_P2_FMA_P3  = 7,
+
+        BIFROST_FIRST_NONE           = 8,
+        BIFROST_FIRST_WRITE_FMA_P2   = 9,
+        BIFROST_REG_NONE             = 11,
+        BIFROST_FIRST_READ_P3        = 12,
+        BIFROST_FIRST_WRITE_ADD_P2   = 13,
+        BIFROST_FIRST_WRITE_ADD_P2_READ_P3 = 14,
+        BIFROST_FIRST_WRITE_ADD_P2_FMA_P3  = 15
+};
+
 #endif