vc4: Redefine VPM writes as a (destination) QIR register file.
authorEric Anholt <eric@anholt.net>
Thu, 18 Dec 2014 04:23:57 +0000 (20:23 -0800)
committerEric Anholt <eric@anholt.net>
Thu, 18 Dec 2014 06:35:08 +0000 (22:35 -0800)
This will let me coalesce the VPM writes into the instructions generating
the values.

src/gallium/drivers/vc4/vc4_qir.c
src/gallium/drivers/vc4/vc4_qir.h
src/gallium/drivers/vc4/vc4_qpu_emit.c

index 8cb9826a21d35e8d02c1cf056d28c0c174378e71..91bdefe81e5b03d7a9bdb59fab9821e76fd6f3a4 100644 (file)
@@ -74,7 +74,6 @@ static const struct qir_op_info qir_op_info[] = {
         [QOP_LOG2] = { "log2", 1, 2 },
         [QOP_PACK_COLORS] = { "pack_colors", 1, 4 },
         [QOP_PACK_SCALED] = { "pack_scaled", 1, 2 },
-        [QOP_VPM_WRITE] = { "vpm_write", 0, 1, true },
         [QOP_VPM_READ] = { "vpm_read", 0, 1, true },
         [QOP_TLB_DISCARD_SETUP] = { "discard", 0, 1, true },
         [QOP_TLB_STENCIL_SETUP] = { "tlb_stencil_setup", 0, 1, true },
@@ -150,6 +149,9 @@ qir_has_side_effects(struct vc4_compile *c, struct qinst *inst)
                 }
         }
 
+        if (inst->dst.file == QFILE_VPM)
+                return true;
+
         return qir_op_info[inst->op].has_side_effects;
 }
 
@@ -217,6 +219,8 @@ qir_print_reg(struct vc4_compile *c, struct qreg reg)
                         fprintf(stderr, "%d", reg.index);
                 else
                         fprintf(stderr, "%f", uif(reg.index));
+        } else if (reg.file == QFILE_VPM) {
+                fprintf(stderr, "vpm");
         } else {
                 fprintf(stderr, "%s%d", files[reg.file], reg.index);
         }
index db0a436722284c7148bad8454a0ee00709403300..dd9866e126f1df51ddcc859c7a54ef15384ab1ac 100644 (file)
@@ -38,6 +38,7 @@ enum qfile {
         QFILE_TEMP,
         QFILE_VARY,
         QFILE_UNIF,
+        QFILE_VPM,
 
         /**
          * Stores an immediate value in the index field that can be turned
@@ -100,7 +101,6 @@ enum qop {
         QOP_VR_SETUP,
         QOP_PACK_SCALED,
         QOP_PACK_COLORS,
-        QOP_VPM_WRITE,
         QOP_VPM_READ,
         QOP_TLB_DISCARD_SETUP,
         QOP_TLB_STENCIL_SETUP,
@@ -472,7 +472,6 @@ QIR_ALU1(EXP2)
 QIR_ALU1(LOG2)
 QIR_ALU2(PACK_SCALED)
 QIR_ALU1(VARY_ADD_C)
-QIR_NODST_1(VPM_WRITE)
 QIR_NODST_2(TEX_S)
 QIR_NODST_2(TEX_T)
 QIR_NODST_2(TEX_R)
@@ -545,4 +544,11 @@ qir_POW(struct vc4_compile *c, struct qreg x, struct qreg y)
                                     qir_LOG2(c, x)));
 }
 
+static inline void
+qir_VPM_WRITE(struct vc4_compile *c, struct qreg val)
+{
+        static const struct qreg vpm = { QFILE_VPM, 0 };
+        qir_emit(c, qir_inst(QOP_MOV, vpm, val, c->undef));
+}
+
 #endif /* VC4_QIR_H */
index 35300ff42e8de9e5ffa94a08fdfcca52cc6f3de6..503f32a4c05a897cad8312eda78e5036456d5210 100644 (file)
@@ -249,6 +249,9 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
                                  */
                                 assert(src[i].addr <= 47);
                                 break;
+                        case QFILE_VPM:
+                                assert(!"not reached");
+                                break;
                         }
                 }
 
@@ -260,6 +263,9 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
                 case QFILE_TEMP:
                         dst = temp_registers[qinst->dst.index];
                         break;
+                case QFILE_VPM:
+                        dst = qpu_ra(QPU_W_VPM);
+                        break;
                 case QFILE_VARY:
                 case QFILE_UNIF:
                 case QFILE_SMALL_IMM:
@@ -308,10 +314,6 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
 
                         break;
 
-                case QOP_VPM_WRITE:
-                        queue(c, qpu_a_MOV(qpu_ra(QPU_W_VPM), src[0]));
-                        break;
-
                 case QOP_VPM_READ:
                         queue(c, qpu_a_MOV(dst, qpu_ra(QPU_R_VPM)));
                         break;