Mercurial > lcfOS
diff python/ppci/ir.py @ 336:d1ecc493384e
Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
author | Windel Bouwman |
---|---|
date | Wed, 19 Feb 2014 22:32:15 +0100 |
parents | e30a77ae359b |
children | 5477e499b039 |
line wrap: on
line diff
--- a/python/ppci/ir.py Mon Feb 17 20:41:30 2014 +0100 +++ b/python/ppci/ir.py Wed Feb 19 22:32:15 2014 +0100 @@ -3,6 +3,19 @@ """ +def label_name(dut): + """ Function that returns the assembly code label name """ + if isinstance(dut, Block): + f = dut.function + return label_name(f) + '_' + dut.name + elif isinstance(dut, Function): + return label_name(dut.module) + '_' + dut.name + elif isinstance(dut, Module): + return dut.name + else: + raise NotImplementedError(str(dut)) + + class Module: """ Container unit for variables and functions. """ def __init__(self, name): @@ -16,8 +29,9 @@ def add_function(self, f): """ Add a function to this module """ self.functions.append(f) + f.module = self - def addVariable(self, v): + def add_variable(self, v): self.variables.append(v) def getVariables(self): @@ -43,9 +57,9 @@ """ Represents a function. """ def __init__(self, name, module=None): self.name = name - self.entry = Block('{}_entry'.format(name)) + self.entry = Block('entry') self.entry.function = self - self.epiloog = Block('{}_epilog'.format(name)) + self.epiloog = Block('epilog') self.epiloog.function = self self.epiloog.addInstruction(Terminator()) self.return_value = Temp('{}_retval'.format(name)) @@ -195,6 +209,7 @@ class Call(Expression): """ Call a function with some arguments """ def __init__(self, f, arguments): + assert type(f) is str self.f = f self.arguments = arguments