Mercurial > lcfOS
diff python/ir/builder.py @ 172:5a7d37d615ee
Added function to IR
author | Windel Bouwman |
---|---|
date | Thu, 04 Apr 2013 17:58:37 +0200 |
parents | 3eb9b9e2958d |
children | 3eb06f5fb987 |
line wrap: on
line diff
--- a/python/ir/builder.py Wed Apr 03 22:20:20 2013 +0200 +++ b/python/ir/builder.py Thu Apr 04 17:58:37 2013 +0200 @@ -1,4 +1,4 @@ -from . import Value, BasicBlock +from . import Value, BasicBlock, Function class NameGenerator: def __init__(self, prefix): @@ -32,14 +32,21 @@ self.newBBint = BBGenerator().gen self.bb = None self.m = None + self.fn = None # Helpers: def newBB(self): bb = self.newBBint() - self.m.addBB(bb) + self.fn.addBB(bb) return bb def setModule(self, m): self.m = m + def newFunc(self, name): + f = Function(name) + self.m.addFunc(f) + return f + def setFunc(self, f): + self.fn = f def setBB(self, bb): self.bb = bb def addIns(self, i):