Mesa (master): freedreno/isa: assert if field's range is out of bitset's range

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Mar 17 12:30:00 UTC 2021


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

Author: Danylo Piliaiev <dpiliaiev at igalia.com>
Date:   Tue Mar 16 21:04:02 2021 +0200

freedreno/isa: assert if field's range is out of bitset's range

Also, update outdated comment along the way.

Signed-off-by: Danylo Piliaiev <dpiliaiev at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9628>

---

 src/freedreno/isa/isa.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/freedreno/isa/isa.py b/src/freedreno/isa/isa.py
index 995823ab1cf..d7d148443e5 100644
--- a/src/freedreno/isa/isa.py
+++ b/src/freedreno/isa/isa.py
@@ -458,6 +458,12 @@ class ISA(object):
                 for field_name, field in case.fields.items():
                     if field.type == 'float':
                         assert field.get_size() == 32 or field.get_size() == 16
+
+                    if not isinstance(field, BitSetDerivedField):
+                        assert field.high < bitset.get_size(), \
+                            "{}.{}: invalid bit range: [{}, {}] is not in [{}, {}]".format(
+                            bitset_name, field_name, field.low, field.high, 0, bitset.get_size() - 1)
+
                     if field.type in builtin_types:
                         continue
                     if field.type in self.enums:
@@ -481,4 +487,4 @@ class ISA(object):
 
         # TODO we should probably be able to look at the contexts where
         # an expression is evaluated and verify that it doesn't have any
-        # <var/> references that would be unresolved at evaluation time
\ No newline at end of file
+        # {VARNAME} references that would be unresolved at evaluation time
\ No newline at end of file



More information about the mesa-commit mailing list