whoops swap regs and form
[soc.git] / src / soc / decoder / pseudo / pywriter.py
index a1629aaab0c10e72958eb534b0b4ef8e98ff241d..c33f944cad45348a16307a3ce863aa5b6fffa513 100644 (file)
@@ -1,6 +1,7 @@
 # python code-writer for OpenPOWER ISA pseudo-code parsing
 
 import os
+import sys
 from soc.decoder.pseudo.pagereader import ISA
 from soc.decoder.power_pseudo import convert_to_python
 from soc.decoder.orderedset import OrderedSet
@@ -25,6 +26,11 @@ class %s:
 
 """
 
+iinfo_template = """(%s, %s,
+                %s, %s,
+                %s, '%s',
+                %s)"""
+
 class PyISAWriter(ISA):
     def __init__(self):
         ISA.__init__(self)
@@ -44,7 +50,7 @@ class PyISAWriter(ISA):
                 print (fname, d.opcode)
                 pcode = '\n'.join(d.pcode) + '\n'
                 print (pcode)
-                pycode, rused = convert_to_python(pcode)
+                pycode, rused = convert_to_python(pcode, d.form)
                 # create list of arguments to call
                 regs = list(rused['read_regs']) + list(rused['uninit_regs'])
                 args = ', '.join(create_args(regs, 'self'))
@@ -64,10 +70,10 @@ class PyISAWriter(ISA):
                 else:
                     f.write("\n")
                 # accumulate the instruction info
-                iinfo = "(%s, %s,\n                %s, %s, '%s')" % \
-                            (op_fname, rused['read_regs'],
-                            rused['uninit_regs'], rused['write_regs'],
-                            d.form)
+                ops = repr(rused['op_fields'])
+                iinfo = iinfo_template % (op_fname, rused['read_regs'],
+                                rused['uninit_regs'], rused['write_regs'],
+                                ops, d.regs, d.form)
                 iinf += "    %s_instrs['%s'] = %s\n" % (pagename, page, iinfo)
             # write out initialisation of info, for ISACaller to use
             f.write("    %s_instrs = {}\n" % pagename)
@@ -93,22 +99,13 @@ class PyISAWriter(ISA):
             f.write('        }\n')
 
 
-
-
-
 if __name__ == '__main__':
     isa = PyISAWriter()
-    isa.write_pysource('sprset')
-    #isa.write_pysource('system')
-    exit(0)
-    isa.write_pysource('stringldst')
-    isa.write_pysource('fixedshift')
-    isa.write_pysource('condition')
-    isa.write_pysource('fixedtrap')
-    isa.write_pysource('branch')
-    isa.write_pysource('fixedlogical')
-    isa.write_pysource('fixedstore')
-    isa.write_pysource('fixedload')
-    isa.write_pysource('comparefixed')
-    isa.write_pysource('fixedarith')
+    if len(sys.argv) == 1: # quick way to do it
+        print (dir(isa))
+        sources = isa.page.keys()
+    else:
+        sources = sys.argv[1:]
+    for source in sources:
+        isa.write_pysource(source)
     isa.write_isa_class()