From: Luke Kenneth Casson Leighton Date: Thu, 30 Sep 2021 18:31:14 +0000 (+0100) Subject: whoops, use cache of pseudocode rather than attempt to truncate X-Git-Tag: sv_maxu_works-initial~798 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3dcb48c72f00758bc646ad467c16868c84623dbf;p=openpower-isa.git whoops, use cache of pseudocode rather than attempt to truncate the list of instructions, causes them to disappear. oops --- diff --git a/src/openpower/decoder/pseudo/pagereader.py b/src/openpower/decoder/pseudo/pagereader.py index 44c94b85..d5cae081 100644 --- a/src/openpower/decoder/pseudo/pagereader.py +++ b/src/openpower/decoder/pseudo/pagereader.py @@ -64,13 +64,11 @@ def get_isa_dir(): class ISA: - def __init__(self, first_encountered_instr=False): + def __init__(self): self.instr = OrderedDict() self.forms = {} self.page = {} self.verbose = False - # only add the first-encountered instruction (marked by "*") - self.first_encountered_instr = first_encountered_instr for pth in os.listdir(os.path.join(get_isa_dir())): if self.verbose: print("examining", get_isa_dir(), pth) @@ -284,14 +282,6 @@ class ISA: # add in opcode for o in opcodes: self.add_op(o, d) - if self.first_encountered_instr: - # turns out that because the pseudocode is identical, - # you don't actually need to add any more than the - # first listed opcode for pseudocode-generation. - # therefore, save compiler time and skip all others. - # detection of "." and "o" etc is handled in ISACaller - # and ends up replicating the instruction that way - break # expect and drop whitespace while lines: diff --git a/src/openpower/decoder/pseudo/pyfnwriter.py b/src/openpower/decoder/pseudo/pyfnwriter.py index 74185b2a..001c0f0a 100644 --- a/src/openpower/decoder/pseudo/pyfnwriter.py +++ b/src/openpower/decoder/pseudo/pyfnwriter.py @@ -39,12 +39,19 @@ class PyISAFnWriter(ISAFunctions): isadir = get_isafn_src_dir() os.makedirs(isadir, exist_ok=True) fname = os.path.join(isadir, "%s.py" % pagename) + sourcecache = dict() with open(fname, "w") as f: f.write(header % function['desc']) # write out header # go through all instructions pcode = function['pcode'] print(pcode) - pycode = convert_to_pure_python(pcode, True) + # check if the code has already been compiled + phash = hash(pcode) + if phash in sourcecache: + pycode = sourcecache[phash] + else: + pycode = convert_to_pure_python(pcode, True) + sourcecache[phash] = pycode 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 2b405e26..b01fc4cc 100644 --- a/src/openpower/decoder/pseudo/pywriter.py +++ b/src/openpower/decoder/pseudo/pywriter.py @@ -53,7 +53,7 @@ iinfo_template = """instruction_info(func=%s, class PyISAWriter(ISA): def __init__(self): - ISA.__init__(self, first_encountered_instr=True) + ISA.__init__(self) self.pages_written = [] def write_pysource(self, pagename):