comparison python/testir.py @ 173:c1d2b6b9f9a7

Rework into passes
author Windel Bouwman
date Fri, 19 Apr 2013 12:42:21 +0200
parents 5a7d37d615ee
children 3eb06f5fb987
comparison
equal deleted inserted replaced
172:5a7d37d615ee 173:c1d2b6b9f9a7
1 import c3, ppci, ir, x86 1 import c3, ppci, ir, x86, transform
2 import os 2 import os
3 3
4 testsrc = """ 4 testsrc = """
5 package test2; 5 package test2;
6 6
37 diag = ppci.DiagnosticsManager() 37 diag = ppci.DiagnosticsManager()
38 builder = c3.Builder(diag) 38 builder = c3.Builder(diag)
39 cgenx86 = x86.X86CodeGen(diag) 39 cgenx86 = x86.X86CodeGen(diag)
40 ir = builder.build(testsrc) 40 ir = builder.build(testsrc)
41 diag.printErrors(testsrc) 41 diag.printErrors(testsrc)
42 #ir.dump()
43 cf = transform.ConstantFolder()
44 dcd = transform.DeadCodeDeleter()
42 ir.check() 45 ir.check()
43 ir.analyze() 46 cf.run(ir)
44 #ir.constantProp() 47 cf.run(ir)
48 #dcd.run(ir)
45 ir.dump() 49 ir.dump()
46 asm = cgenx86.genBin(ir) 50 asm = cgenx86.genBin(ir)
47 for a in asm: 51 for a in asm:
48 print(a) 52 print(a)
49 with open('out.asm', 'w') as f: 53 with open('out.asm', 'w') as f: