|
@@ -65,8 +65,19 @@ def to_hex(value):
|
|
|
def fold_constants(block):
|
|
def fold_constants(block):
|
|
|
"""
|
|
"""
|
|
|
Constant folding:
|
|
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 = {}
|
|
constants = {}
|
|
|
|
|
+ reg = {}
|
|
|
|
|
|
|
|
while not block.end():
|
|
while not block.end():
|
|
|
s = block.read()
|
|
s = block.read()
|
|
@@ -91,7 +102,7 @@ def fold_constants(block):
|
|
|
#else:
|
|
#else:
|
|
|
|
|
|
|
|
return False
|
|
return False
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
def copy_propagtion(block):
|
|
def copy_propagtion(block):
|
|
|
"""
|
|
"""
|
|
|
Rename values that were copied to there original, so the copy statement
|
|
Rename values that were copied to there original, so the copy statement
|