Mesa (master): nir/opcodes: Add new 'umul_low' and 'imadsh_mix16' opcodes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 7 07:02:25 UTC 2019


Module: Mesa
Branch: master
Commit: c27b3758fa0dcd7fade9e85c5483b8310b8263d7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c27b3758fa0dcd7fade9e85c5483b8310b8263d7

Author: Eduardo Lima Mitev <elima at igalia.com>
Date:   Fri Mar 29 10:49:12 2019 +0100

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 <eric at anholt.net>

---

 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;
+""")




More information about the mesa-commit mailing list