vc4: Add initial support for math opcodes

This commit is contained in:
Eric Anholt 2014-07-16 08:25:22 -07:00
parent 792d1c92df
commit db8712bcbc
2 changed files with 41 additions and 1 deletions

View File

@ -258,6 +258,10 @@ emit_tgsi_instruction(struct tgsi_to_qir *trans,
[TGSI_OPCODE_DP2] = { 0, tgsi_to_qir_dp2 },
[TGSI_OPCODE_DP3] = { 0, tgsi_to_qir_dp3 },
[TGSI_OPCODE_DP4] = { 0, tgsi_to_qir_dp4 },
[TGSI_OPCODE_RCP] = { QOP_RCP, tgsi_to_qir_alu },
[TGSI_OPCODE_RSQ] = { QOP_RSQ, tgsi_to_qir_alu },
[TGSI_OPCODE_EX2] = { QOP_EXP2, tgsi_to_qir_alu },
[TGSI_OPCODE_LG2] = { QOP_LOG2, tgsi_to_qir_alu },
[TGSI_OPCODE_LIT] = { QOP_MOV, tgsi_to_qir_alu }, /* XXX */
};
static int asdf = 0;

View File

@ -196,6 +196,43 @@ vc4_generate_code(struct qcompile *c)
qpu_m_NOP());
break;
case QOP_RCP:
case QOP_RSQ:
case QOP_EXP2:
case QOP_LOG2:
switch (qinst->op) {
case QOP_RCP:
insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_RECIP),
src[0]),
qpu_m_NOP());
break;
case QOP_RSQ:
insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_RECIPSQRT),
src[0]),
qpu_m_NOP());
break;
case QOP_EXP2:
insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_EXP),
src[0]),
qpu_m_NOP());
break;
case QOP_LOG2:
insts[ni++] = qpu_inst(qpu_a_MOV(qpu_rb(QPU_W_SFU_LOG),
src[0]),
qpu_m_NOP());
break;
default:
abort();
}
insts[ni++] = qpu_inst(qpu_a_NOP(), qpu_m_NOP());
insts[ni++] = qpu_inst(qpu_a_NOP(), qpu_m_NOP());
insts[ni++] = qpu_inst(qpu_a_MOV(dst, qpu_r4()),
qpu_m_NOP());
break;
case QOP_PACK_COLORS:
for (int i = 0; i < 4; i++) {
insts[ni++] = qpu_inst(qpu_a_NOP(),
@ -207,7 +244,6 @@ vc4_generate_code(struct qcompile *c)
insts[ni++] = qpu_inst(qpu_a_MOV(dst, qpu_r5()),
qpu_m_NOP());
break;
case QOP_TLB_COLOR_WRITE: