diff python/testcg.py @ 268:5ec7580976d9

Op naar tree-IR
author Windel Bouwman
date Wed, 14 Aug 2013 20:12:40 +0200
parents ef683881c64e
children e64bae57cda8
line wrap: on
line diff
--- a/python/testcg.py	Mon Aug 12 20:14:47 2013 +0200
+++ b/python/testcg.py	Wed Aug 14 20:12:40 2013 +0200
@@ -8,9 +8,7 @@
     m = ir.Module('tst')
     f = ir.Function('tst')
     m.addFunction(f)
-    bb = ir.BasicBlock('entry')
-    f.addBasicBlock(bb)
-    return m, bb
+    return m, f.entry
 
 
 class testCodeGeneration(unittest.TestCase):
@@ -19,8 +17,8 @@
 
     def testFunction(self):
         m, bb = genTestFunction()
-        v = ir.Value('tst')
-        bb.addInstruction(ir.ImmLoad(v, 123))
+        bb.addInstruction(ir.Const(123))
+        bb.addInstruction(ir.Return(ir.Const(0)))
         m.check()
         obj = self.cg.generate(m)
         self.assertTrue(obj)
@@ -31,15 +29,13 @@
         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))
+        bb.addInstruction(ir.Move(ir.Mem(ir.Const(1)), ir.Const(22)))
+        bb.addInstruction(ir.Return(ir.Const(0)))
         m.check()
         cg.generate(m)
         #s.dump()
 
+
 if __name__ == '__main__':
     unittest.main()