269
|
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
|
272
|
14 var int phaa, foo, bar;
|
|
15
|
|
16 function int insanemath(int a, int b)
|
|
17 {
|
|
18 var int c;
|
|
19 c = a + b + 1;
|
|
20 return c;
|
|
21 }
|
|
22
|
269
|
23 function void tesssst(int henkie)
|
|
24 {
|
|
25 var int a, b, cee;
|
|
26 a = 2 * 33 - 12;
|
|
27 b = a * 2;
|
|
28 a = b + a;
|
|
29 cee = a;
|
|
30 cee = cee * 2 + cee;
|
|
31 if (cee + a > b and b - a+b== 3*6-b)
|
|
32 {
|
|
33 var int x = a;
|
272
|
34 x = b - a + insanemath(3, 4);
|
269
|
35 a = x * (x + a);
|
|
36 }
|
|
37 else
|
|
38 {
|
|
39 a = b + (a + b);
|
|
40 }
|
|
41 var int y;
|
|
42 y = a - b * 53;
|
|
43 }
|
|
44 """
|
|
45
|
|
46 if __name__ == '__main__':
|
|
47 diag = ppci.DiagnosticsManager()
|
|
48 builder = c3.Builder(diag)
|
|
49 ir = builder.build(testsrc)
|
|
50 ir.dump()
|
|
51 outs = outstream.TextOutputStream()
|
|
52 cga = codegenarm.ArmCodeGenerator(outs)
|
|
53 cfg_file = open('cfg.gv', 'w')
|
|
54 ig_file = open('ig.gv', 'w')
|
272
|
55 ir2 = cga.generate(ir, cfg_file=cfg_file, ig_file=ig_file)
|
269
|
56 cfg_file.close()
|
|
57 ig_file.close()
|
272
|
58 for i in ir2:
|
|
59 print(i)
|
269
|
60
|