From: Dmitry Selyutin Date: Tue, 16 Jan 2024 19:09:45 +0000 (+0300) Subject: oppc: refactor output X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f63b1c7d45ffafb8c7af6740ec6fb9586080686e;p=openpower-isa.git oppc: refactor output --- diff --git a/src/openpower/oppc/__main__.py b/src/openpower/oppc/__main__.py index e3a12f96..846f3ab8 100644 --- a/src/openpower/oppc/__main__.py +++ b/src/openpower/oppc/__main__.py @@ -13,6 +13,7 @@ import openpower.oppc.pc_parser as pc_parser import openpower.oppc.pc_pseudocode as pc_pseudocode +table = {} lexer = pc_lexer.IndentLexer(debug=False) parser = pc_parser.Parser(lexer=lexer) db = Database(find_wiki_dir()) @@ -21,19 +22,18 @@ for insn in db: continue try: tree = parser.parse(code="\n".join(insn.pcode)) - for (level, line) in pc_code.code(insn=insn, root=tree): - print(f"{' ' * 4 * level}{line}") + code = pc_code.code(insn=insn, root=tree) + handler = ("oppc_handler_" + insn.name.replace(".", "_")) + table[handler] = code except Exception as exc: print(insn.name) print(insn.pcode) raise exc -insn = db["tdi"] -code = "\n".join(insn.pcode) -tree = parser.parse(code=code) -print(tree) -for (level, line) in pc_pseudocode.pseudocode(tree): - print(f"{' ' * 4 * level}{line}") - -for (level, line) in pc_code.code(insn=insn, root=tree): - print(f"{' ' * 4 * level}{line}") +for (handler, code) in table.items(): + print("void") + print(f"{handler}(struct oppc_value const *insn) {{") + for (level, line) in code: + print(f"{' ' * 4 * (level + 1)}{line}") + print(f"}}") + print()