From 5cbdf29b7e931fcda52aa1a0e8a9551cd7309651 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 1 May 2020 21:37:59 -0400 Subject: [PATCH] pan/bi: Pack ADD ICMP 16 Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 32 +++++++++++++++++++++++++++----- src/panfrost/bifrost/bifrost.h | 4 ++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 28ba283237a..50d2ca66c2c 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -1527,19 +1527,21 @@ bi_pack_add_discard(bi_instruction *ins, struct bi_registers *regs) } static enum bifrost_icmp_cond -bi_cond_to_icmp(enum bi_cond cond, bool *flip, bool is_unsigned) +bi_cond_to_icmp(enum bi_cond cond, bool *flip, bool is_unsigned, bool is_16) { switch (cond){ case BI_COND_LT: *flip = true; /* fallthrough */ case BI_COND_GT: - return is_unsigned ? BIFROST_ICMP_UGT : BIFROST_ICMP_IGT; + return is_unsigned ? (is_16 ? BIFROST_ICMP_IGE : 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; + return is_unsigned ? BIFROST_ICMP_UGE : + (is_16 ? BIFROST_ICMP_UGT : BIFROST_ICMP_IGE); case BI_COND_NE: return BIFROST_ICMP_NEQ; case BI_COND_EQ: @@ -1565,6 +1567,23 @@ bi_pack_add_icmp32(bi_instruction *ins, struct bi_registers *regs, bool flip, RETURN_PACKED(pack); } +static unsigned +bi_pack_add_icmp16(bi_instruction *ins, struct bi_registers *regs, bool flip, + enum bifrost_icmp_cond cond) +{ + struct bifrost_add_icmp16 pack = { + .src0 = bi_get_src(ins, regs, flip ? 1 : 0, false), + .src1 = bi_get_src(ins, regs, flip ? 0 : 1, false), + .src0_swizzle = bi_swiz16(ins, flip ? 1 : 0), + .src1_swizzle = bi_swiz16(ins, flip ? 0 : 1), + .cond = cond, + .d3d = false, + .op = BIFROST_ADD_OP_ICMP_16 + }; + + RETURN_PACKED(pack); +} + static unsigned bi_pack_add_cmp(bi_instruction *ins, struct bi_registers *regs) { @@ -1578,11 +1597,14 @@ bi_pack_add_cmp(bi_instruction *ins, struct bi_registers *regs) bool flip = false; - enum bifrost_icmp_cond cond = - bi_cond_to_icmp(ins->cond, &flip, Bl == nir_type_uint); + enum bifrost_icmp_cond cond = bi_cond_to_icmp( + sz == 16 ? /*bi_invert_cond*/(ins->cond) : ins->cond, + &flip, Bl == nir_type_uint, sz == 16); if (sz == 32) return bi_pack_add_icmp32(ins, regs, flip, cond); + else if (sz == 16) + return bi_pack_add_icmp16(ins, regs, flip, cond); else unreachable("TODO"); } else { diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index d4e6952545b..cc26e281ea4 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -497,8 +497,8 @@ struct bifrost_add_fcmp16 { enum bifrost_icmp_cond { BIFROST_ICMP_IGT = 0, - BIFROST_ICMP_IGE = 1, - BIFROST_ICMP_UGT = 2, + BIFROST_ICMP_IGE = 1, /* swapped for 16-bit */ + BIFROST_ICMP_UGT = 2, /* swapped for 16-bit */ BIFROST_ICMP_UGE = 3, BIFROST_ICMP_EQ = 4, BIFROST_ICMP_NEQ = 5, -- 2.30.2