From: Luke Kenneth Casson Leighton Date: Sat, 4 Apr 2020 13:39:28 +0000 (+0100) Subject: use set not list to make regs unique X-Git-Tag: div_pipeline~1532 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d3244e7d800e79687a5e0a6f0bc03b570e5a00f4;p=soc.git use set not list to make regs unique --- diff --git a/src/soc/decoder/pseudo/parser.py b/src/soc/decoder/pseudo/parser.py index 6c67265b..8b38c802 100644 --- a/src/soc/decoder/pseudo/parser.py +++ b/src/soc/decoder/pseudo/parser.py @@ -197,9 +197,9 @@ class PowerParser: self.gprs = {} for rname in ['RA', 'RB', 'RC', 'RT', 'RS']: self.gprs[rname] = None - self.read_regs = [] - self.uninit_regs = [] - self.write_regs = [] + self.read_regs = set() + self.uninit_regs = set() + self.write_regs = set() # The grammar comments come from Python's Grammar/Grammar file @@ -310,10 +310,10 @@ class PowerParser: name = p[1].value.id if name in self.gprs: # add to list of uninitialised - self.uninit_regs.append(name) + self.uninit_regs.add(name) print("expr assign", name, p[1]) if name in self.gprs: - self.write_regs.append(name) # add to list of regs to write + self.write_regs.add(name) # add to list of regs to write p[0] = Assign(p[1], p[3]) def p_flow_stmt(self, p): @@ -488,7 +488,7 @@ class PowerParser: if isinstance(p[2], ast.Name): print("tuple name", p[2].id) if p[2].id in self.gprs: - self.read_regs.append(p[2].id) # add to list of regs to read + self.read_regs.add(p[2].id) # add to list of regs to read #p[0] = ast.Subscript(ast.Name("GPR"), ast.Str(p[2].id)) # return p[0] = p[2] diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index 238ef646..6198dcd3 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -49,7 +49,7 @@ class PyISAWriter(ISA): print (pcode) pycode, rused = convert_to_python(pcode) # create list of arguments to call - regs = rused['read_regs'] + rused['uninit_regs'] + regs = list(rused['read_regs']) + list(rused['uninit_regs']) args = create_args(regs, 'self') # create list of arguments to return retargs = create_args(rused['write_regs'])