i965: Share the sop opcodes between brw_wm_glsl.c and brw_wm_emit.c.

This commit is contained in:
Eric Anholt 2009-08-11 21:17:14 -07:00
parent 726ad15606
commit 7059aa0eff
3 changed files with 29 additions and 74 deletions

View file

@ -357,5 +357,11 @@ void emit_mad(struct brw_compile *p,
const struct brw_reg *arg0, const struct brw_reg *arg0,
const struct brw_reg *arg1, const struct brw_reg *arg1,
const struct brw_reg *arg2); const struct brw_reg *arg2);
void emit_sop(struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
GLuint cond,
const struct brw_reg *arg0,
const struct brw_reg *arg1);
#endif #endif

View file

@ -447,7 +447,7 @@ void emit_lrp(struct brw_compile *p,
} }
} }
static void emit_sop( struct brw_compile *p, void emit_sop(struct brw_compile *p,
const struct brw_reg *dst, const struct brw_reg *dst,
GLuint mask, GLuint mask,
GLuint cond, GLuint cond,
@ -458,10 +458,13 @@ static void emit_sop( struct brw_compile *p,
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (mask & (1<<i)) { if (mask & (1<<i)) {
brw_MOV(p, dst[i], brw_imm_f(0)); brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]); brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
brw_MOV(p, dst[i], brw_imm_f(0));
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_MOV(p, dst[i], brw_imm_f(1.0)); brw_MOV(p, dst[i], brw_imm_f(1.0));
brw_set_predicate_control_flag_value(p, 0xff); brw_pop_insn_state(p);
} }
} }
} }

View file

@ -1214,66 +1214,6 @@ static void emit_kil(struct brw_wm_compile *c)
brw_pop_insn_state(p); brw_pop_insn_state(p);
} }
static void emit_sop(struct brw_wm_compile *c,
const struct prog_instruction *inst, GLuint cond)
{
struct brw_compile *p = &c->func;
GLuint mask = inst->DstReg.WriteMask;
struct brw_reg dst, src0, src1;
int i;
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i);
src0 = get_src_reg(c, inst, 0, i);
src1 = get_src_reg_imm(c, inst, 1, i);
brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), cond, src0, src1);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
brw_MOV(p, dst, brw_imm_f(0.0));
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_MOV(p, dst, brw_imm_f(1.0));
brw_pop_insn_state(p);
}
}
}
static void emit_slt(struct brw_wm_compile *c,
const struct prog_instruction *inst)
{
emit_sop(c, inst, BRW_CONDITIONAL_L);
}
static void emit_sle(struct brw_wm_compile *c,
const struct prog_instruction *inst)
{
emit_sop(c, inst, BRW_CONDITIONAL_LE);
}
static void emit_sgt(struct brw_wm_compile *c,
const struct prog_instruction *inst)
{
emit_sop(c, inst, BRW_CONDITIONAL_G);
}
static void emit_sge(struct brw_wm_compile *c,
const struct prog_instruction *inst)
{
emit_sop(c, inst, BRW_CONDITIONAL_GE);
}
static void emit_seq(struct brw_wm_compile *c,
const struct prog_instruction *inst)
{
emit_sop(c, inst, BRW_CONDITIONAL_EQ);
}
static void emit_sne(struct brw_wm_compile *c,
const struct prog_instruction *inst)
{
emit_sop(c, inst, BRW_CONDITIONAL_NEQ);
}
static INLINE struct brw_reg high_words( struct brw_reg reg ) static INLINE struct brw_reg high_words( struct brw_reg reg )
{ {
return stride( suboffset( retype( reg, BRW_REGISTER_TYPE_W ), 1 ), return stride( suboffset( retype( reg, BRW_REGISTER_TYPE_W ), 1 ),
@ -2687,22 +2627,28 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
args[0]); args[0]);
break; break;
case OPCODE_SLT: case OPCODE_SLT:
emit_slt(c, inst); emit_sop(p, dst, dst_flags,
BRW_CONDITIONAL_L, args[0], args[1]);
break; break;
case OPCODE_SLE: case OPCODE_SLE:
emit_sle(c, inst); emit_sop(p, dst, dst_flags,
BRW_CONDITIONAL_LE, args[0], args[1]);
break; break;
case OPCODE_SGT: case OPCODE_SGT:
emit_sgt(c, inst); emit_sop(p, dst, dst_flags,
BRW_CONDITIONAL_G, args[0], args[1]);
break; break;
case OPCODE_SGE: case OPCODE_SGE:
emit_sge(c, inst); emit_sop(p, dst, dst_flags,
BRW_CONDITIONAL_GE, args[0], args[1]);
break; break;
case OPCODE_SEQ: case OPCODE_SEQ:
emit_seq(c, inst); emit_sop(p, dst, dst_flags,
BRW_CONDITIONAL_EQ, args[0], args[1]);
break; break;
case OPCODE_SNE: case OPCODE_SNE:
emit_sne(c, inst); emit_sop(p, dst, dst_flags,
BRW_CONDITIONAL_NEQ, args[0], args[1]);
break; break;
case OPCODE_MUL: case OPCODE_MUL:
emit_alu2(p, brw_MUL, dst, dst_flags, args[0], args[1]); emit_alu2(p, brw_MUL, dst, dst_flags, args[0], args[1]);