comparison python/ir/module.py @ 174:3eb06f5fb987

Added memory alloc for locals
author Windel Bouwman
date Fri, 19 Apr 2013 19:22:52 +0200
parents c1d2b6b9f9a7
children 460db5669efa
comparison
equal deleted inserted replaced
173:c1d2b6b9f9a7 174:3eb06f5fb987
36 print(' ', ins) 36 print(' ', ins)
37 print('END') 37 print('END')
38 def dumpgv(self, outf): 38 def dumpgv(self, outf):
39 outf.write('digraph G \n{\n') 39 outf.write('digraph G \n{\n')
40 for f in self.Functions: 40 for f in self.Functions:
41 outf.write('{0} [label="{1}"]\n'.format(id(f), f)) 41 outf.write('{0} [label="{1}" shape=box3d]\n'.format(id(f), f))
42 for bb in f.BasicBlocks: 42 for bb in f.BasicBlocks:
43 contents = str(bb) + '\n' 43 contents = str(bb) + '\n'
44 contents += '\n'.join([str(i) for i in bb.Instructions]) 44 contents += '\n'.join([str(i) for i in bb.Instructions])
45 outf.write('{0} [label="{1}"];\n'.format(id(bb), contents)) 45 outf.write('{0} [shape=note label="{1}"];\n'.format(id(bb), contents))
46 for successor in bb.Successors: 46 for successor in bb.Successors:
47 outf.write('"{0}" -> "{1}"\n'.format(id(bb), id(successor))) 47 outf.write('"{0}" -> "{1}"\n'.format(id(bb), id(successor)))
48 outf.write('"{0}" -> "{1}" [label="entry"]\n'.format(id(f), id(f.entry))) 48 outf.write('"{0}" -> "{1}" [label="entry"]\n'.format(id(f), id(f.entry)))
49 outf.write('}\n') 49 outf.write('}\n')
50 50
53 """ Perform sanity check on module """ 53 """ Perform sanity check on module """
54 for i in self.Instructions: 54 for i in self.Instructions:
55 for t in i.defs: 55 for t in i.defs:
56 assert type(t) is Value, "def must be Value, not {0}".format(type(t)) 56 assert type(t) is Value, "def must be Value, not {0}".format(type(t))
57 for t in i.uses: 57 for t in i.uses:
58 assert type(t) is Value, "use must be Value, not {0}".format(type(t)) 58 assert type(t) is Use, "use must be Value, not {0}".format(type(t))
59 59