From: Dmitry Selyutin Date: Sun, 6 Nov 2022 09:29:55 +0000 (+0300) Subject: power_insn: introduce record operands helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7effd4fd47a0bddef31db3eee860149955b767d0;p=openpower-isa.git power_insn: introduce record operands helpers --- diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 9217ceb9..13005511 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -669,6 +669,16 @@ class Record: rhs = (min(other.opcodes), other.name) return (lhs < rhs) + @property + def static_operands(self): + for (cls, kwargs) in self.mdwn.operands.static: + yield cls(record=self, **kwargs) + + @property + def dynamic_operands(self): + for (cls, kwargs) in self.mdwn.operands.dynamic: + yield cls(record=self, **kwargs) + @property def opcodes(self): def opcode(ppc): @@ -686,8 +696,7 @@ class Record: value[dst] = int((XO.value & (1 << src)) != 0) mask[dst] = int((XO.mask & (1 << src)) != 0) - for (cls, kwargs) in self.mdwn.operands.static: - operand = cls(record=self, **kwargs) + for operand in self.static_operands: for (src, dst) in enumerate(reversed(operand.span)): value[dst] = int((operand.value & (1 << src)) != 0) mask[dst] = 1 @@ -1220,8 +1229,7 @@ class Instruction(_Mapping): imm = False imm_name = "" imm_value = "" - for (cls, kwargs) in record.mdwn.operands.dynamic: - operand = cls(record=record, **kwargs) + for operand in record.dynamic_operands: name = operand.name value = " ".join(operand.disassemble(insn=self, record=record, verbosity=min(verbosity, Verbosity.NORMAL))) @@ -1238,8 +1246,7 @@ class Instruction(_Mapping): def static_operands(self, db): record = self.record(db=db) - for (cls, kwargs) in record.mdwn.operands.static: - operand = cls(record=record, **kwargs) + for operand in record.static_operands: yield (operand.name, operand.value) @classmethod