|
@@ -11,37 +11,44 @@ class TestOptimizeAdvanced(unittest.TestCase):
|
|
|
self.foo = S('command', 'foo')
|
|
self.foo = S('command', 'foo')
|
|
|
self.bar = S('command', 'bar')
|
|
self.bar = S('command', 'bar')
|
|
|
|
|
|
|
|
|
|
+ def tearDown(self):
|
|
|
|
|
+ del self.foo
|
|
|
|
|
+ del self.bar
|
|
|
|
|
+
|
|
|
def test_eliminate_common_subexpressions(self):
|
|
def test_eliminate_common_subexpressions(self):
|
|
|
pass
|
|
pass
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ def test_fold_constants(self):
|
|
|
|
|
+ pass
|
|
|
|
|
+
|
|
|
def test_copy_propagation_true(self):
|
|
def test_copy_propagation_true(self):
|
|
|
block = B([self.foo,
|
|
block = B([self.foo,
|
|
|
S('command', 'move', '$1', '$2'),
|
|
S('command', 'move', '$1', '$2'),
|
|
|
self.foo,
|
|
self.foo,
|
|
|
S('command', 'addu', '$3', '$1', '$4'),
|
|
S('command', 'addu', '$3', '$1', '$4'),
|
|
|
self.bar])
|
|
self.bar])
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
self.assertTrue(copy_propagation(block))
|
|
self.assertTrue(copy_propagation(block))
|
|
|
self.assertEqual(block.statements, [self.foo,
|
|
self.assertEqual(block.statements, [self.foo,
|
|
|
S('command', 'move', '$1', '$2'),
|
|
S('command', 'move', '$1', '$2'),
|
|
|
self.foo,
|
|
self.foo,
|
|
|
S('command', 'addu', '$3', '$2', '$4'),
|
|
S('command', 'addu', '$3', '$2', '$4'),
|
|
|
self.bar])
|
|
self.bar])
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
def test_copy_propagation_overwrite(self):
|
|
def test_copy_propagation_overwrite(self):
|
|
|
block = B([self.foo, \
|
|
block = B([self.foo, \
|
|
|
S('command', 'move', '$1', '$2'),
|
|
S('command', 'move', '$1', '$2'),
|
|
|
S('command', 'move', '$1', '$5'),
|
|
S('command', 'move', '$1', '$5'),
|
|
|
S('command', 'addu', '$3', '$1', '$4'),
|
|
S('command', 'addu', '$3', '$1', '$4'),
|
|
|
self.bar])
|
|
self.bar])
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
self.assertTrue(copy_propagation(block))
|
|
self.assertTrue(copy_propagation(block))
|
|
|
self.assertEqual(block.statements, [self.foo,
|
|
self.assertEqual(block.statements, [self.foo,
|
|
|
S('command', 'move', '$1', '$2'),
|
|
S('command', 'move', '$1', '$2'),
|
|
|
S('command', 'move', '$1', '$5'),
|
|
S('command', 'move', '$1', '$5'),
|
|
|
S('command', 'addu', '$3', '$5', '$4'),
|
|
S('command', 'addu', '$3', '$5', '$4'),
|
|
|
self.bar])
|
|
self.bar])
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
def test_copy_propagation_false(self):
|
|
def test_copy_propagation_false(self):
|
|
|
arguments = [self.foo,
|
|
arguments = [self.foo,
|
|
|
S('command', 'move', '$1', '$2'),
|
|
S('command', 'move', '$1', '$2'),
|
|
@@ -52,7 +59,7 @@ class TestOptimizeAdvanced(unittest.TestCase):
|
|
|
block = B(arguments)
|
|
block = B(arguments)
|
|
|
self.assertFalse(copy_propagation(block))
|
|
self.assertFalse(copy_propagation(block))
|
|
|
self.assertEqual(block.statements, arguments)
|
|
self.assertEqual(block.statements, arguments)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
def test_copy_propagation_false_severalmoves(self):
|
|
def test_copy_propagation_false_severalmoves(self):
|
|
|
arguments = [self.foo,
|
|
arguments = [self.foo,
|
|
|
S('command', 'move', '$1', '$2'),
|
|
S('command', 'move', '$1', '$2'),
|