|
@@ -64,37 +64,39 @@ class TestLiveness(unittest.TestCase):
|
|
|
self.assertEqual(b3.live_in, set(['b', 'd', '$4', '$5', '$6', '$7']))
|
|
self.assertEqual(b3.live_in, set(['b', 'd', '$4', '$5', '$6', '$7']))
|
|
|
self.assertEqual(b3.live_out, set(['$4', '$5', '$6', '$7']))
|
|
self.assertEqual(b3.live_out, set(['$4', '$5', '$6', '$7']))
|
|
|
|
|
|
|
|
- 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')
|
|
|
|
|
-
|
|
|
|
|
- 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
|
|
|
|
|
|
|
+# 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')
|
|
|
|
|
+#
|
|
|
|
|
+# s21 = S('label', 'L1')
|
|
|
|
|
+# s22 = S('command', 'addi', 'i', '0x00000001')
|
|
|
|
|
+# s23 = S('command', 'subi', 'j', '0x00000002')
|
|
|
|
|
+# s24 = S('command', 'bne', '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', 'i', 'j', '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, s52])
|
|
|
|
|
+#
|
|
|
|
|
+# 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
|
|
|
|
|
+#
|
|
|
|
|
+# #print blocks[-1].live_in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|