Mercurial > lcfOS
diff python/ir/module.py @ 271:cf7d5fb7d9c8
Reorganization
author | Windel Bouwman |
---|---|
date | Tue, 20 Aug 2013 18:56:02 +0200 |
parents | 5ec7580976d9 |
children | e64bae57cda8 |
line wrap: on
line diff
--- a/python/ir/module.py Mon Aug 19 21:14:28 2013 +0200 +++ b/python/ir/module.py Tue Aug 20 18:56:02 2013 +0200 @@ -1,6 +1,6 @@ # IR-Structures: from .instruction import * -from .basicblock import Block +from .function import Block class Module: """ Main container for a piece of code. """ @@ -12,22 +12,9 @@ def __repr__(self): return 'IR-module [{0}]'.format(self.name) - def getInstructions(self): - ins = [] - for bb in self.BasicBlocks: - ins += bb.Instructions - return ins - Instructions = property(getInstructions) - - def getBBs(self): - bbs = [] - for f in self.Functions: - bbs += f.BasicBlocks - return bbs - - BasicBlocks = property(getBBs) def addFunc(self, f): self.funcs.append(f) + addFunction = addFunc def addVariable(self, v): @@ -35,10 +22,12 @@ def getVariables(self): return self.variables + Variables = property(getVariables) def getFunctions(self): return self.funcs + Functions = property(getFunctions) def findFunction(self, name): @@ -46,6 +35,7 @@ if f.name == name: return f raise KeyError(name) + getFunction = findFunction def dump(self): @@ -69,10 +59,6 @@ outf.write('{0} [shape=note label="{1}"];\n'.format(id(bb), contents)) for successor in bb.Successors: outf.write('"{0}" -> "{1}"\n'.format(id(bb), id(successor))) - # Draw dags if any: - if hasattr(bb, 'dag'): - outf.write('{0} -> {1}\n'.format(id(bb), id(bb.dag))) - bb.dag.dumpgv(outf) outf.write('"{0}" -> "{1}" [label="entry"]\n'.format(id(f), id(f.entry))) outf.write('}\n') @@ -80,8 +66,6 @@ # Analysis functions: def check(self): """ Perform sanity check on module """ - for i in self.Instructions: - pass for f in self.Functions: f.check()