summaryrefslogtreecommitdiffstats
path: root/src/panfrost/midgard
diff options
context:
space:
mode:
authorBoris Brezillon <[email protected]>2020-01-20 22:02:40 +0100
committerMarge Bot <[email protected]>2020-01-22 15:31:28 +0000
commit5b810c7de303e32900fed18b1303648eb74a6415 (patch)
tree94f95808e51d9fd40a370213a978d5af6449443a /src/panfrost/midgard
parentfcceeaffaef8d10a96e5b3171ed5d9be25a15001 (diff)
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 <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3478> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3478>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r--src/panfrost/midgard/midgard_nir_algebraic.py47
1 files changed, 34 insertions, 13 deletions
diff --git a/src/panfrost/midgard/midgard_nir_algebraic.py b/src/panfrost/midgard/midgard_nir_algebraic.py
index 951b4b23241..2ba9f226d22 100644
--- a/src/panfrost/midgard/midgard_nir_algebraic.py
+++ b/src/panfrost/midgard/midgard_nir_algebraic.py
@@ -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))),
-
- (('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),
-]
+converts = []
+
+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