209
|
1 import unittest
|
|
2 import ppci, codegen, ir
|
218
|
3 import cortexm3 as arm
|
209
|
4
|
|
5 class testCodeGeneration(unittest.TestCase):
|
|
6 def setUp(self):
|
218
|
7 self.cg = codegen.CodeGenerator(arm.armtarget)
|
209
|
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()
|