Mesa (master): pan/bi: Pack ADD IADD/ISUB for 8/16/32

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 4 19:01:44 UTC 2020


Module: Mesa
Branch: master
Commit: 10c18c6f69ed6ea8d82b300dc93c55e3180c1c74
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=10c18c6f69ed6ea8d82b300dc93c55e3180c1c74

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Mon May  4 14:37:04 2020 -0400

pan/bi: Pack ADD IADD/ISUB for 8/16/32

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

---

 src/panfrost/bifrost/bi_pack.c | 28 ++++++++++++++++++++++++++++
 src/panfrost/bifrost/bifrost.h |  7 +++++++
 2 files changed, 35 insertions(+)

diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index 90d63be6ff7..741ed133fc8 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -1625,6 +1625,32 @@ bi_pack_add_cmp(bi_instruction *ins, struct bi_registers *regs)
         }
 }
 
+static unsigned
+bi_pack_add_imath(bi_instruction *ins, struct bi_registers *regs)
+{
+        /* TODO: 32+16 add */
+        assert(ins->src_types[0] == ins->src_types[1]);
+        unsigned sz = nir_alu_type_get_type_size(ins->src_types[0]);
+        enum bi_imath_op p = ins->op.imath;
+
+        unsigned op = 0;
+
+        if (sz == 8) {
+                op = (p == BI_IMATH_ADD) ? BIFROST_ADD_IADD_8 :
+                        BIFROST_ADD_ISUB_8;
+        } else if (sz == 16) {
+                op = (p == BI_IMATH_ADD) ? BIFROST_ADD_IADD_16 :
+                        BIFROST_ADD_ISUB_16;
+        } else if (sz == 32) {
+                op = (p == BI_IMATH_ADD) ? BIFROST_ADD_IADD_32 :
+                        BIFROST_ADD_ISUB_32;
+        } else {
+                unreachable("64-bit todo");
+        }
+
+        return bi_pack_add_2src(ins, regs, op);
+}
+
 static unsigned
 bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
 {
@@ -1649,7 +1675,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
         case BI_DISCARD:
                 return bi_pack_add_discard(bundle.add, regs);
         case BI_FREXP:
+                unreachable("Packing todo");
         case BI_IMATH:
+                return bi_pack_add_imath(bundle.add, regs);
         case BI_LOAD:
                 unreachable("Packing todo");
         case BI_LOAD_ATTR:
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h
index 15e44251c1a..31ef76a4d5a 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -195,6 +195,13 @@ struct bifrost_add_discard {
 #define BIFROST_ADD_OP_LD_UBO_4 (0x0c220 >> 3)
 #define BIFROST_ADD_SEL_16(swiz) ((0xea60 >> 3) | (swiz))
 
+#define BIFROST_ADD_IADD_8  (0x17880 >> 3)
+#define BIFROST_ADD_IADD_16 (0x17900 >> 3)
+#define BIFROST_ADD_IADD_32 (0x178c0 >> 3)
+#define BIFROST_ADD_ISUB_8  (0x17a80 >> 3)
+#define BIFROST_ADD_ISUB_16 (0x17b00 >> 3)
+#define BIFROST_ADD_ISUB_32 (0x17ac0 >> 3)
+
 struct bifrost_add_2src {
         unsigned src0 : 3;
         unsigned src1 : 3;



More information about the mesa-commit mailing list