vc4: Rewrite the pack instructions as a MOV with a dst pack flag
authorEric Anholt <eric@anholt.net>
Mon, 26 Oct 2015 20:45:06 +0000 (13:45 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 26 Oct 2015 23:48:34 +0000 (16:48 -0700)
Another step in reducing the special-casing of instructions.

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

index bba4f6d82ace6f078ce917d20f6a5504e2bf9abf..7894b081b1921d51015a19022d5ddcb522d0713a 100644 (file)
@@ -37,6 +37,7 @@ struct qir_op_info {
 static const struct qir_op_info qir_op_info[] = {
         [QOP_MOV] = { "mov", 1, 1 },
         [QOP_FMOV] = { "fmov", 1, 1 },
+        [QOP_MMOV] = { "mmov", 1, 1 },
         [QOP_FADD] = { "fadd", 1, 2 },
         [QOP_FSUB] = { "fsub", 1, 2 },
         [QOP_FMUL] = { "fmul", 1, 2 },
@@ -77,11 +78,6 @@ static const struct qir_op_info qir_op_info[] = {
         [QOP_RSQ] = { "rsq", 1, 1, false, true },
         [QOP_EXP2] = { "exp2", 1, 2, false, true },
         [QOP_LOG2] = { "log2", 1, 2, false, true },
-        [QOP_PACK_8888_F] = { "pack_8888_f", 1, 1 },
-        [QOP_PACK_8A_F] = { "pack_8a_f", 1, 1 },
-        [QOP_PACK_8B_F] = { "pack_8b_f", 1, 1 },
-        [QOP_PACK_8C_F] = { "pack_8c_f", 1, 1 },
-        [QOP_PACK_8D_F] = { "pack_8d_f", 1, 1 },
         [QOP_TLB_DISCARD_SETUP] = { "discard", 0, 1, true },
         [QOP_TLB_STENCIL_SETUP] = { "tlb_stencil_setup", 0, 1, true },
         [QOP_TLB_Z_WRITE] = { "tlb_z", 0, 1, true },
@@ -165,6 +161,7 @@ bool
 qir_is_mul(struct qinst *inst)
 {
         switch (inst->op) {
+        case QOP_MMOV:
         case QOP_FMUL:
         case QOP_MUL24:
         case QOP_V8MULD:
@@ -201,7 +198,8 @@ bool
 qir_is_raw_mov(struct qinst *inst)
 {
         return ((inst->op == QOP_MOV ||
-                 inst->op == QOP_FMOV) &&
+                 inst->op == QOP_FMOV ||
+                 inst->op == QOP_MMOV) &&
                 !inst->dst.pack &&
                 !inst->src[0].pack);
 }
index 393749b2f602f35042c420cc1325cd7ba1ce7fbf..a92ad93ee079e82e7208aee3dc92dae43cacf6d2 100644 (file)
@@ -66,6 +66,7 @@ enum qop {
         QOP_UNDEF,
         QOP_MOV,
         QOP_FMOV,
+        QOP_MMOV,
         QOP_FADD,
         QOP_FSUB,
         QOP_FMUL,
@@ -112,11 +113,6 @@ enum qop {
         QOP_LOG2,
         QOP_VW_SETUP,
         QOP_VR_SETUP,
-        QOP_PACK_8888_F,
-        QOP_PACK_8A_F,
-        QOP_PACK_8B_F,
-        QOP_PACK_8C_F,
-        QOP_PACK_8D_F,
         QOP_TLB_DISCARD_SETUP,
         QOP_TLB_STENCIL_SETUP,
         QOP_TLB_Z_WRITE,
@@ -557,6 +553,7 @@ qir_##name(struct vc4_compile *c, struct qreg dest, struct qreg a)       \
 
 QIR_ALU1(MOV)
 QIR_ALU1(FMOV)
+QIR_ALU1(MMOV)
 QIR_ALU2(FADD)
 QIR_ALU2(FSUB)
 QIR_ALU2(FMUL)
@@ -597,11 +594,6 @@ QIR_ALU1(RCP)
 QIR_ALU1(RSQ)
 QIR_ALU1(EXP2)
 QIR_ALU1(LOG2)
-QIR_ALU1(PACK_8888_F)
-QIR_PACK(PACK_8A_F)
-QIR_PACK(PACK_8B_F)
-QIR_PACK(PACK_8C_F)
-QIR_PACK(PACK_8D_F)
 QIR_ALU1(VARY_ADD_C)
 QIR_NODST_2(TEX_S)
 QIR_NODST_2(TEX_T)
@@ -652,12 +644,21 @@ qir_UNPACK_16_I(struct vc4_compile *c, struct qreg src, int i)
         return t;
 }
 
-static inline struct qreg
+static inline void
 qir_PACK_8_F(struct vc4_compile *c, struct qreg dest, struct qreg val, int chan)
 {
-        qir_emit(c, qir_inst(QOP_PACK_8A_F + chan, dest, val, c->undef));
+        assert(!dest.pack);
+        dest.pack = QPU_PACK_MUL_8A + chan;
+        qir_emit(c, qir_inst(QOP_MMOV, dest, val, c->undef));
         if (dest.file == QFILE_TEMP)
                 c->defs[dest.index] = NULL;
+}
+
+static inline struct qreg
+qir_PACK_8888_F(struct vc4_compile *c, struct qreg val)
+{
+        struct qreg dest = qir_MMOV(c, val);
+        c->defs[dest.index]->dst.pack = QPU_PACK_MUL_8888;
         return dest;
 }
 
index 7d4144ac30f5422f91ffd1653dad274b9d1b2a14..d06f8b27d2935ba6f82cd026da29d1b4892316bf 100644 (file)
@@ -227,6 +227,7 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
                          */
                         [QOP_MOV] = { QPU_A_OR },
                         [QOP_FMOV] = { QPU_A_FMAX },
+                        [QOP_MMOV] = { QPU_M_V8MIN },
                 };
 
                 uint64_t unpack = 0;
@@ -348,25 +349,6 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
 
                         break;
 
-                case QOP_PACK_8888_F:
-                        queue(c, qpu_m_MOV(dst, src[0]));
-                        *last_inst(c) |= QPU_PM;
-                        *last_inst(c) |= QPU_SET_FIELD(QPU_PACK_MUL_8888,
-                                                       QPU_PACK);
-                        break;
-
-                case QOP_PACK_8A_F:
-                case QOP_PACK_8B_F:
-                case QOP_PACK_8C_F:
-                case QOP_PACK_8D_F:
-                        queue(c,
-                              qpu_m_MOV(dst, src[0]) |
-                              QPU_PM |
-                              QPU_SET_FIELD(QPU_PACK_MUL_8A +
-                                            qinst->op - QOP_PACK_8A_F,
-                                            QPU_PACK));
-                        break;
-
                 case QOP_FRAG_X:
                         queue(c, qpu_a_ITOF(dst,
                                             qpu_ra(QPU_R_XY_PIXEL_COORD)));