diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-05-01 20:58:45 -0400 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2020-05-04 11:08:16 -0400 |
commit | 5bd417228020a670e73fc8bf43e9595d1118d085 (patch) | |
tree | 48a479e3c866fa2ed9f627e5f09b98cca86d8119 /src/panfrost/bifrost | |
parent | 336d5128f9ba5036834fe1fb6420931b8aaad0ff (diff) |
pan/bi: Pack ADD ICMP 32
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4883>
Diffstat (limited to 'src/panfrost/bifrost')
-rw-r--r-- | src/panfrost/bifrost/bi_pack.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index c92bd4e2ef0..28ba283237a 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -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: |