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
2bcdcaff
Commit
2bcdcaff
authored
13 years ago
by
Jayke Meijer
Browse files
Options
Downloads
Patches
Plain Diff
Added function to simplify branch-jump combos. Not function properly yet.
parent
1ea1d70f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/optimizer.py
+29
-0
29 additions, 0 deletions
src/optimizer.py
with
29 additions
and
0 deletions
src/optimizer.py
+
29
−
0
View file @
2bcdcaff
...
...
@@ -10,9 +10,38 @@ def empty_shift(statement):
stype
,
name
,
args
=
statement
return
stype
==
'
command
'
and
name
in
shift_types
and
\
args
[
'
args
'
][
0
]
==
args
[
'
args
'
][
1
]
and
args
[
'
args
'
][
2
]
==
0
def
optimize_branch_jump_label
(
statements
):
'''
Optimize jumps after branches.
'''
out_statements
=
[]
for
i
in
xrange
(
len
(
statements
)):
if
i
+
3
>
len
(
statements
):
out_statements
.
append
(
statements
[
i
])
continue
stype
,
name
,
args
=
statements
[
i
]
stype2
,
name2
,
args2
=
statements
[
i
+
1
]
stype3
,
name3
,
args3
=
statements
[
i
+
2
]
if
stype
==
'
command
'
and
name
==
'
beq
'
and
\
stype2
==
'
command
'
and
name2
in
[
'
j
'
,
'
jal
'
]
and
\
stype3
==
'
label
'
and
name3
==
args
[
'
args
'
][
2
]:
out_statements
.
append
((
'
command
'
,
'
bne
'
,
\
{
'
args
'
:
[
args
[
'
args
'
][
0
],
args
[
'
args
'
][
1
],
args2
[
'
args
'
][
0
]]}))
out_statements
.
append
(
statements
[
1
+
2
])
i
+=
3
else
:
out_statements
.
append
(
statements
[
i
])
return
out_statements
def
optimize_global
(
statements
):
'''
Optimize one-line statements in entire code.
'''
statements
=
optimize_branch_jump_label
(
statements
)
return
filter
(
lambda
s
:
not
equal_mov
(
s
)
and
not
empty_shift
(
s
),
statements
)
def
optimize_blocks
(
blocks
):
...
...
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