From 2a8ec3fd69bf41596fb65835b990cb289df38fe9 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 6 Nov 2022 19:50:14 +0300 Subject: [PATCH] power_insn: provide SVP64 assembly stub --- src/openpower/decoder/power_insn.py | 42 ++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 87b816a2..89dbbda8 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -1391,6 +1391,18 @@ class WordInstruction(Instruction): _: _Field = range(0, 32) PO: _Field = range(0, 6) + @classmethod + def integer(cls, value, byteorder="little"): + return super().integer(bits=32, value=value, byteorder=byteorder) + + @property + def binary(self): + bits = [] + for idx in range(32): + bit = int(self[idx]) + bits.append(bit) + return "".join(map(str, bits)) + @classmethod def assemble(cls, db, opcode, arguments): record = db[opcode] @@ -1406,18 +1418,6 @@ class WordInstruction(Instruction): return insn - @classmethod - def integer(cls, value, byteorder="little"): - return super().integer(bits=32, value=value, byteorder=byteorder) - - @property - def binary(self): - bits = [] - for idx in range(32): - bit = int(self[idx]) - bits.append(bit) - return "".join(map(str, bits)) - def disassemble(self, db, byteorder="little", verbosity=Verbosity.NORMAL): @@ -2261,6 +2261,24 @@ class SVP64Instruction(PrefixedInstruction): bits.append(bit) return "".join(map(str, bits)) + @classmethod + def assemble(cls, db, opcode, arguments): + record = db[opcode] + insn = cls.integer(value=0) + for operand in record.static_operands: + operand.assemble(insn=insn) + + dynamic_operands = tuple(record.dynamic_operands) + if len(dynamic_operands) != len(arguments): + raise ValueError("operands count mismatch") + for (value, operand) in zip(arguments, dynamic_operands): + operand.assemble(value=value, insn=insn) + + insn.prefix.PO = 0x1 + insn.prefix.id = 0x3 + + return insn + def disassemble(self, db, byteorder="little", verbosity=Verbosity.NORMAL): -- 2.30.2