mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 15:50:11 +01:00
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@anholt.net>
This commit is contained in:
parent
9b96ae69bc
commit
c27b3758fa
1 changed files with 14 additions and 1 deletions
|
|
@ -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;
|
||||
""")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue