nir: add ir3-specific bitwise triop opcodes

ir3 has a number of bitwise triops (e.g., shrm == (src0 >> src1) & src2)
that don't have NIR-equivalents. Doing instruction selection for them is
a lot more convenient using algebraic patterns than to have to manually
match for them. This patch add NIR opcodes for these instructions.

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32181>
This commit is contained in:
Job Noorman 2024-11-27 17:32:56 +01:00 committed by Marge Bot
parent c51378fa6c
commit 22fc90a116

View file

@ -1267,6 +1267,16 @@ dst = ((((src0 & 0x0000ffff) << 16) * (src1 & 0xffff0000)) >> 16) + src2;
triop("imad24_ir3", tint32, _2src_commutative,
"(((int32_t)src0 << 8) >> 8) * (((int32_t)src1 << 8) >> 8) + src2")
def triop_shift_ir3(name, shift_op, bit_op):
opcode(name, 0, tuint, [0, 0, 0], [tuint, tuint32, tuint], False, "",
f"(src0 {shift_op} (src1 & (sizeof(src0) * 8 - 1))) {bit_op} src2")
triop_shift_ir3("shrm_ir3", ">>", "&")
triop_shift_ir3("shlm_ir3", "<<", "&")
triop_shift_ir3("shrg_ir3", ">>", "|")
triop_shift_ir3("shlg_ir3", "<<", "|")
triop("andg_ir3", tuint, _2src_commutative, "(src0 & src1) | src2")
# r600/gcn specific instruction that evaluates unnormalized cube texture coordinates
# and face index
# The actual texture coordinates are evaluated from this according to