From c1b1380f8245bd0726a2892809299e0f079cd288 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Mon, 17 Jan 2022 16:32:39 -0800 Subject: [PATCH] speed up pywriter --- src/openpower/decoder/pseudo/parser.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index de266840..51fd100a 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -288,12 +288,10 @@ class PowerParser: ("left", "INVERT"), ) - def __init__(self, form, include_carry_in_write=False, helper=False): - self.include_ca_in_write = include_carry_in_write - self.helper = helper + def reset(self): self.gprs = {} - if form is not None: - form = self.sd.sigforms[form] + if self.form is not None: + form = self.sd.sigforms[self.form] print(form) formkeys = form._asdict().keys() else: @@ -315,6 +313,12 @@ class PowerParser: self.write_regs = OrderedSet() self.special_regs = OrderedSet() # see p_atom_name + def __init__(self, form, include_carry_in_write=False, helper=False): + self.include_ca_in_write = include_carry_in_write + self.helper = helper + self.form = form + self.reset() + # The grammar comments come from Python's Grammar/Grammar file # NB: compound_stmt in single_input is followed by extra NEWLINE! @@ -941,6 +945,7 @@ class GardenSnakeParser(PowerParser): debug=debug, write_tables=False) def parse(self, code): + self.reset() result = self.parser.parse(code, lexer=self.lexer, debug=self.debug) if self.helper: result = [ast.ClassDef("ISACallerFnHelper", [ -- 2.30.2