view python/testcg.py @ 209:07bfea4c1ed7

Added codegen test
author Windel Bouwman
date Sat, 29 Jun 2013 10:08:46 +0200
parents
children 494828a7adf1
line wrap: on
line source

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()