From: Dmitry Selyutin Date: Sat, 17 Sep 2022 15:42:17 +0000 (+0300) Subject: selectable_int: drop redundant operators X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8387e23437f4187df4145160de7be2f71b0c3fe;p=openpower-isa.git selectable_int: drop redundant operators --- diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index c4e45865..9469aca2 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -225,6 +225,7 @@ class FieldSelectableIntTestCase(unittest.TestCase): self.assertEqual(fs.get_range(), 0b1011) +@functools.total_ordering class SelectableInt: """SelectableInt - a class that behaves exactly like python int @@ -449,41 +450,8 @@ class SelectableInt: for (src, dst) in enumerate(bits): self[dst] = value[src] - def __ge__(self, other): - if isinstance(other, FieldSelectableInt): - other = other.get_range() - if isinstance(other, SelectableInt): - other = check_extsign(self, other) - assert other.bits == self.bits - other = other.to_signed_int() - if isinstance(other, int): - return onebit(self.to_signed_int() >= other) - assert False - - def __le__(self, other): - if isinstance(other, FieldSelectableInt): - other = other.get_range() - if isinstance(other, SelectableInt): - other = check_extsign(self, other) - assert other.bits == self.bits - other = other.to_signed_int() - if isinstance(other, int): - return onebit(self.to_signed_int() <= other) - assert False - - def __gt__(self, other): - if isinstance(other, FieldSelectableInt): - other = other.get_range() - if isinstance(other, SelectableInt): - other = check_extsign(self, other) - assert other.bits == self.bits - other = other.to_signed_int() - if isinstance(other, int): - return onebit(self.to_signed_int() > other) - assert False - def __lt__(self, other): - log ("SelectableInt lt", self, other) + log ("SelectableInt __lt__", self, other) if isinstance(other, FieldSelectableInt): other = other.get_range() if isinstance(other, SelectableInt): @@ -498,7 +466,7 @@ class SelectableInt: assert False def __eq__(self, other): - log("__eq__", self, other) + log("SelectableInt __eq__", self, other) if isinstance(other, FieldSelectableInt): other = other.get_range() if isinstance(other, SelectableInt):