209
|
1 import unittest
|
|
2 import ppci, codegen, ir
|
|
3 import arm_cm3
|
|
4
|
|
5 class testCodeGeneration(unittest.TestCase):
|
|
6 def setUp(self):
|
|
7 self.cg = codegen.CodeGenerator(arm_cm3.armtarget)
|
|
8
|
|
9 def testFunction(self):
|
|
10 m = ir.Module('tst')
|
|
11 f = ir.Function('tst')
|
|
12 m.addFunction(f)
|
|
13 bb = ir.BasicBlock('entry')
|
|
14 f.addBasicBlock(bb)
|
|
15 v = ir.Value('tst')
|
|
16 bb.addInstruction(ir.ImmLoad(v, 123))
|
|
17 m.check()
|
|
18 obj = self.cg.generate(m)
|
|
19 self.assertTrue(obj)
|
|
20
|
|
21 if __name__ == '__main__':
|
|
22 unittest.main()
|