vc4: Make some helpers for setting condition codes in instructions.
authorEric Anholt <eric@anholt.net>
Thu, 21 Aug 2014 20:17:58 +0000 (13:17 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 22 Aug 2014 17:16:58 +0000 (10:16 -0700)
src/gallium/drivers/vc4/vc4_qpu.c
src/gallium/drivers/vc4/vc4_qpu.h
src/gallium/drivers/vc4/vc4_qpu_emit.c

index de07f72bdd69acc6b932e1dac795e0f620c6ee68..d74dee5689ea1cf3d42defe376476dcea28a52a9 100644 (file)
@@ -216,3 +216,17 @@ qpu_set_sig(uint64_t inst, uint32_t sig)
         return (inst & ~QPU_SIG_MASK) | QPU_SET_FIELD(sig, QPU_SIG);
 }
 
+uint64_t
+qpu_set_cond_add(uint64_t inst, uint32_t sig)
+{
+        assert(QPU_GET_FIELD(inst, QPU_COND_ADD) == QPU_COND_ALWAYS);
+        return (inst & ~QPU_COND_ADD_MASK) | QPU_SET_FIELD(sig, QPU_COND_ADD);
+}
+
+uint64_t
+qpu_set_cond_mul(uint64_t inst, uint32_t sig)
+{
+        assert(QPU_GET_FIELD(inst, QPU_COND_MUL) == QPU_COND_ALWAYS);
+        return (inst & ~QPU_COND_MUL_MASK) | QPU_SET_FIELD(sig, QPU_COND_MUL);
+}
+
index 45aac0e135bb8b41b450c09a3f00b54b2b2835cc..15a33fcbf97229811187bb0fd9cf92d119d7af27 100644 (file)
@@ -131,6 +131,8 @@ uint64_t qpu_m_alu2(enum qpu_op_mul op, struct qpu_reg dst,
 uint64_t qpu_inst(uint64_t add, uint64_t mul);
 uint64_t qpu_load_imm_ui(struct qpu_reg dst, uint32_t val);
 uint64_t qpu_set_sig(uint64_t inst, uint32_t sig);
+uint64_t qpu_set_cond_add(uint64_t inst, uint32_t cond);
+uint64_t qpu_set_cond_mul(uint64_t inst, uint32_t cond);
 
 static inline uint64_t
 qpu_load_imm_f(struct qpu_reg dst, float val)
index 477929cc19950a5b833f283e2a5a4bb07d343ed9..d777af64d43c55c68de7479a0306ed2e6d835ad2 100644 (file)
@@ -379,12 +379,10 @@ vc4_generate_code(struct qcompile *c)
                                 fixup_raddr_conflict(c, src[1], &src[2]);
                                 queue(c, qpu_inst(qpu_a_MOV(dst, src[1]),
                                                   qpu_m_MOV(dst, src[2])));
-                                *last_inst(c) = ((*last_inst(c) & ~(QPU_COND_ADD_MASK |
-                                                                    QPU_COND_MUL_MASK))
-                                                 | QPU_SET_FIELD(QPU_COND_NS,
-                                                                 QPU_COND_ADD)
-                                                 | QPU_SET_FIELD(QPU_COND_NC,
-                                                                 QPU_COND_MUL));
+                                *last_inst(c) = qpu_set_cond_add(*last_inst(c),
+                                                                 QPU_COND_NS);
+                                *last_inst(c) = qpu_set_cond_mul(*last_inst(c),
+                                                                 QPU_COND_NC);
                         } else {
                                 if (dst.mux == src[1].mux &&
                                     dst.addr == src[1].addr) {
@@ -393,18 +391,16 @@ vc4_generate_code(struct qcompile *c)
 
                                         queue(c, qpu_inst(qpu_a_MOV(dst, src[2]),
                                                           qpu_m_NOP()));
-                                        *last_inst(c) = ((*last_inst(c) & ~(QPU_COND_ADD_MASK))
-                                                         | QPU_SET_FIELD(QPU_COND_NC,
-                                                                         QPU_COND_ADD));
+                                        *last_inst(c) = qpu_set_cond_add(*last_inst(c),
+                                                                         QPU_COND_NC);
                                 } else {
                                         queue(c, qpu_inst(qpu_a_MOV(dst, src[2]),
                                                           qpu_m_NOP()));
 
                                         queue(c, qpu_inst(qpu_a_MOV(dst, src[1]),
                                                           qpu_m_NOP()));
-                                        *last_inst(c) = ((*last_inst(c) & ~(QPU_COND_ADD_MASK))
-                                                         | QPU_SET_FIELD(QPU_COND_NS,
-                                                                         QPU_COND_ADD));
+                                        *last_inst(c) = qpu_set_cond_add(*last_inst(c),
+                                                                         QPU_COND_NS);
                                 }
                         }
                         break;
@@ -421,9 +417,9 @@ vc4_generate_code(struct qcompile *c)
 
                         queue(c, qpu_load_imm_f(dst, 0.0));
                         queue(c, qpu_load_imm_f(dst, 1.0));
-                        *last_inst(c) = ((*last_inst(c) & ~QPU_COND_ADD_MASK)
-                                         | QPU_SET_FIELD(compareflags[qinst->op - QOP_SEQ],
-                                                         QPU_COND_ADD));
+                        *last_inst(c) = qpu_set_cond_add(*last_inst(c),
+                                                         compareflags[qinst->op - QOP_SEQ]);
+
 
                         break;