mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
panfrost/midgard: Add missing lowering passes for type/size conversion ops
Replace the manual type/size conversion lowering description by one that's automatically generated and covers all type/size conversions. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3478> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3478>
This commit is contained in:
parent
fcceeaffae
commit
5b810c7de3
1 changed files with 33 additions and 12 deletions
|
|
@ -48,19 +48,40 @@ algebraic_late = [
|
|||
# Midgard is able to type convert down by only one "step" per instruction; if
|
||||
# NIR wants more than one step, we need to break up into multiple instructions
|
||||
|
||||
converts = [
|
||||
(('i2i8', 'a@32'), ('i2i8', ('i2i16', a))),
|
||||
(('u2u8', 'a@32'), ('u2u8', ('u2u16', a))),
|
||||
converts = []
|
||||
|
||||
(('i2i32', 'a@8'), ('i2i32', ('i2i16', a))),
|
||||
(('u2u32', 'a@8'), ('u2u32', ('u2u16', a))),
|
||||
|
||||
(('f2i32', 'a@16'), ('f2i32', ('f2f32', a))),
|
||||
(('f2u32', 'a@16'), ('f2u32', ('f2f32', a))),
|
||||
|
||||
# Totally redundant
|
||||
(('~f2f16', ('f2f32', 'a@16')), a),
|
||||
]
|
||||
for op in ('u2u', 'i2i', 'f2f', 'i2f', 'u2f', 'f2i', 'f2u'):
|
||||
srcsz_max = 64
|
||||
dstsz_max = 64
|
||||
# 8 bit float doesn't exist
|
||||
srcsz_min = 8 if op[0] != 'f' else 16
|
||||
dstsz_min = 8 if op[2] != 'f' else 16
|
||||
dstsz = dstsz_min
|
||||
# Iterate over all possible destination and source sizes
|
||||
while dstsz <= dstsz_max:
|
||||
srcsz = srcsz_min
|
||||
while srcsz <= srcsz_max:
|
||||
# Size converter lowering is only needed if src and dst sizes are
|
||||
# spaced by a factor > 2.
|
||||
# Type converter lowering is needed as soon as src_size != dst_size
|
||||
if srcsz != dstsz and ((srcsz * 2 != dstsz and srcsz != dstsz * 2) or op[0] != op[2]):
|
||||
cursz = srcsz
|
||||
rule = a
|
||||
# When converting down we first do the type conversion followed
|
||||
# by one or more size conversions. When converting up, we do
|
||||
# the type conversion at the end. This way we don't have to
|
||||
# deal with the fact that f2f8 doesn't exists.
|
||||
sizeconvop = op[0] + '2' + op[0] if srcsz < dstsz else op[2] + '2' + op[2]
|
||||
if srcsz > dstsz and op[0] != op[2]:
|
||||
rule = (op + str(int(cursz)), rule)
|
||||
while cursz != dstsz:
|
||||
cursz = cursz / 2 if dstsz < srcsz else cursz * 2
|
||||
rule = (sizeconvop + str(int(cursz)), rule)
|
||||
if srcsz < dstsz and op[0] != op[2]:
|
||||
rule = (op + str(int(cursz)), rule)
|
||||
converts += [((op + str(int(dstsz)), 'a@' + str(int(srcsz))), rule)]
|
||||
srcsz *= 2
|
||||
dstsz *= 2
|
||||
|
||||
# Midgard scales fsin/fcos arguments by pi.
|
||||
# Pass must be run only once, after the main loop
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue