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
7343f43c
Commit
7343f43c
authored
Dec 28, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Plain Diff
Merged conflicts.
parents
fff63a67
8dfef611
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
src/optimize/__init__.py
src/optimize/__init__.py
+4
-3
src/optimize/advanced.py
src/optimize/advanced.py
+15
-3
No files found.
src/optimize/__init__.py
View file @
7343f43c
from
src.
dataflow
import
find_basic_blocks
from
dataflow
import
find_basic_blocks
from
standard
import
redundant_move_1
,
redundant_move_2
,
\
redundant_move_3
,
redundant_move_4
,
redundant_load
,
\
redundant_shift
,
redundant_add
from
advanced
import
eliminate_common_subexpressions
,
fold_constants
from
advanced
import
eliminate_common_subexpressions
,
fold_constants
,
\
copy_propagation
def
optimize_global
(
statements
):
...
...
@@ -57,7 +58,7 @@ def optimize_block(block):
# or fold_constants(block)
while
eliminate_common_subexpressions
(
block
)
\
|
fold_constants
(
block
):
|
fold_constants
(
block
)
|
copy_propagation
(
block
)
:
pass
def
optimize
(
statements
,
verbose
=
0
):
...
...
src/optimize/advanced.py
View file @
7343f43c
from
s
rc.s
tatement
import
Statement
as
S
from
statement
import
Statement
as
S
def
create_variable
():
...
...
@@ -103,9 +103,21 @@ def fold_constants(block):
return
False
def
copy_propagtion
(
block
):
def
copy_propagation
(
block
):
"""
Rename values that were copied to there original, so the copy statement
might be useless, allowing it to be removed by dead code elimination.
"""
return
false
moves
=
[]
count
=
0
while
not
block
.
end
():
s
=
block
.
read
()
if
s
.
is_command
(
'move'
):
moves
.
append
((
s
[
0
],
s
[
1
]))
count
+=
1
print
"count"
,
count
return
False
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