From 22fc90a116a36668ec6459e09975c6c7d49a697e Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Wed, 27 Nov 2024 17:32:56 +0100 Subject: [PATCH] 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 Reviewed-by: Rob Clark Part-of: --- src/compiler/nir/nir_opcodes.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 7c2cb5b67ba..05786b7397b 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -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