From 4d9c8ea968f42325122915a1d9ac6d6f9056a6fe Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Mon, 27 Sep 2021 20:10:32 +0000 Subject: [PATCH] pyfnwriter: write helper class --- src/openpower/decoder/pseudo/pyfnwriter.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/openpower/decoder/pseudo/pyfnwriter.py b/src/openpower/decoder/pseudo/pyfnwriter.py index c277b112..5d0eabb3 100644 --- a/src/openpower/decoder/pseudo/pyfnwriter.py +++ b/src/openpower/decoder/pseudo/pyfnwriter.py @@ -53,6 +53,24 @@ class PyISAFnWriter(ISAFunctions): pycode = convert_to_pure_python(pcode) f.write(pycode) + def write_isa_class(self): + isadir = get_isafn_src_dir() + fname = os.path.join(isadir, "all.py") + + with open(fname, "w") as f: + helpers = [] + f.write('# auto-generated by pyfnwriter.py: do not edit or commit\n') + f.write('from openpower.decoder.helpers import ISACallerHelper\n') + for page in self.pages_written: + module = 'openpower.decoder.isafunctions.' + page + helper = 'ISACallerFnHelper_' + page + helpers.append(helper) + f.write('from %s import ISACallerFnHelper as %s\n' % (module, helper)) + f.write('\n') + f.write('\n') + f.write('class ISACallerFnHelper(%s):\n' % ', '.join(helpers + ['ISACallerHelper'])) + f.write(' pass\n') + def pyfnwriter(): isa = PyISAFnWriter() @@ -68,6 +86,8 @@ def pyfnwriter(): print ("sources", write_isa_class, sources) for source in sources: isa.write_pysource(source) + if write_isa_class: + isa.write_isa_class() if __name__ == '__main__': pyfnwriter() -- 2.30.2