comparison python/tcodegen.py @ 269:5f8c04a8d26b

Towards better modularity
author Windel Bouwman
date Sun, 18 Aug 2013 17:43:18 +0200
parents
children e64bae57cda8
comparison
equal deleted inserted replaced
268:5ec7580976d9 269:5f8c04a8d26b
1
2 """
3 Test individual parts of the code generation for arm using the c3 frontend.
4 """
5
6 import c3
7 import ppci
8 import codegenarm
9 import outstream
10
11 testsrc = """
12 package test2;
13
14 function void tesssst(int henkie)
15 {
16 var int a, b, cee;
17 a = 2 * 33 - 12;
18 b = a * 2;
19 a = b + a;
20 cee = a;
21 cee = cee * 2 + cee;
22 if (cee + a > b and b - a+b== 3*6-b)
23 {
24 var int x = a;
25 x = b - a;
26 a = x * (x + a);
27 }
28 else
29 {
30 a = b + (a + b);
31 }
32 var int y;
33 y = a - b * 53;
34 }
35 """
36
37 if __name__ == '__main__':
38 diag = ppci.DiagnosticsManager()
39 builder = c3.Builder(diag)
40 ir = builder.build(testsrc)
41 ir.dump()
42 outs = outstream.TextOutputStream()
43 cga = codegenarm.ArmCodeGenerator(outs)
44 cfg_file = open('cfg.gv', 'w')
45 ig_file = open('ig.gv', 'w')
46 cga.generate(ir, cfg_file=cfg_file, ig_file=ig_file)
47 cfg_file.close()
48 ig_file.close()
49