args = [extra] + args
return ', '.join(args)
+header = """\
+# auto-generated by pywriter.py, do not edit or commit
+
+from soc.decoder.isa import ISACaller
+from soc.decoder.helpers import (EXTS64, EXTZ64, ROTL64, ROTL32, MASK,)
+
+class %s(ISACaller):
+"""
class PyISAWriter(ISA):
def __init__(self):
fname = os.path.join(isadir, "%s.py" % pagename)
with open(fname, "w") as f:
iinf = ''
- f.write("# auto-generated by pywriter.py, do not edit or commit\n")
- f.write("from soc.decoder.isa import ISACaller\n\n")
- f.write("from soc.decoder.helpers import " + \
- "(EXTS64, EXTZ64, ROTL64, ROTL32, MASK,)\n")
-
- f.write("class %s(ISACaller):\n" % pagename)
+ f.write(header % pagename) # write out header
+ # go through all instructions
for page in instrs:
d = self.instr[page]
print (fname, d.opcode)
f.write(" return (%s,)\n\n" % retargs)
else:
f.write("\n")
- # cumulate the instruction info
+ # accumulate the instruction info
iinfo = "(%s, %s, %s, %s)" % \
- (pagename, rused['read_regs'],
+ (page, rused['read_regs'],
rused['uninit_regs'], rused['write_regs'])
iinf += " instrs['%s'] = %s\n" % (pagename, iinfo)
+ # write out initialisation of info, for ISACaller to use
f.write(" instrs = {}\n")
f.write(iinf)