From: Eric Anholt Date: Wed, 13 Feb 2019 19:59:10 +0000 (-0800) Subject: v3d: Add a helper function for getting a nop register. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4586f9f9024bd8211256b8382f316aa5e3b57d37;p=mesa.git v3d: Add a helper function for getting a nop register. Just a little refactor to explain what's going on with QFILE_NULL. --- diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index e05b8a0b313..97d05529913 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -698,7 +698,7 @@ ntq_emit_comparison(struct v3d_compile *c, if (nir_op_infos[compare_instr->op].num_inputs > 1) src1 = ntq_get_alu_src(c, compare_instr, 1); bool cond_invert = false; - struct qreg nop = vir_reg(QFILE_NULL, 0); + struct qreg nop = vir_nop_reg(); switch (compare_instr->op) { case nir_op_feq32: @@ -1116,7 +1116,7 @@ emit_frag_end(struct v3d_compile *c) struct nir_variable *var = c->output_color_var[0]; struct qreg *color = &c->outputs[var->data.driver_location * 4]; - vir_SETMSF_dest(c, vir_reg(QFILE_NULL, 0), + vir_SETMSF_dest(c, vir_nop_reg(), vir_AND(c, vir_MSF(c), vir_FTOC(c, color[3]))); @@ -1153,7 +1153,7 @@ emit_frag_end(struct v3d_compile *c) struct qinst *inst = vir_MOV_dest(c, vir_reg(QFILE_TLBU, 0), - vir_reg(QFILE_NULL, 0)); + vir_nop_reg()); uint8_t tlb_specifier = TLB_TYPE_DEPTH; if (c->devinfo->ver >= 42) { @@ -1888,11 +1888,11 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) case nir_intrinsic_discard: if (c->execute.file != QFILE_NULL) { vir_PF(c, c->execute, V3D_QPU_PF_PUSHZ); - vir_set_cond(vir_SETMSF_dest(c, vir_reg(QFILE_NULL, 0), + vir_set_cond(vir_SETMSF_dest(c, vir_nop_reg(), vir_uniform_ui(c, 0)), V3D_QPU_COND_IFA); } else { - vir_SETMSF_dest(c, vir_reg(QFILE_NULL, 0), + vir_SETMSF_dest(c, vir_nop_reg(), vir_uniform_ui(c, 0)); } break; @@ -1908,12 +1908,12 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) */ vir_PF(c, vir_OR(c, c->execute, vir_NOT(c, cond)), V3D_QPU_PF_PUSHZ); - vir_set_cond(vir_SETMSF_dest(c, vir_reg(QFILE_NULL, 0), + vir_set_cond(vir_SETMSF_dest(c, vir_nop_reg(), vir_uniform_ui(c, 0)), V3D_QPU_COND_IFA); } else { vir_PF(c, cond, V3D_QPU_PF_PUSHZ); - vir_set_cond(vir_SETMSF_dest(c, vir_reg(QFILE_NULL, 0), + vir_set_cond(vir_SETMSF_dest(c, vir_nop_reg(), vir_uniform_ui(c, 0)), V3D_QPU_COND_IFNA); } @@ -2008,7 +2008,7 @@ ntq_emit_intrinsic(struct v3d_compile *c, nir_intrinsic_instr *instr) static void ntq_activate_execute_for_block(struct v3d_compile *c) { - vir_set_pf(vir_XOR_dest(c, vir_reg(QFILE_NULL, 0), + vir_set_pf(vir_XOR_dest(c, vir_nop_reg(), c->execute, vir_uniform_ui(c, c->cur_block->index)), V3D_QPU_PF_PUSHZ); @@ -2106,8 +2106,7 @@ ntq_emit_nonuniform_if(struct v3d_compile *c, nir_if *if_stmt) if (was_top_level) { cond = v3d_qpu_cond_invert(cond); } else { - struct qinst *inst = vir_MOV_dest(c, vir_reg(QFILE_NULL, 0), - c->execute); + struct qinst *inst = vir_MOV_dest(c, vir_nop_reg(), c->execute); if (cond == V3D_QPU_COND_IFA) { vir_set_uf(inst, V3D_QPU_UF_NORNZ); } else { diff --git a/src/broadcom/compiler/qpu_schedule.c b/src/broadcom/compiler/qpu_schedule.c index 0f8001ff52d..6b04ca488ec 100644 --- a/src/broadcom/compiler/qpu_schedule.c +++ b/src/broadcom/compiler/qpu_schedule.c @@ -1028,7 +1028,7 @@ insert_scheduled_instruction(struct v3d_compile *c, static struct qinst * vir_nop() { - struct qreg undef = { QFILE_NULL, 0 }; + struct qreg undef = vir_nop_reg(); struct qinst *qinst = vir_add_inst(V3D_QPU_A_NOP, undef, undef, undef); return qinst; diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h index 3d21a1154f7..bb4b5d0b3b2 100644 --- a/src/broadcom/compiler/v3d_compiler.h +++ b/src/broadcom/compiler/v3d_compiler.h @@ -105,6 +105,11 @@ static inline struct qreg vir_reg(enum qfile file, uint32_t index) return (struct qreg){file, index}; } +static inline struct qreg vir_nop_reg(void) +{ + return (struct qreg){QFILE_NULL, 0}; +} + /** * A reference to an actual register at the QPU level, for register * allocation. diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index 3efe41d3da9..628466a6765 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -401,7 +401,7 @@ vir_branch_inst(enum v3d_qpu_branch_cond cond, struct qreg src) inst->qpu.branch.ub = true; inst->qpu.branch.bdu = V3D_QPU_BRANCH_DEST_REL; - inst->dst = vir_reg(QFILE_NULL, 0); + inst->dst = vir_nop_reg(); inst->src[0] = src; inst->uniform = ~0; @@ -1098,7 +1098,7 @@ vir_PF(struct v3d_compile *c, struct qreg src, enum v3d_qpu_pf pf) last_inst != c->defs[src.index] || !vir_can_set_flags(c, last_inst)) { /* XXX: Make the MOV be the appropriate type */ - last_inst = vir_MOV_dest(c, vir_reg(QFILE_NULL, 0), src); + last_inst = vir_MOV_dest(c, vir_nop_reg(), src); } vir_set_pf(last_inst, pf); diff --git a/src/broadcom/compiler/vir_to_qpu.c b/src/broadcom/compiler/vir_to_qpu.c index c66bb84b3fc..9e80fbb0fd7 100644 --- a/src/broadcom/compiler/vir_to_qpu.c +++ b/src/broadcom/compiler/vir_to_qpu.c @@ -76,7 +76,7 @@ v3d_qpu_nop(void) static struct qinst * vir_nop(void) { - struct qreg undef = { QFILE_NULL, 0 }; + struct qreg undef = vir_nop_reg(); struct qinst *qinst = vir_add_inst(V3D_QPU_A_NOP, undef, undef, undef); return qinst;