pan/bit: Interpret BI_BITWISE
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 28 Apr 2020 17:49:24 +0000 (13:49 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Apr 2020 00:30:05 +0000 (00:30 +0000)
No shifting yet.

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

src/panfrost/bifrost/test/bi_interpret.c

index f83f76d1b99d7399a79ad43d8ec3c883f434760d..eaa3327430cee01c7c048b28b5ead66a4d383619 100644 (file)
@@ -437,8 +437,28 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
                 break;
         }
 
-        case BI_BITWISE:
-                unreachable("Unsupported op");
+        case BI_BITWISE: {
+                /* Apply inverts first */
+                if (ins->bitwise.src_invert[0])
+                        srcs[0].u64 = ~srcs[0].u64;
+
+                if (ins->bitwise.src_invert[1])
+                        srcs[1].u64 = ~srcs[1].u64;
+
+                /* TODO: Shifting */
+                assert(srcs[2].u32 == 0);
+
+                if (ins->op.bitwise == BI_BITWISE_AND)
+                        dest.u64 = srcs[0].u64 & srcs[1].u64;
+                else if (ins->op.bitwise == BI_BITWISE_OR)
+                        dest.u64 = srcs[0].u64 | srcs[1].u64;
+                else if (ins->op.bitwise == BI_BITWISE_XOR)
+                        dest.u64 = srcs[0].u64 ^ srcs[1].u64;
+                else
+                        unreachable("Unsupported op");
+
+                break;
+         }
 
         case BI_CONVERT: {
                 /* If it exists */