# python code-writer for OpenPOWER ISA pseudo-code parsing
-
+import io
import os
import sys
import shutil
from openpower.decoder.isa.caller import create_args, create_full_args
+import openpower.oppc.pc_lexer as pc_lexer
+import openpower.oppc.pc_parser as pc_parser
+import openpower.oppc.pc_util as pc_util
+
+
def get_isasrc_dir():
fdir = os.path.abspath(os.path.dirname(__file__))
fdir = os.path.split(fdir)[0]
def __init__(self):
ISA.__init__(self)
self.pages_written = []
+ self.pc_lexer = pc_lexer.IndentLexer()
+ self.pc_parser = pc_parser.Parser(lexer=self.pc_lexer)
+
+ def normalize(self, code):
+ tree = self.pc_parser.parse(code=code)
+ with io.StringIO() as stream:
+ for (level, line) in pc_util.pseudocode(tree):
+ print(f"{' ' * 4 * level}{line}", file=stream)
+ stream.seek(0)
+ return "\n".join(stream)
+
def check_for_old_generated_files(self, pagenames):
isadir = get_isasrc_dir()
print(pcode)
incl_carry = pagename == 'fixedshift'
filename = os.path.join(get_isa_dir(), pagename + ".mdwn")
+ pcode = self.normalize(code=pcode)
+ print(pcode)
pycode, rused = convert_to_python(pcode, d.form, incl_carry,
filename=filename)
rused['uninit_regs'] |= d.extra_uninit_regs