Commit 09d65898 authored by Taddeus Kroes's avatar Taddeus Kroes

Code cleanup.

parent 48dd0f24
......@@ -11,14 +11,12 @@ if __name__ == '__main__':
exit(1)
# Parse File
statements = parse_file(argv[1])
statements = optimize(statements, verbose=1)
# Rewrite to assembly
out = write_statements(statements)
original = parse_file(argv[1])
optimized = optimize(original, verbose=1)
if len(argv) > 2:
# Save output assembly
out = write_statements(optimized)
f = open(argv[2], 'w+')
f.write(out)
f.close()
......@@ -41,6 +41,12 @@ def optimize_global(statements):
"""Optimize one-line statements in entire code."""
statements = optimize_branch_jump_label(statements)
#while not block.end():
# i, s = block.read()
# if block.peek():
# block.replace(i, i + 3, [nieuwe statements])
return filter(lambda s: not equal_mov(s) and not empty_shift(s), statements)
......@@ -79,6 +85,8 @@ def optimize_block(statements):
def optimize(original, verbose=0):
"""optimization wrapper function, calls global and basic-block level
optimization functions."""
# Optimize on a global level
opt_global = optimize_global(original)
......
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