Mercurial > lcfOS
changeset 209:07bfea4c1ed7
Added codegen test
author | Windel Bouwman |
---|---|
date | Sat, 29 Jun 2013 10:08:46 +0200 |
parents | 4cb47d80fd1f |
children | 67b0feafe5ae |
files | python/ir/instruction.py python/testcg.py |
diffstat | 2 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/python/ir/instruction.py Sat Jun 29 10:06:58 2013 +0200 +++ b/python/ir/instruction.py Sat Jun 29 10:08:46 2013 +0200 @@ -36,9 +36,9 @@ self.defs = [] self.uses = [] def delete(self): - for use in self.uses: - use.delete() - self.uses.clear() + while self.uses: + use = self.uses.pop() + use.delete() def addUse(self, val): self.uses.append(Use(self, val)) def addDef(self, v):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/testcg.py Sat Jun 29 10:08:46 2013 +0200 @@ -0,0 +1,22 @@ +import unittest +import ppci, codegen, ir +import arm_cm3 + +class testCodeGeneration(unittest.TestCase): + def setUp(self): + self.cg = codegen.CodeGenerator(arm_cm3.armtarget) + + def testFunction(self): + m = ir.Module('tst') + f = ir.Function('tst') + m.addFunction(f) + bb = ir.BasicBlock('entry') + f.addBasicBlock(bb) + v = ir.Value('tst') + bb.addInstruction(ir.ImmLoad(v, 123)) + m.check() + obj = self.cg.generate(m) + self.assertTrue(obj) + +if __name__ == '__main__': + unittest.main()