Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
peephole
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
peephole
Commits
06607dd1
Commit
06607dd1
authored
Dec 29, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extended 'is_arith() method.
parent
be87f728
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
src/optimize/advanced.py
src/optimize/advanced.py
+1
-0
src/statement.py
src/statement.py
+3
-2
No files found.
src/optimize/advanced.py
View file @
06607dd1
...
@@ -148,6 +148,7 @@ def fold_constants(block):
...
@@ -148,6 +148,7 @@ def fold_constants(block):
# Usage of variable with constant value
# Usage of variable with constant value
register
[
s
[
0
]]
=
constants
[
s
[
1
]]
register
[
s
[
0
]]
=
constants
[
s
[
1
]]
elif
s
.
name
in
[
'addu'
,
'subu'
,
'mult'
,
'div'
]:
elif
s
.
name
in
[
'addu'
,
'subu'
,
'mult'
,
'div'
]:
# TODO: implement 'mult' optimization
# Calculation with constants
# Calculation with constants
rd
,
rs
,
rt
=
s
[
0
],
s
[
1
],
s
[
2
]
rd
,
rs
,
rt
=
s
[
0
],
s
[
1
],
s
[
2
]
rs_known
=
rs
in
register
rs_known
=
rs
in
register
...
...
src/statement.py
View file @
06607dd1
...
@@ -62,7 +62,7 @@ class Statement:
...
@@ -62,7 +62,7 @@ class Statement:
def
is_shift
(
self
):
def
is_shift
(
self
):
"""Check if the statement is a shift operation."""
"""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
):
def
is_load
(
self
):
"""Check if the statement is a load instruction."""
"""Check if the statement is a load instruction."""
...
@@ -71,7 +71,8 @@ class Statement:
...
@@ -71,7 +71,8 @@ class Statement:
def
is_arith
(
self
):
def
is_arith
(
self
):
"""Check if the statement is an arithmetic operation."""
"""Check if the statement is an arithmetic operation."""
return
self
.
is_command
()
\
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
):
def
is_monop
(
self
):
"""Check if the statement is an unary operation."""
"""Check if the statement is an unary operation."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment