Commit 030e9754 authored by Taddeus Kroes's avatar Taddeus Kroes

Extended docstrings.

parent 870d25ee
......@@ -8,6 +8,11 @@ def create_variable():
def eliminate_common_subexpressions(block):
"""
Common subexpression elimination:
x = a + b -> u = a + b
y = a + b x = u
y = u
The algorithm used is as follows:
- Traverse through the statements in reverse order.
- If the statement can be possibly be eliminated, walk further collecting
all other occurrences of the expression until one of the arguments is
......@@ -65,7 +70,11 @@ def to_hex(value):
def fold_constants(block):
"""
Constant folding:
- An immidiate load defines a register value:
x = 3 + 5 -> x = 8
y = x * 2 y = 16
To keep track of constant values, the following assumptions are made:
- An immediate load defines a register value:
li $reg, XX -> register[$reg] = XX
- Integer variable definition is of the following form:
li $reg, XX -> constants[VAR] = XX
......
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