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=86d75f7e890270aff5588916db15a10bcec7df52;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)