power_insn: provide SVP64 assembly stub
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 6 Nov 2022 16:50:14 +0000 (19:50 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:16 +0000 (19:51 +0100)
src/openpower/decoder/power_insn.py

index 87b816a24c39dc74bf0b6ff53469c869963afead..89dbbda850725721c97fbdd905196ed68fa90f19 100644 (file)
@@ -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):