From 86d75f7e890270aff5588916db15a10bcec7df52 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 6 Nov 2022 12:29:55 +0300 Subject: [PATCH] power_insn: provide operands helpers --- src/openpower/decoder/power_insn.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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) -- 2.30.2