vc4: Define a QIR branch instruction
[mesa.git] / src / gallium / drivers / vc4 / vc4_qir.h
index 5099b7f1f1c908d3c7fa071922b6122dc6cd470e..ad784bb987bb3df0115eabf5822035dc2ad4aef7 100644 (file)
@@ -156,6 +156,12 @@ enum qop {
         QOP_TEX_RESULT,
 
         QOP_LOAD_IMM,
+
+        /* Jumps to block->successor[0] if the qinst->cond (as a
+         * QPU_COND_BRANCH_*) passes, or block->successor[1] if not.  Note
+         * that block->successor[1] may be unset if the condition is ALWAYS.
+         */
+        QOP_BRANCH,
 };
 
 struct queued_qpu_inst {
@@ -754,6 +760,15 @@ qir_LOAD_IMM(struct vc4_compile *c, uint32_t val)
                                         qir_reg(QFILE_LOAD_IMM, val), c->undef));
 }
 
+static inline struct qinst *
+qir_BRANCH(struct vc4_compile *c, uint8_t cond)
+{
+        struct qinst *inst = qir_inst(QOP_BRANCH, c->undef, c->undef, c->undef);
+        inst->cond = cond;
+        qir_emit_nondef(c, inst);
+        return inst;
+}
+
 #define qir_for_each_block(block, c)                                    \
         list_for_each_entry(struct qblock, block, &c->blocks, link)