Mercurial > lcfOS
diff python/testcg.py @ 240:6259856841a0
Remove project
author | Windel Bouwman |
---|---|
date | Mon, 22 Jul 2013 22:37:33 +0200 |
parents | 494828a7adf1 |
children | ef683881c64e |
line wrap: on
line diff
--- a/python/testcg.py Mon Jul 22 17:57:25 2013 +0200 +++ b/python/testcg.py Mon Jul 22 22:37:33 2013 +0200 @@ -1,22 +1,43 @@ import unittest import ppci, codegen, ir import cortexm3 as arm +import codegenarm +import outstream + +def genTestFunction(): + m = ir.Module('tst') + f = ir.Function('tst') + m.addFunction(f) + bb = ir.BasicBlock('entry') + f.addBasicBlock(bb) + return m, bb + class testCodeGeneration(unittest.TestCase): def setUp(self): self.cg = codegen.CodeGenerator(arm.armtarget) def testFunction(self): - m = ir.Module('tst') - f = ir.Function('tst') - m.addFunction(f) - bb = ir.BasicBlock('entry') - f.addBasicBlock(bb) + m, bb = genTestFunction() v = ir.Value('tst') bb.addInstruction(ir.ImmLoad(v, 123)) m.check() obj = self.cg.generate(m) self.assertTrue(obj) +class testArmCodeGeneration(unittest.TestCase): + def testStack(self): + s = outstream.OutputStream() + cg = codegenarm.ArmCodeGenerator(s) + m, bb = genTestFunction() + v = ir.Value('tst') + bb.addInstruction(ir.Alloc(v)) + v2 = ir.Value('tst2') + bb.addInstruction(ir.ImmLoad(v2, 22)) + bb.addInstruction(ir.Store(v, v2)) + m.check() + cg.generate(m) + s.dump() + if __name__ == '__main__': - unittest.main() + unittest.main()