From a8387e23437f4187df4145160de7be2f71b0c3fe Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 17 Sep 2022 18:42:17 +0300 Subject: [PATCH] selectable_int: drop redundant operators --- src/openpower/decoder/selectable_int.py | 38 ++----------------------- 1 file changed, 3 insertions(+), 35 deletions(-) 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): -- 2.30.2