From bf1ccc067a859d2c9a919a410169ac67e95de6e8 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Mon, 27 Sep 2021 20:12:46 +0000 Subject: [PATCH] pywriter, pyfnwriter, parser: activate helper class --- src/openpower/decoder/pseudo/parser.py | 35 ++++------------------ src/openpower/decoder/pseudo/pyfnwriter.py | 13 ++------ src/openpower/decoder/pseudo/pywriter.py | 10 ++----- 3 files changed, 9 insertions(+), 49 deletions(-) diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index cc7f1292..70e87374 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -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) diff --git a/src/openpower/decoder/pseudo/pyfnwriter.py b/src/openpower/decoder/pseudo/pyfnwriter.py index 5d0eabb3..5de36d38 100644 --- a/src/openpower/decoder/pseudo/pyfnwriter.py +++ b/src/openpower/decoder/pseudo/pyfnwriter.py @@ -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): diff --git a/src/openpower/decoder/pseudo/pywriter.py b/src/openpower/decoder/pseudo/pywriter.py index e883b326..dafe6122 100644 --- a/src/openpower/decoder/pseudo/pywriter.py +++ b/src/openpower/decoder/pseudo/pywriter.py @@ -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 """ -- 2.30.2