summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-10-19 14:03:24 -0500
committerJason Ekstrand <[email protected]>2018-10-22 16:00:18 -0500
commitea9e651423424219cae8ebdef88f432b7cff31ab (patch)
tree24872bf457f5fb8da4f8910cafa2bdaa726e126d /src/compiler
parent641f4be8e80eb1abd4d497bc136b9572062d8003 (diff)
nir/algebraic: A bit of validation refactoring'
We rename some local variables in validate() to be more readable and plumb the var through to get/set_var_bit_class instead of the var index. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_algebraic.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 39b85089b1e..34ea2ba9e68 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -333,32 +333,32 @@ class BitSizeValidator(object):
self._class_relation = IntEquivalenceRelation()
def validate(self, search, replace):
- dst_class = self._propagate_bit_size_up(search)
- if dst_class == 0:
- dst_class = self._new_class()
- self._propagate_bit_class_down(search, dst_class)
+ search_dst_class = self._propagate_bit_size_up(search)
+ if search_dst_class == 0:
+ search_dst_class = self._new_class()
+ self._propagate_bit_class_down(search, search_dst_class)
- validate_dst_class = self._validate_bit_class_up(replace)
- assert validate_dst_class == 0 or validate_dst_class == dst_class
- self._validate_bit_class_down(replace, dst_class)
+ replace_dst_class = self._validate_bit_class_up(replace)
+ assert replace_dst_class == 0 or replace_dst_class == search_dst_class
+ self._validate_bit_class_down(replace, search_dst_class)
def _new_class(self):
self._num_classes += 1
return -self._num_classes
- def _set_var_bit_class(self, var_id, bit_class):
+ def _set_var_bit_class(self, var, bit_class):
assert bit_class != 0
- var_class = self._var_classes[var_id]
+ var_class = self._var_classes[var.index]
if var_class == 0:
- self._var_classes[var_id] = bit_class
+ self._var_classes[var.index] = bit_class
else:
canon_class = self._class_relation.get_canonical(var_class)
assert canon_class < 0 or canon_class == bit_class
var_class = self._class_relation.add_equiv(var_class, bit_class)
- self._var_classes[var_id] = var_class
+ self._var_classes[var.index] = var_class
- def _get_var_bit_class(self, var_id):
- return self._class_relation.get_canonical(self._var_classes[var_id])
+ def _get_var_bit_class(self, var):
+ return self._class_relation.get_canonical(self._var_classes[var.index])
def _propagate_bit_size_up(self, val):
if isinstance(val, (Constant, Variable)):
@@ -396,7 +396,7 @@ class BitSizeValidator(object):
elif isinstance(val, Variable):
assert val.bit_size == 0 or val.bit_size == bit_class
- self._set_var_bit_class(val.index, bit_class)
+ self._set_var_bit_class(val, bit_class)
elif isinstance(val, Expression):
nir_op = opcodes[val.opcode]
@@ -426,7 +426,7 @@ class BitSizeValidator(object):
return val.bit_size
elif isinstance(val, Variable):
- var_class = self._get_var_bit_class(val.index)
+ var_class = self._get_var_bit_class(val)
# By the time we get to validation, every variable should have a class
assert var_class != 0