From c27b3758fa0dcd7fade9e85c5483b8310b8263d7 Mon Sep 17 00:00:00 2001 From: Eduardo Lima Mitev Date: Fri, 29 Mar 2019 10:49:12 +0100 Subject: [PATCH] nir/opcodes: Add new 'umul_low' and 'imadsh_mix16' opcodes 'umul_low' is the low 32-bits of unsigned integer multiply. It maps directly to ir3's MULL_U. 'imadsh_mix16' is multiply add with shift and mix, an ir3 specific instruction that maps directly to ir3's IMADSH_M16. Both are necessary for the lowering of integer multiplication on Freedreno, which will be introduced later in this series. Reviewed-by: Eric Anholt --- src/compiler/nir/nir_opcodes.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index f6fa462cd13..1ab4a3e7a31 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -552,6 +552,13 @@ if (bit_size == 64) { } """) +# low 32-bits of unsigned integer multiply +binop("umul_low", tuint32, _2src_commutative, """ +uint64_t mask = (1 << (bit_size / 2)) - 1; +dst = ((uint64_t)src0 & mask) * ((uint64_t)src1 & mask); +""") + + binop("fdiv", tfloat, "", "src0 / src1") binop("idiv", tint, "", "src1 == 0 ? 0 : (src0 / src1)") binop("udiv", tuint, "", "src1 == 0 ? 0 : (src0 / src1)") @@ -958,4 +965,10 @@ dst.z = src2.x; dst.w = src3.x; """) - +# ir3-specific instruction that maps directly to mul-add shift high mix, +# (IMADSH_MIX16 i.e. ah * bl << 16 + c). It is used for lowering integer +# multiplication (imul) on Freedreno backend.. +opcode("imadsh_mix16", 1, tint32, + [1, 1, 1], [tint32, tint32, tint32], False, "", """ +dst.x = ((((src0.x & 0xffff0000) >> 16) * (src1.x & 0x0000ffff)) << 16) + src2.x; +""") -- 2.30.2