From be7b3177462e9026718e6302bd49eed2ec60e7f2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 30 Sep 2021 14:32:18 +0100 Subject: [PATCH] reduce PyFnWriter compile time (pywriter) by 75% needs some explanation: the pagereader enumerates all the sub-options (Rc=1, OE=1) and adds one instruction (each) for all of the sub-options but adds the exact same pseudocode. PyFnWriter then generates up to *four copies* of the exact same pseucodode and four functions, *only one of which is actually used* by ISACaller (the one *without* Rc=1 and OE=1), then handles Rc=1 and OE=1 *separately* added an option to pagereader to only add the first-encountered instruction but for other purposes it is still added, so is not made the default --- src/openpower/decoder/pseudo/pagereader.py | 12 +++++++++++- src/openpower/decoder/pseudo/pywriter.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/openpower/decoder/pseudo/pagereader.py b/src/openpower/decoder/pseudo/pagereader.py index d5cae081..44c94b85 100644 --- a/src/openpower/decoder/pseudo/pagereader.py +++ b/src/openpower/decoder/pseudo/pagereader.py @@ -64,11 +64,13 @@ def get_isa_dir(): class ISA: - def __init__(self): + def __init__(self, first_encountered_instr=False): 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) @@ -282,6 +284,14 @@ 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/pywriter.py b/src/openpower/decoder/pseudo/pywriter.py index b01fc4cc..2b405e26 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) + ISA.__init__(self, first_encountered_instr=True) self.pages_written = [] def write_pysource(self, pagename): -- 2.30.2