add "op_" prefix to function names to avoid use of python keywords
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Apr 2020 12:52:03 +0000 (13:52 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Apr 2020 12:52:03 +0000 (13:52 +0100)
src/soc/decoder/pseudo/pywriter.py

index 600c11233809b3e314cbe998fa4e616283319d45..340a8cc9814574ac2cdd1239eba0e05873bf7c4d 100644 (file)
@@ -51,7 +51,9 @@ class PyISAWriter(ISA):
                 args = create_args(regs, 'self')
                 # create list of arguments to return
                 retargs = create_args(rused['write_regs'])
-                f.write("    def %s(%s):\n" % (page.replace(".", "_"), args))
+                # write out function.  pre-pend "op_" because some instrs are
+                # also python keywords (cmp).  also replace "." with "_"
+                f.write("    def op_%s(%s):\n" % (page.replace(".", "_"), args))
                 pycode = pycode.split("\n")
                 pycode = '\n'.join(map(lambda x: "        %s" % x, pycode))
                 pycode = pycode.rstrip()
@@ -61,10 +63,10 @@ class PyISAWriter(ISA):
                 else:
                     f.write("\n")
                 # accumulate the instruction info
-                iinfo = "(%s, %s, %s, %s)" % \
+                iinfo = "(op_%s, %s, %s, %s)" % \
                             (page, rused['read_regs'],
                             rused['uninit_regs'], rused['write_regs'])
-                iinf += "    instrs['%s'] = %s\n" % (pagename, iinfo)
+                iinf += "    instrs['%s'] = %s\n" % (page, iinfo)
             # write out initialisation of info, for ISACaller to use
             f.write("    instrs = {}\n")
             f.write(iinf)