annotate python/testcg.py @ 220:3f6c30a5d234

Major change in expression parsing to enable pointers and structs
author Windel Bouwman
date Sat, 06 Jul 2013 21:32:20 +0200
parents 494828a7adf1
children 6259856841a0
rev   line source
209
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
1 import unittest
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
2 import ppci, codegen, ir
218
494828a7adf1 added some sort of cache to assembler
Windel Bouwman
parents: 209
diff changeset
3 import cortexm3 as arm
209
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
4
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
5 class testCodeGeneration(unittest.TestCase):
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
6 def setUp(self):
218
494828a7adf1 added some sort of cache to assembler
Windel Bouwman
parents: 209
diff changeset
7 self.cg = codegen.CodeGenerator(arm.armtarget)
209
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
8
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
9 def testFunction(self):
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
10 m = ir.Module('tst')
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
11 f = ir.Function('tst')
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
12 m.addFunction(f)
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
13 bb = ir.BasicBlock('entry')
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
14 f.addBasicBlock(bb)
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
15 v = ir.Value('tst')
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
16 bb.addInstruction(ir.ImmLoad(v, 123))
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
17 m.check()
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
18 obj = self.cg.generate(m)
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
19 self.assertTrue(obj)
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
20
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
21 if __name__ == '__main__':
07bfea4c1ed7 Added codegen test
Windel Bouwman
parents:
diff changeset
22 unittest.main()