Commit 06607dd1 authored by Taddeus Kroes's avatar Taddeus Kroes

Extended 'is_arith() method.

parent be87f728
......@@ -148,6 +148,7 @@ def fold_constants(block):
# Usage of variable with constant value
register[s[0]] = constants[s[1]]
elif s.name in ['addu', 'subu', 'mult', 'div']:
# TODO: implement 'mult' optimization
# Calculation with constants
rd, rs, rt = s[0], s[1], s[2]
rs_known = rs in register
......
......@@ -62,7 +62,7 @@ class Statement:
def is_shift(self):
"""Check if the statement is a shift operation."""
return self.is_command() and re.match('^s(ll|la|rl|ra)$', self.name)
return self.is_command() and re.match('^s(ll|rl|ra)$', self.name)
def is_load(self):
"""Check if the statement is a load instruction."""
......@@ -71,7 +71,8 @@ class Statement:
def is_arith(self):
"""Check if the statement is an arithmetic operation."""
return self.is_command() \
and re.match('^(add|sub|mult|div|abs|neg)(u|\.d)?$', self.name)
and re.match('^s(ll|rl|ra)|(add|sub|mflo|abs|neg|slt|sqrt)' \
+ '(u|\.s|\.d)?$', self.name)
def is_monop(self):
"""Check if the statement is an unary operation."""
......
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