Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
peephole
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Taddeüs Kroes
peephole
Commits
b5507160
Commit
b5507160
authored
13 years ago
by
Jayke Meijer
Browse files
Options
Downloads
Patches
Plain Diff
Working on copyprop.
parent
53ac258b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/optimize/advanced.py
+10
-7
10 additions, 7 deletions
src/optimize/advanced.py
tests/test_optimize_advanced.py
+24
-10
24 additions, 10 deletions
tests/test_optimize_advanced.py
with
34 additions
and
17 deletions
src/optimize/advanced.py
+
10
−
7
View file @
b5507160
...
...
@@ -114,25 +114,27 @@ def copy_propagation(block):
while
not
block
.
end
():
s
=
block
.
read
()
print
"
len(s)
"
,
len
(
s
)
if
len
(
s
)
==
3
:
print
"
s[0] =
"
,
s
[
0
]
print
"
s[1] =
"
,
s
[
1
]
print
"
s[2] =
"
,
s
[
2
]
if
moves_from
:
print
moves_from
print
moves_to
print
"
fr:
"
,
moves_from
print
"
to:
"
,
moves_to
if
s
.
is_command
(
'
move
'
)
and
s
[
0
]
not
in
moves_
from
:
moves_from
.
append
(
s
[
0
])
moves_to
.
append
(
s
[
1
])
if
s
.
is_command
(
'
move
'
)
and
s
[
0
]
not
in
moves_
to
:
moves_from
.
append
(
s
[
1
])
moves_to
.
append
(
s
[
0
])
print
"
Added move to list.
"
elif
s
.
is_command
(
'
move
'
):
for
i
in
xrange
(
len
(
moves_to
)):
if
moves_to
[
i
]
==
s
[
0
]:
moves_from
[
i
]
=
s
[
1
]
elif
len
(
s
)
==
3
and
s
[
0
]
in
moves_to
:
print
len
(
s
)
print
len
(
moves_to
)
for
i
in
xrange
(
len
(
moves_to
)):
if
moves_to
[
i
]
==
s
[
0
]:
del
moves_to
[
i
]
...
...
@@ -148,5 +150,6 @@ def copy_propagation(block):
if
s
[
2
]
==
moves_to
[
i
]:
s
[
2
]
=
moves_from
[
i
]
print
"
Propagated
"
print
""
return
False
This diff is collapsed.
Click to expand it.
tests/test_optimize_advanced.py
+
24
−
10
View file @
b5507160
...
...
@@ -14,17 +14,31 @@ class TestOptimizeAdvanced(unittest.TestCase):
def
test_eliminate_common_subexpressions
(
self
):
pass
def
test_copy_propagation_true
(
self
):
# block = B([self.foo,
def
test_copy_propagation_true
(
self
):
print
"
testing true
"
block
=
B
([
self
.
foo
,
S
(
'
command
'
,
'
move
'
,
'
$1
'
,
'
$2
'
),
self
.
foo
,
S
(
'
command
'
,
'
addu
'
,
'
$3
'
,
'
$1
'
,
'
$4
'
),
self
.
bar
])
copy_propagation
(
block
)
self
.
assertEqual
(
block
.
statements
,
[
self
.
foo
,
S
(
'
command
'
,
'
move
'
,
'
$1
'
,
'
$2
'
),
self
.
foo
,
S
(
'
command
'
,
'
addu
'
,
'
$3
'
,
'
$2
'
,
'
$4
'
),
self
.
bar
])
print
"
Test true succesfull
"
# def test_copy_propagation_false(self):
# print "Testing false"
# arguments = [self.foo,
# S('command', 'move', '$1', '$2'),
# self.foo,
# S('command', 'move', '$10', '$20'),
# S('command', 'addu', '$1', '$5', 1),
# S('command', 'addu', '$3', '$1', '$4'),
# self.bar])
# self.bar]
# block = B(arguments)
#
# copy_propagation(block)
# self.assertEquals(block.statements, [self.foo,
# S('command', 'move', '$1', '$2'),
# self.foo,
# S('command', 'addu', '$3', '$2', '$4'),
# self.bar])
pass
# self.assertEqual(block.statements, arguments)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment