power_insn: provide basics for insndb assembly
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 6 Nov 2022 09:29:55 +0000 (12:29 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:16 +0000 (19:51 +0100)
src/openpower/sv/trans/svp64.py

index c61e92833d696d46c50bf715c898b33a3100aa49..12bef488a6c1ff12a22ccc5dea2a2103bb251345 100644 (file)
@@ -30,6 +30,7 @@ from openpower.decoder.selectable_int import SelectableInt
 from openpower.consts import SVP64MODE
 from openpower.decoder.power_insn import SVP64Instruction
 from openpower.decoder.power_insn import Database
+from openpower.decoder.power_insn import WordInstruction
 from openpower.decoder.power_enums import find_wiki_dir
 
 # for debug logging
@@ -821,7 +822,7 @@ def to_number(field):
     return int(field)
 
 
-db = Database(find_wiki_dir())
+DB = Database(find_wiki_dir())
 
 
 # decodes svp64 assembly listings and creates EXT001 svp64 prefixes
@@ -859,7 +860,19 @@ class SVP64Asm:
             fields.append(macro_subst(macros, field))
         log("opcode, fields substed", ls, opcode, fields)
 
-        # identify if it is a special instruction
+        # identify if it is a word instruction
+        record = DB[opcode]
+        if record is not None:
+            insn = WordInstruction.assemble(db=DB,
+                opcode=opcode, arguments=fields)
+            yield " ".join((
+                f".long 0x{int(insn):08X}",
+                "#",
+                opcode,
+                ",".join(fields),
+            ))
+            return
+
         custom_insn_hook = CUSTOM_INSNS.get(opcode)
         if custom_insn_hook is not None:
             fields = tuple(map(to_number, fields))