pan/bi: Mark some opcodes as default round-to-zero
authorAlyssa Rosenzweig <alyssa@collabora.com>
Sun, 27 Feb 2022 20:46:03 +0000 (15:46 -0500)
committerMarge Bot <emma+marge@anholt.net>
Thu, 7 Apr 2022 18:03:57 +0000 (18:03 +0000)
Conversions to integer have different rounding rules.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15187>

src/panfrost/bifrost/bifrost_isa.py

index 89e5d6f..ba5e62a 100644 (file)
@@ -247,6 +247,12 @@ def simplify_to_ir(ins):
             'immediates': [m[0] for m in ins['immediates']]
         }
 
+# Converstions to integers default to rounding-to-zero
+# All other opcodes default to rounding to nearest even
+def default_round_to_zero(name):
+    # 8-bit int to float is exact
+    subs = ['_TO_U', '_TO_S', '_TO_V2U', '_TO_V2S', '_TO_V4U', '_TO_V4S']
+    return any([x in name for x in subs])
 
 def combine_ir_variants(instructions, key):
     seen = [op for op in instructions.keys() if op[1:] == key]
@@ -278,7 +284,8 @@ def combine_ir_variants(instructions, key):
             'immediates': sorted(variants[0]['immediates']),
             'modifiers': modifiers,
             'v': len(variants),
-            'ir': variants
+            'ir': variants,
+            'rtz': default_round_to_zero(key)
         }
 
 # Partition instructions to mnemonics, considering units and variants