emit_cat5() needs to check if the last optional reg is there before it
accesses it.
Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Rob Clark <robdclark@gmail.com>
* than tex/sampler idx, we use the first src reg in the ir to hold
* samp_tex hvec2:
*/
- struct ir3_register *src1 = instr->regs[2];
- struct ir3_register *src2 = instr->regs[3];
+ struct ir3_register *src1;
+ struct ir3_register *src2;
instr_cat5_t *cat5 = ptr;
+ iassert((instr->regs_count == 2) ||
+ (instr->regs_count == 3) || (instr->regs_count == 4));
+
switch (instr->opc) {
case OPC_DSX:
case OPC_DSXPP_1:
case OPC_DSYPP_1:
iassert((instr->flags & IR3_INSTR_S2EN) == 0);
src1 = instr->regs[1];
- src2 = instr->regs[2];
+ src2 = instr->regs_count > 2 ? instr->regs[2] : NULL;
break;
default:
src1 = instr->regs[2];
- src2 = instr->regs[3];
+ src2 = instr->regs_count > 3 ? instr->regs[3] : NULL;
break;
}