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
09d65898
Commit
09d65898
authored
Dec 19, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup.
parent
48dd0f24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
src/main.py
src/main.py
+3
-5
src/optimizer.py
src/optimizer.py
+8
-0
No files found.
src/main.py
View file @
09d65898
...
...
@@ -11,14 +11,12 @@ if __name__ == '__main__':
exit
(
1
)
# Parse File
statements
=
parse_file
(
argv
[
1
])
statements
=
optimize
(
statements
,
verbose
=
1
)
# Rewrite to assembly
out
=
write_statements
(
statements
)
original
=
parse_file
(
argv
[
1
])
optimized
=
optimize
(
original
,
verbose
=
1
)
if
len
(
argv
)
>
2
:
# Save output assembly
out
=
write_statements
(
optimized
)
f
=
open
(
argv
[
2
],
'w+'
)
f
.
write
(
out
)
f
.
close
()
src/optimizer.py
View file @
09d65898
...
...
@@ -41,6 +41,12 @@ def optimize_global(statements):
"""Optimize one-line statements in entire code."""
statements
=
optimize_branch_jump_label
(
statements
)
#while not block.end():
# i, s = block.read()
# if block.peek():
# block.replace(i, i + 3, [nieuwe statements])
return
filter
(
lambda
s
:
not
equal_mov
(
s
)
and
not
empty_shift
(
s
),
statements
)
...
...
@@ -79,6 +85,8 @@ def optimize_block(statements):
def
optimize
(
original
,
verbose
=
0
):
"""optimization wrapper function, calls global and basic-block level
optimization functions."""
# Optimize on a global level
opt_global
=
optimize_global
(
original
)
...
...
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