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

index cc7f129221f386c33e278a1ed8085c66b5bd88ee..70e87374420301415707fa6edfa1a18293319635 100644 (file)
@@ -25,32 +25,7 @@ import ast
 
 regs = ['RA', 'RS', 'RB', 'RC', 'RT']
 fregs = ['FRA', 'FRS', 'FRB', 'FRC', 'FRT', 'FRS']
-HELPERS = {
-    "EXTS",
-    "EXTS128",
-    "EXTS64",
-    "EXTZ64",
-    "FPADD32",
-    "FPADD64",
-    "FPCOS32",
-    "FPDIV32",
-    "FPDIV64",
-    "FPMUL32",
-    "FPMUL64",
-    "FPMULADD32",
-    "FPSIN32",
-    "FPSUB32",
-    "FPSUB64",
-    "MASK",
-    "MASK32",
-    "MULS",
-    "ROTL32",
-    "ROTL64",
-    "SHL64",
-    "SINGLE",
-    "SVSTATE_NEXT",
-    "TRAP",
-}
+SPECIAL_HELPERS = {'concat', 'MEM', 'GPR', 'FPR', 'SPR'}
 
 def Assign(autoassign, assignname, left, right, iea_mode):
     names = []
@@ -241,8 +216,8 @@ def apply_trailer(atom, trailer, read_regs):
                 name = arg.id
                 if name in regs + fregs:
                     read_regs.add(name)
-        # special-case, these functions must be made "self.xxxx"
-        if atom.id in HELPERS:
+        # special-case, these functions must NOT be made "self.xxxx"
+        if atom.id not in SPECIAL_HELPERS:
             name = ast.Name("self", ast.Load())
             atom = ast.Attribute(name, atom, ast.Load())
         return ast.Call(atom, trailer[1], [])
@@ -439,7 +414,7 @@ class PowerParser:
                       | expr_stmt"""
         if isinstance(p[1], ast.Call):
             p[0] = ast.Expr(p[1])
-        elif isinstance(p[1], ast.Name) and p[1].id in HELPERS:
+        elif isinstance(p[1], ast.Name) and p[1].id not in SPECIAL_HELPERS:
             fname = p[1].id
             name = ast.Name("self", ast.Load())
             name = ast.Attribute(name, fname, ast.Load())
@@ -953,7 +928,7 @@ class GardenSnakeParser(PowerParser):
         # self.lexer.input(code)
         result = self.parser.parse(code, lexer=self.lexer, debug=self.debug)
         if self.helper:
-            result = [ast.ClassDef("ISACallerFnHelper", [], [], result, decorator_list=[])]
+            result = [ast.ClassDef("ISACallerFnHelper", ["ISACallerHelper"], [], result, decorator_list=[])]
         return ast.Module(result)
 
 
index 5d0eabb320daff9ddb31e5ecf2727e37d334a308..5de36d38558b04f51754c406df816b99d79ffd11 100644 (file)
@@ -17,16 +17,7 @@ def get_isafn_src_dir():
 header = """\
 # auto-generated by pyfnwriter.py, do not edit or commit
 
-from openpower.decoder.isa.caller import inject
-from openpower.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32,
-                                 MASK, MASK32,
-                                 ne, eq, gt, ge, lt, le, ltu, gtu, length,
-                                 trunc_divs, trunc_rems, MULS, DIVS, MODS,
-                                 EXTS128, undefined,
-                                 SINGLE,
-                                 FPADD32, FPSUB32, FPMUL32, FPDIV32,
-                                 FPADD64, FPSUB64, FPMUL64, FPDIV64,
-                                )
+from openpower.decoder.helpers import ISACallerHelper
 from openpower.decoder.selectable_int import SelectableInt
 from openpower.decoder.selectable_int import selectconcat as concat
 
@@ -50,7 +41,7 @@ class PyISAFnWriter(ISAFunctions):
             # go through all instructions
             pcode = function['pcode']
             print(pcode)
-            pycode = convert_to_pure_python(pcode)
+            pycode = convert_to_pure_python(pcode, True)
             f.write(pycode)
 
     def write_isa_class(self):
index e883b326a66148160580e775395344b457663b33..dafe6122eb89890a379e9ea44537cf7bdc8935cd 100644 (file)
@@ -20,19 +20,15 @@ header = """\
 # auto-generated by pywriter.py, do not edit or commit
 
 from openpower.decoder.isa.caller import inject, instruction_info
-from openpower.decoder.helpers import (EXTS, EXTS64, EXTZ64, ROTL64, ROTL32,
-                                 MASK, MASK32,
+from openpower.decoder.helpers import (
                                  ne, eq, gt, ge, lt, le, ltu, gtu, length,
-                                 trunc_divs, trunc_rems, MULS, DIVS, MODS,
-                                 EXTS128, undefined,
-                                 bitrev, SHL64,
                                  RANGE,
                                  ISACallerHelper,
                                 )
 from openpower.decoder.selectable_int import SelectableInt
 from openpower.decoder.selectable_int import selectconcat as concat
 from openpower.decoder.orderedset import OrderedSet
-from openpower.decoder.isafunctions.bcd import BCD_TO_DPD, DPD_TO_BCD
+from openpower.decoder.isafunctions.all import ISACallerFnHelper
 
 """
 
@@ -44,8 +40,6 @@ from openpower.decoder.helpers import (
                                  FPMULADD32,
                                  FPSIN32, FPCOS32,
                                 )
-from openpower.decoder.isafunctions.fpfromint import INT2FP
-from openpower.decoder.isafunctions.double2single import DOUBLE
 
 """