pan/bi: Handle fmov class ops
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 1 Apr 2020 02:16:55 +0000 (22:16 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 1 Apr 2020 02:25:05 +0000 (02:25 +0000)
We need to lower them to something reasonable (ideally, the modifier
would be attached but we need to do something for the case it's not). We
specifically have to lower pre-sched as well, but we can do the lower
literally at schedule time for now (if this proves annoying, we can move
it earlier, but I want to leave room for modifier-aware copyprop should
that prove interesting).

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

src/panfrost/bifrost/bi_pack.c
src/panfrost/bifrost/bi_print.c
src/panfrost/bifrost/bi_schedule.c

index 293a109eb5aedd4ba5e7fe2459d7c6a65dd66cad..9ec31044f71507998967a89deab8017fc1c09e18 100644 (file)
@@ -780,7 +780,6 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
                 return BIFROST_FMA_NOP;
         case BI_MOV:
                 return bi_pack_fma_1src(bundle.fma, regs, BIFROST_FMA_OP_MOV);
-        case BI_FMOV:
         case BI_SHIFT:
         case BI_SWIZZLE:
         case BI_ROUND:
@@ -989,7 +988,6 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
                 return bi_pack_add_ld_var_addr(clause, bundle.add, regs);
         case BI_MINMAX:
         case BI_MOV:
-        case BI_FMOV:
         case BI_SHIFT:
         case BI_STORE:
                 return BIFROST_ADD_NOP;
index 73c3a7f6422db964a15e9a1d307060b03b31beb6..7a4b73aca2b6cc9657cb25f9978555081acea647 100644 (file)
@@ -137,6 +137,7 @@ bi_class_name(enum bi_class cl)
         case BI_CSEL: return "csel";
         case BI_DISCARD: return "discard";
         case BI_FMA: return "fma";
+        case BI_FMOV: return "fmov";
         case BI_FREXP: return "frexp";
         case BI_ISUB: return "isub";
         case BI_LOAD: return "load";
index b3f7ca605c3acc7b5754a0f39a7190abfe0e3158..2885aeefe3a4cf70859572063ab0883532ca87c6 100644 (file)
@@ -89,6 +89,22 @@ bi_ambiguous_abs(bi_instruction *ins)
         return classy && typey && absy;
 }
 
+/* Lowers FMOV to ADD #0, since FMOV doesn't exist on the h/w and this is the
+ * latest time it's sane to lower (it's useful to distinguish before, but we'll
+ * need this handle during scheduling to ensure the ports get modeled
+ * correctly with respect to the new zero source) */
+
+static void
+bi_lower_fmov(bi_instruction *ins)
+{
+        if (ins->type != BI_FMOV)
+                return;
+
+        ins->type = BI_ADD;
+        ins->src[1] = BIR_INDEX_ZERO;
+        ins->src_types[1] = ins->src_types[0];
+}
+
 /* Eventually, we'll need a proper scheduling, grouping instructions
  * into clauses and ordering/assigning grouped instructions to the
  * appropriate FMA/ADD slots. Right now we do the dumbest possible
@@ -108,6 +124,9 @@ bi_schedule(bi_context *ctx)
                 list_inithead(&bblock->clauses);
 
                 bi_foreach_instr_in_block(bblock, ins) {
+                        /* Convenient time to lower */
+                        bi_lower_fmov(ins);
+
                         unsigned props = bi_class_props[ins->type];
 
                         bi_clause *u = rzalloc(ctx, bi_clause);