pan/bi: Pack ADD ICMP 32

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4883>
This commit is contained in:
Alyssa Rosenzweig
2020-05-01 20:58:45 -04:00
parent 336d5128f9
commit 5bd4172280
+66 -1
View File
@@ -1526,6 +1526,70 @@ bi_pack_add_discard(bi_instruction *ins, struct bi_registers *regs)
RETURN_PACKED(pack);
}
static enum bifrost_icmp_cond
bi_cond_to_icmp(enum bi_cond cond, bool *flip, bool is_unsigned)
{
switch (cond){
case BI_COND_LT:
*flip = true;
/* fallthrough */
case BI_COND_GT:
return is_unsigned ? BIFROST_ICMP_UGT : BIFROST_ICMP_IGT;
case BI_COND_LE:
*flip = true;
/* fallthrough */
case BI_COND_GE:
return is_unsigned ? BIFROST_ICMP_UGE : BIFROST_ICMP_IGE;
case BI_COND_NE:
return BIFROST_ICMP_NEQ;
case BI_COND_EQ:
return BIFROST_ICMP_EQ;
default:
unreachable("Invalid op for icmp");
}
}
static unsigned
bi_pack_add_icmp32(bi_instruction *ins, struct bi_registers *regs, bool flip,
enum bifrost_icmp_cond cond)
{
struct bifrost_add_icmp pack = {
.src0 = bi_get_src(ins, regs, flip ? 1 : 0, true),
.src1 = bi_get_src(ins, regs, flip ? 0 : 1, true),
.cond = cond,
.sz = 1,
.d3d = false,
.op = BIFROST_ADD_OP_ICMP_32
};
RETURN_PACKED(pack);
}
static unsigned
bi_pack_add_cmp(bi_instruction *ins, struct bi_registers *regs)
{
nir_alu_type Tl = ins->src_types[0];
nir_alu_type Tr = ins->src_types[1];
nir_alu_type Bl = nir_alu_type_get_base_type(Tl);
if (Bl == nir_type_uint || Bl == nir_type_int) {
assert(Tl == Tr);
unsigned sz = nir_alu_type_get_type_size(Tl);
bool flip = false;
enum bifrost_icmp_cond cond =
bi_cond_to_icmp(ins->cond, &flip, Bl == nir_type_uint);
if (sz == 32)
return bi_pack_add_icmp32(ins, regs, flip, cond);
else
unreachable("TODO");
} else {
unreachable("TODO");
}
}
static unsigned
bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
{
@@ -1538,8 +1602,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
case BI_ATEST:
return bi_pack_add_atest(clause, bundle.add, regs);
case BI_BRANCH:
case BI_CMP:
unreachable("Packing todo");
case BI_CMP:
return bi_pack_add_cmp(bundle.add, regs);
case BI_BLEND:
return bi_pack_add_blend(clause, bundle.add, regs);
case BI_BITWISE: