Mercurial > lcfOS
diff python/tcodegen.py @ 269:5f8c04a8d26b
Towards better modularity
author | Windel Bouwman |
---|---|
date | Sun, 18 Aug 2013 17:43:18 +0200 |
parents | |
children | e64bae57cda8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/tcodegen.py Sun Aug 18 17:43:18 2013 +0200 @@ -0,0 +1,49 @@ + +""" + Test individual parts of the code generation for arm using the c3 frontend. +""" + +import c3 +import ppci +import codegenarm +import outstream + +testsrc = """ +package test2; + +function void tesssst(int henkie) +{ + var int a, b, cee; + a = 2 * 33 - 12; + b = a * 2; + a = b + a; + cee = a; + cee = cee * 2 + cee; + if (cee + a > b and b - a+b== 3*6-b) + { + var int x = a; + x = b - a; + a = x * (x + a); + } + else + { + a = b + (a + b); + } + var int y; + y = a - b * 53; +} +""" + +if __name__ == '__main__': + diag = ppci.DiagnosticsManager() + builder = c3.Builder(diag) + ir = builder.build(testsrc) + ir.dump() + outs = outstream.TextOutputStream() + cga = codegenarm.ArmCodeGenerator(outs) + cfg_file = open('cfg.gv', 'w') + ig_file = open('ig.gv', 'w') + cga.generate(ir, cfg_file=cfg_file, ig_file=ig_file) + cfg_file.close() + ig_file.close() +