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())
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()