speed up pywriter
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 18 Jan 2022 00:32:39 +0000 (16:32 -0800)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 18 Jan 2022 00:32:39 +0000 (16:32 -0800)
src/openpower/decoder/pseudo/parser.py

index de2668401fc1cc85a89702ee643157ccf9017e67..51fd100ad0164521c120488d9a762c3107a08672 100644 (file)
@@ -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", [