diff python/zcc.py @ 316:56e6ff84f646

Fixed burn led demo
author Windel Bouwman
date Sat, 21 Dec 2013 13:13:26 +0100
parents 084cccaa5deb
children e30a77ae359b
line wrap: on
line diff
--- a/python/zcc.py	Sat Dec 21 10:03:01 2013 +0100
+++ b/python/zcc.py	Sat Dec 21 13:13:26 2013 +0100
@@ -13,6 +13,7 @@
 import target
 from ppci import irutils
 import io
+from ppci.transform import CleanPass
 
 
 logformat='%(asctime)s|%(levelname)s|%(name)s|%(message)s'
@@ -79,6 +80,7 @@
             print('.. graphviz::', file=f)
             print('', file=f)
             print('  digraph G {', file=f)
+            print('    size="8,80";', file=f)
             cfg = record.ra_cfg
             cfg.to_dot(f)
             print('  }', file=f)
@@ -91,11 +93,22 @@
             print('.. graphviz::', file=f)
             print('', file=f)
             print('  digraph G {', file=f)
+            print('    ratio="compress";', file=f)
+            print('    size="8,80";', file=f)
             ig = record.ra_ig
             ig.to_dot(f)
             print('  }', file=f)
             print('', file=f)
             s += '\n' + f.getvalue()
+        if hasattr(record, 'zcc_outs'):
+            f = io.StringIO()
+            print('', file=f)
+            print('', file=f)
+            print('.. code::', file=f)
+            print('', file=f)
+            outstream.OutputStreamWriter('  ').dump(record.zcc_outs, f)
+            print('', file=f)
+            s += '\n' + f.getvalue()
         return s
 
 
@@ -119,7 +132,8 @@
     type=argparse.FileType('w'))
 parser.add_argument('--log', help='Log level (INFO,DEBUG,[WARN])', 
                     type=logLevel, default='WARN')
-parser.add_argument('--report', help='Specify a file to write the compile report to', 
+parser.add_argument('--report', 
+            help='Specify a file to write the compile report to', 
             type=argparse.FileType('w'))
 
 
@@ -129,7 +143,8 @@
         Compile sources into output stream.
         Sources is an iterable of open files.
     """
-    logging.info('Zcc started {}'.format(srcs))
+    logger = logging.getLogger('zcc')
+    logger.info('Zcc started {}'.format(srcs))
     # Front end:
     c3b = Builder(diag, tg)
     cg = CodeGenerator(tg)
@@ -145,13 +160,16 @@
             return
 
         d = {'ircode':ircode}
-        logging.info('Verifying code {}'.format(ircode), extra=d)
-        # Optimization passes, TODO
+        logger.info('Verifying code {}'.format(ircode), extra=d)
+        Verifier().verify(ircode)
+
+        # Optimization passes:
+        CleanPass().run(ircode)
         Verifier().verify(ircode)
 
         # Code generation:
         d = {'ircode':ircode}
-        logging.info('Starting code generation for {}'.format(ircode), extra=d)
+        logger.info('Starting code generation for {}'.format(ircode), extra=d)
         cg.generate(ircode, outs)
     # TODO: fixup references, do this in another way?
     outs.backpatch()