comparison python/ppci/codegen/canon.py @ 307:e609d5296ee9

Massive rewrite of codegenerator
author Windel Bouwman
date Thu, 12 Dec 2013 20:42:56 +0100
parents 6753763d3bec
children 5477e499b039
comparison
equal deleted inserted replaced
306:b145f8e6050b 307:e609d5296ee9
1 from .. import ir 1 from .. import ir
2 from .. import irutils
2 from itertools import chain 3 from itertools import chain
3 4
4 def make(function, frame): 5 def make(function, frame):
5 """ 6 """
6 Create canonicalized version of the IR-code. This means: 7 Create canonicalized version of the IR-code. This means:
42 elif isinstance(stmt, ir.Exp): 43 elif isinstance(stmt, ir.Exp):
43 stmt.e = rewriteExp(stmt.e, frame) 44 stmt.e = rewriteExp(stmt.e, frame)
44 else: 45 else:
45 raise NotImplementedError('STMT NI: {}'.format(stmt)) 46 raise NotImplementedError('STMT NI: {}'.format(stmt))
46 47
47 newTemp = ir.NamedClassGenerator('canon_reg', ir.Temp).gen 48 newTemp = irutils.NamedClassGenerator('canon_reg', ir.Temp).gen
48 49
49 def rewriteExp(exp, frame): 50 def rewriteExp(exp, frame):
50 if isinstance(exp, ir.Binop): 51 if isinstance(exp, ir.Binop):
51 exp.a = rewriteExp(exp.a, frame) 52 exp.a = rewriteExp(exp.a, frame)
52 exp.b = rewriteExp(exp.b, frame) 53 exp.b = rewriteExp(exp.b, frame)