Commit c7080a74 authored by Taddeus Kroes's avatar Taddeus Kroes

Moved optimization files to src/ directory.

parent 4542b9c5
from statement import Statement as S, Block
from dataflow import find_basic_blocks, generate_flow_graph
from optimize.redundancies import remove_redundant_jumps, remove_redundancies,\
from optimize_redundancies import remove_redundant_jumps, remove_redundancies,\
remove_redundant_branch_jumps
from optimize.advanced import eliminate_common_subexpressions, \
from optimize_advanced import eliminate_common_subexpressions, \
fold_constants, propagate_copies, eliminate_dead_code
import liveness
......
import unittest
from src.optimize.redundancies import remove_redundancies, \
from src.optimize_redundancies import remove_redundancies, \
remove_redundant_jumps, remove_redundant_branch_jumps
from src.program import Program
from src.statement import Statement as S, Block as B
......@@ -12,7 +12,7 @@ def optimize_block(block):
# program.blocks = [block]
# del program.statements
# program.optimize_blocks()
remove_redundancies(block)
......@@ -173,7 +173,7 @@ class TestOptimize(unittest.TestCase):
self.assertEquals(block.statements, arguments)
self.assertEquals(block2.statements, arguments2)
self.assertEquals(block3.statements, arguments3)
def test_optimize_block_move_move_true(self):
block = B([self.foo,
S('command', 'move', '$regA', '$regB'),
......@@ -194,30 +194,30 @@ class TestOptimize(unittest.TestCase):
remove_redundancies(block)
self.assertEquals(block.statements, arguments)
def test_remove_redundant_jumps_true(self):
block = B([self.foo,
S('command', 'j', '$L1'),
S('label', '$L1'),
self.bar])
remove_redundant_jumps(block)
self.assertEqual(block.statements, [self.foo,
self.assertEqual(block.statements, [self.foo,
S('label', '$L1'),
self.bar])
def test_remove_redundant_jumps_false(self):
arguments = [self.foo,
S('command', 'j', '$L1'),
S('label', '$L2'),
self.bar]
block = B(arguments)
remove_redundant_jumps(block)
self.assertEqual(block.statements, arguments)
def test_remove_redundant_branch_jumps_beq_j_true(self):
block = B([self.foo,
S('command', 'beq', '$regA', '$regB', '$Lx'),
......
import unittest
from copy import copy
from src.optimize.advanced import eliminate_common_subexpressions, \
from src.optimize_advanced import eliminate_common_subexpressions, \
fold_constants, propagate_copies
from src.statement import Statement as S
from src.dataflow import BasicBlock as B, generate_flow_graph
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment