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
7343f43c
Commit
7343f43c
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Plain Diff
Merged conflicts.
parents
fff63a67
8dfef611
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/__init__.py
+4
-3
4 additions, 3 deletions
src/optimize/__init__.py
src/optimize/advanced.py
+15
-3
15 additions, 3 deletions
src/optimize/advanced.py
with
19 additions
and
6 deletions
src/optimize/__init__.py
+
4
−
3
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
,
\
from
standard
import
redundant_move_1
,
redundant_move_2
,
\
redundant_move_3
,
redundant_move_4
,
redundant_load
,
\
redundant_move_3
,
redundant_move_4
,
redundant_load
,
\
redundant_shift
,
redundant_add
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
):
def
optimize_global
(
statements
):
...
@@ -57,7 +58,7 @@ def optimize_block(block):
...
@@ -57,7 +58,7 @@ def optimize_block(block):
# or fold_constants(block)
# or fold_constants(block)
while
eliminate_common_subexpressions
(
block
)
\
while
eliminate_common_subexpressions
(
block
)
\
|
fold_constants
(
block
):
|
fold_constants
(
block
)
|
copy_propagation
(
block
)
:
pass
pass
def
optimize
(
statements
,
verbose
=
0
):
def
optimize
(
statements
,
verbose
=
0
):
...
...
This diff is collapsed.
Click to expand it.
src/optimize/advanced.py
+
15
−
3
View file @
7343f43c
from
src.
statement
import
Statement
as
S
from
statement
import
Statement
as
S
def
create_variable
():
def
create_variable
():
...
@@ -103,9 +103,21 @@ def fold_constants(block):
...
@@ -103,9 +103,21 @@ def fold_constants(block):
return
False
return
False
def
copy_propagtion
(
block
):
def
copy_propagation
(
block
):
"""
"""
Rename values that were copied to there original, so the copy statement
Rename values that were copied to there original, so the copy statement
might be useless, allowing it to be removed by dead code elimination.
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
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