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
12b1dc5e
Commit
12b1dc5e
authored
Dec 28, 2011
by
Jayke Meijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed one thing in unittest, added example to docstring.
parent
8c1d9515
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
src/optimize/advanced.py
src/optimize/advanced.py
+12
-4
tests/test_optimize_advanced.py
tests/test_optimize_advanced.py
+1
-2
No files found.
src/optimize/advanced.py
View file @
12b1dc5e
...
...
@@ -166,6 +166,13 @@ def copy_propagation(block):
walking through the code, storing move operations and checking whether it
changes or whether a variable can be replaced. This way, the move statement
might be a target for dead code elimination.
move $regA, $regB move $regA, $regB
... ...
Code not writing $regA, -> ...
$regB ...
... ...
addu $regC, $regA, ... addu $regC, $regB, ...
"""
moves_from
=
[]
moves_to
=
[]
...
...
@@ -221,17 +228,18 @@ def algebraic_transformations(block):
changed
=
False
while
not
block
.
end
():
changed
=
True
s
=
block
.
read
()
if
(
s
.
is_command
(
'addu'
)
or
s
.
is_command
(
'subu'
))
and
s
[
2
]
==
0
:
block
.
replace
(
1
,
[])
changed
=
True
elif
s
.
is_command
(
'mult'
)
and
s
[
2
]
==
1
:
block
.
replace
(
1
,
[])
changed
=
True
elif
s
.
is_command
(
'mult'
)
and
s
[
2
]
==
2
:
new_command
=
S
([
'command'
,
'sll'
,
s
[
0
],
s
[
1
],
1
])
new_command
=
S
([
'command'
,
'sll'
,
s
[
0
],
s
[
1
],
1
])
block
.
replace
(
1
,
[
new_command
])
else
:
changed
=
False
changed
=
True
return
changed
tests/test_optimize_advanced.py
View file @
12b1dc5e
...
...
@@ -76,7 +76,6 @@ class TestOptimizeAdvanced(unittest.TestCase):
S
(
'command'
,
'addu'
,
'$1'
,
'$2'
,
0
),
self
.
bar
])
# self.assertTrue(copy_propagation(block))
algebraic_transformations
(
block
)
self
.
assertTrue
(
algebraic_transformations
(
block
))
self
.
assertEqual
(
block
.
statements
,
[
self
.
foo
,
self
.
bar
])
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