agx: Add pseudo-instructions for icmp/fcmp

Easier to optimize with.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25052>
This commit is contained in:
Alyssa Rosenzweig
2023-08-30 09:40:54 -04:00
committed by Marge Bot
parent 139e56c0db
commit ed6e391349
2 changed files with 15 additions and 0 deletions
+11
View File
@@ -65,6 +65,17 @@ lower(agx_builder *b, agx_instr *I)
case AGX_OPCODE_OR:
return agx_bitop_to(b, I->dest[0], I->src[0], I->src[1], AGX_BITOP_OR);
/* Unfused comparisons are fused with a 0/1 select */
case AGX_OPCODE_ICMP:
return agx_icmpsel_to(b, I->dest[0], I->src[0], I->src[1],
agx_immediate(I->invert_cond ? 0 : 1),
agx_immediate(I->invert_cond ? 1 : 0), I->icond);
case AGX_OPCODE_FCMP:
return agx_fcmpsel_to(b, I->dest[0], I->src[0], I->src[1],
agx_immediate(I->invert_cond ? 0 : 1),
agx_immediate(I->invert_cond ? 1 : 0), I->fcond);
/* Writes to the nesting counter lowered to the real register */
case AGX_OPCODE_BEGIN_CF:
return agx_mov_imm_to(b, agx_register(0, AGX_SIZE_16), 0);
+4
View File
@@ -251,6 +251,10 @@ op("fcmpsel",
encoding_32 = (0x02, 0x7F, 8, 10),
srcs = 4, imms = [FCOND])
# Pseudo-instructions for compares returning 1/0
op("icmp", _, srcs = 2, imms = [ICOND, INVERT_COND])
op("fcmp", _, srcs = 2, imms = [FCOND, INVERT_COND])
# sources are coordinates, LOD, texture bindless base (zero for texture state
# registers), texture, sampler, shadow/offset
# TODO: anything else?