Browse Source

worked on test_liveness create_in_out testing

Richard Torenvliet 14 years ago
parent
commit
ebef48edbe
1 changed files with 27 additions and 33 deletions
  1. 27 33
      tests/test_liveness.py

+ 27 - 33
tests/test_liveness.py

@@ -64,44 +64,37 @@ class TestLiveness(unittest.TestCase):
         self.assertEqual(b3.live_in, set(['b', 'd']))
         self.assertEqual(b3.live_out, set())
         
-#    def test_create_in_out_two(self):    
-#        s11 = S('command', 'subu', 'i', 'm', '0x00000001')
-#        s12 = S('command', 'move', 'j', 'n')
-#        s13 = S('command', 'move', 'a', 'u1')
-#        s14 = S('command', 'subu', 'i', 'm', '0x00000001')
-#        s15 = S('command', 'j', 'L1')
-#        s16 = S('')
-#        
-#        s21 = S('label', 'L1')
-#        s22 = S('command', 'addi', 'i', '0x00000001')
-#        s23 = S('command', 'subi', 'j', '0x00000001')
-#        s24 = S('command', 'j', 'L2')
-#        
-#        s31 = S('label', 'L2')
-#        s32 = S('command', 'move', 'a', 'u2')
-#        s33 = S('command', 'j', 'L1')        
-
-#        s41 = S('label', 'L3')
-#        s42 = S('command', 'move', 'i', 'u3')
-#        s43 = S('command', 'beq', 'g', 'd', 'L4')
-#        
-#        s51 = S('label', 'L4')
-#        s52 = S('command', 'addu', 'b', 'i', 'a')
-#        
-#        b1, b2, b3, b4 = find_basic_blocks([s11, s12, s13, s14, s15, s21, s22,\
-#                                s31, s32, s33, s41, s42, s43, s51])
-
-#        generate_flow_graph([b1, b2, b3, b4, b5])
-#        create_in_out([b1, b2, b3, b4, b5])
-#        
-#        
+    def test_create_in_out_two(self):    
+        s11 = S('command', 'subu', 'i', 'm', '0x00000001')
+        s12 = S('command', 'move', 'j', 'n')
+        s13 = S('command', 'move', 'a', 'u1')
+        s14 = S('command', 'subu', 'i', 'm', '0x00000005')
+        s15 = S('command', 'j', 'L1')
         
-        #self.assertEqual(b1.)
-
+        s21 = S('label', 'L1')
+        s22 = S('command', 'addi', 'i', '0x00000001')
+        s23 = S('command', 'subi', 'j', '0x00000002')
+        s24 = S('command', 'bnq', 'i', 'j', 'L2')
         
+        s31 = S('command', 'move', 'a', 'u2')
+        s32 = S('command', 'j', 'L1')        
+
+        s41 = S('label', 'L2')
+        s42 = S('command', 'move', 'i', 'u3')
+        s43 = S('command', 'beq', 'g', 'd', 'L3')
         
+        s51 = S('label', 'L3')
+        s52 = S('command', 'addu', 'b', 'i', 'a')
         
+        blocks = find_basic_blocks([s11, s12, s13, s14, s15, 
+        s21, s22, s23, s24, s31, s32, s41, s42, s43, s51])
+    
+        generate_flow_graph(blocks)
+        create_in_out(blocks)
         
+        for i, block in enumerate(blocks):
+            print 'block ', i,':\n\t in:', block.live_in
+            print  '\t out:', block.live_out
         
         
         
@@ -109,3 +102,4 @@ class TestLiveness(unittest.TestCase):
         
         
         
+