From 11363547c27d0d011ac97cbe98747c2cf6310c22 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 4 Apr 2020 13:52:03 +0100 Subject: [PATCH] add "op_" prefix to function names to avoid use of python keywords --- src/soc/decoder/pseudo/pywriter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/soc/decoder/pseudo/pywriter.py b/src/soc/decoder/pseudo/pywriter.py index 600c1123..340a8cc9 100644 --- a/src/soc/decoder/pseudo/pywriter.py +++ b/src/soc/decoder/pseudo/pywriter.py @@ -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) -- 2.30.2