From: Dmitry Selyutin Date: Sun, 6 Nov 2022 09:29:55 +0000 (+0300) Subject: power_insn: provide operands helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7a156c3a0d2a1b10ebfd3e4469047396b52cbe19;p=openpower-isa.git power_insn: provide operands helpers --- diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 72aea8bd..cc5d0e5c 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -793,13 +793,18 @@ class Record: extra_idx_cr_in2 = property(lambda self: self.svp64.extra_idx_cr_in2) extra_idx_cr_out = property(lambda self: self.svp64.extra_idx_cr_out) + def __contains__(self, key): + return self.mdwn.operands.__contains__(key) + + def __getitem__(self, key): + (cls, kwargs) = self.mdwn.operands.__getitem__(key) + return cls(record=self, **kwargs) + @cached_property def Rc(self): - (cls, kwargs) = self.mdwn.operands["Rc"] - Rc = cls(record=self, **kwargs) - if Rc is None: + if "Rc" not in self: return False - return bool(Rc.value) + return bool(self["Rc"]) @_dataclasses.dataclass(eq=True, frozen=True)