pyfnwriter: write helper class
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Mon, 27 Sep 2021 20:10:32 +0000 (20:10 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 28 Sep 2021 11:09:07 +0000 (12:09 +0100)
src/openpower/decoder/pseudo/pyfnwriter.py

index c277b112caa9a2968000e899f5695846027de6f0..5d0eabb320daff9ddb31e5ecf2727e37d334a308 100644 (file)
@@ -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()