Skip to content
Snippets Groups Projects
Commit fff63a67 authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Added docstings for Constant Folding.

parent 1912905a
No related branches found
No related tags found
No related merge requests found
......@@ -65,8 +65,19 @@ def to_hex(value):
def fold_constants(block):
"""
Constant folding:
- Integer variable definition is of the following form:
li $reg, XX
sw $reg, VAR
save this as:
reg[$reg] = XX
constants[VAR] = XX
- When a variable is used, the following happens:
lw $reg, VAR
save this as:
reg[$reg] = constants[VAR]
"""
constants = {}
reg = {}
while not block.end():
s = block.read()
......@@ -91,7 +102,7 @@ def fold_constants(block):
#else:
return False
def copy_propagtion(block):
"""
Rename values that were copied to there original, so the copy statement
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment