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
69a28137
Commit
69a28137
authored
Dec 30, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added block reset() call whenever 'while block.end():' is used.
parent
0de7d78b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
src/optimize/advanced.py
src/optimize/advanced.py
+10
-2
src/statement.py
src/statement.py
+4
-0
No files found.
src/optimize/advanced.py
View file @
69a28137
...
@@ -50,6 +50,8 @@ def eliminate_common_subexpressions(block):
...
@@ -50,6 +50,8 @@ def eliminate_common_subexpressions(block):
"""
"""
changed
=
False
changed
=
False
block
.
reset
()
while
not
block
.
end
():
while
not
block
.
end
():
s
=
block
.
read
()
s
=
block
.
read
()
...
@@ -123,6 +125,8 @@ def fold_constants(block):
...
@@ -123,6 +125,8 @@ def fold_constants(block):
# Current known values in register
# Current known values in register
register
=
{}
register
=
{}
block
.
reset
()
while
not
block
.
end
():
while
not
block
.
end
():
s
=
block
.
read
()
s
=
block
.
read
()
...
@@ -147,10 +151,10 @@ def fold_constants(block):
...
@@ -147,10 +151,10 @@ def fold_constants(block):
elif
s
.
name
==
'lw'
and
s
[
1
]
in
constants
:
elif
s
.
name
==
'lw'
and
s
[
1
]
in
constants
:
# 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
==
'mflo'
:
elif
s
.
name
==
'mflo'
and
'$lo'
in
register
:
# Move of `Lo' register to another register
# Move of `Lo' register to another register
register
[
s
[
0
]]
=
register
[
'$lo'
]
register
[
s
[
0
]]
=
register
[
'$lo'
]
elif
s
.
name
==
'mfhi'
:
elif
s
.
name
==
'mfhi'
and
'$hi'
in
register
:
# Move of `Hi' register to another register
# Move of `Hi' register to another register
register
[
s
[
0
]]
=
register
[
'$hi'
]
register
[
s
[
0
]]
=
register
[
'$hi'
]
elif
s
.
name
in
[
'mult'
,
'div'
]
\
elif
s
.
name
in
[
'mult'
,
'div'
]
\
...
@@ -252,6 +256,8 @@ def copy_propagation(block):
...
@@ -252,6 +256,8 @@ def copy_propagation(block):
moves_to
=
[]
moves_to
=
[]
changed
=
False
changed
=
False
block
.
reset
()
while
not
block
.
end
():
while
not
block
.
end
():
s
=
block
.
read
()
s
=
block
.
read
()
...
@@ -305,6 +311,8 @@ def algebraic_transformations(block):
...
@@ -305,6 +311,8 @@ def algebraic_transformations(block):
"""
"""
changed
=
False
changed
=
False
block
.
reset
()
while
not
block
.
end
():
while
not
block
.
end
():
s
=
block
.
read
()
s
=
block
.
read
()
...
...
src/statement.py
View file @
69a28137
...
@@ -288,4 +288,8 @@ class Block:
...
@@ -288,4 +288,8 @@ class Block:
def reverse_statements(self):
def reverse_statements(self):
"""Reverse the statement list and reset the pointer."""
"""Reverse the statement list and reset the pointer."""
self.statements = self.statements[::-1]
self.statements = self.statements[::-1]
self.reset()
def reset(self):
"""Reset the internal pointer."""
self.pointer = 0
self.pointer = 0
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