pan/bi: Handle standard FMA conversions
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 27 Mar 2020 23:06:28 +0000 (19:06 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 31 Mar 2020 01:12:26 +0000 (01:12 +0000)
These are plain old 1-sources so they're easy to start with.

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

src/panfrost/bifrost/bi_pack.c

index 83f27be6a7633273b62a9d4a576c5de4b242d18c..cac1ef5f31f9c8ee91a840e9b36f2bb32ec4e2b5 100644 (file)
@@ -609,9 +609,11 @@ bi_pack_fma_convert(bi_instruction *ins, struct bi_registers *regs)
 {
         nir_alu_type from_base = nir_alu_type_get_base_type(ins->src_types[0]);
         unsigned from_size = nir_alu_type_get_type_size(ins->src_types[0]);
+        bool from_unsigned = from_base == nir_type_uint;
 
         nir_alu_type to_base = nir_alu_type_get_base_type(ins->dest_type);
         unsigned to_size = nir_alu_type_get_type_size(ins->dest_type);
+        bool to_unsigned = to_base == nir_type_uint;
 
         /* Sanity check */
         assert((from_base != to_base) || (from_size != to_size));
@@ -620,14 +622,21 @@ bi_pack_fma_convert(bi_instruction *ins, struct bi_registers *regs)
         if (from_size == 16 && to_size == 16) {
                 /* f2i_i2f16 */
         } else if (from_size == 32 && to_size == 32) {
+                unsigned op = 0;
+
                 if (from_base == nir_type_float) {
-                        /* float32_to_int */
+                        op = BIFROST_FMA_FLOAT32_TO_INT(to_unsigned);
                 } else {
-                        /* int_to_float32 */
+                        op = BIFROST_FMA_INT_TO_FLOAT32(from_unsigned);
                 }
+
+                return bi_pack_fma_1src(ins, regs, op);
         } else if (from_size == 16 && to_size == 32) {
+                bool from_y = ins->swizzle[0][0];
+
                 if (from_base == nir_type_float) {
-                        /* float16_to_32 */
+                        return bi_pack_fma_1src(ins, regs,
+                                        BIFROST_FMA_FLOAT16_TO_32(from_y));
                 } else {
                         /* int16_to_32 */
                 }