From: Dmitry Selyutin Date: Sat, 17 Sep 2022 19:54:02 +0000 (+0300) Subject: power_fields: support boolean checks X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2f00719724cf04bede94ad2fd52e4875f030663;p=openpower-isa.git power_fields: support boolean checks --- diff --git a/src/openpower/decoder/power_fields.py b/src/openpower/decoder/power_fields.py index 7530e456..f69f7855 100644 --- a/src/openpower/decoder/power_fields.py +++ b/src/openpower/decoder/power_fields.py @@ -71,6 +71,9 @@ class Reference: def __eq__(self, other): return self.__binary_operator(_operator.eq, other) + def __bool__(self): + return bool(int(self)) + def __int__(self): span = dict.fromkeys(self.__class__.span).keys() return int(_selectconcat(*(self.storage[bit] for bit in span)))