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
5d9baa40
Commit
5d9baa40
authored
13 years ago
by
Jayke Meijer
Browse files
Options
Downloads
Patches
Plain Diff
Changed list to set in def and use.
parent
bc5d2620
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/statement.py
+12
-11
12 additions, 11 deletions
src/statement.py
with
12 additions
and
11 deletions
src/statement.py
+
12
−
11
View file @
5d9baa40
...
...
@@ -155,28 +155,29 @@ class Statement:
def
get_def
(
self
):
"""
Get the variable that this statement defines, if any.
"""
instr
=
[
'
div
'
,
'
move
'
,
'
addu
'
,
'
subu
'
,
'
li
'
,
'
dmfc1
'
,
'
mov.d
'
]
defined
=
set
()
if
self
.
is_command
(
'
mtc1
'
):
return
[
self
[
1
]
]
return
defined
.
add
(
self
[
1
]
)
if
self
.
is_load_non_immediate
()
or
self
.
is_arith
()
\
or
self
.
is_logical
()
or
self
.
is_double_arithmetic
()
\
or
self
.
is_move_from_spec
()
or
self
.
is_double_unary
()
\
or
self
.
is_set_if_less
()
or
self
.
is_convert
()
\
or
self
.
is_truncate
()
or
self
.
is_load
()
\
or
self
.
is_command
(
*
instr
):
return
self
[
:
1
]
return
defined
.
add
(
self
[
0
])
return
[]
return
defined
def
get_use
(
self
):
"""
Get the variables that this statement uses, if any.
"""
instr
=
[
'
addu
'
,
'
subu
'
,
'
mult
'
,
'
div
'
,
'
move
'
,
'
mov.d
'
,
\
'
dmfc1
'
]
use
=
[]
use
=
set
()
# Jump to register addres uses register
if
self
.
is_command
(
'
j
'
)
and
re
.
match
(
'
^\$\d+$
'
,
self
[
0
]):
use
.
a
ppen
d
(
self
[
0
])
use
.
a
d
d
(
self
[
0
])
# Case arg0
if
(
self
.
is_branch
()
\
...
...
@@ -187,9 +188,9 @@ class Statement:
m
=
re
.
match
(
'
^[^(]+\(([^)]+)\)$
'
,
self
[
0
])
if
m
:
use
.
a
ppen
d
(
m
.
group
(
1
))
use
.
a
d
d
(
m
.
group
(
1
))
else
:
use
.
a
ppen
d
(
self
[
0
])
use
.
a
d
d
(
self
[
0
])
if
(
self
.
is_branch
()
and
not
self
.
is_branch_zero
()
\
and
not
self
.
is_command
(
'
bc1f
'
,
'
bc1t
'
,
'
bct
'
,
'
bcf
'
))
\
...
...
@@ -199,22 +200,22 @@ class Statement:
or
self
.
is_truncate
()
or
self
.
is_set_if_less
()
\
or
self
.
is_compare
()
or
self
.
is_command
(
*
instr
):
# Case arg1 direct adressing
use
.
a
ppen
d
(
self
[
1
])
use
.
a
d
d
(
self
[
1
])
elif
self
.
is_load_non_immediate
()
or
self
.
is_store
():
# Case arg1 relative adressing
m
=
re
.
match
(
'
^[^(]+\(([^)]+)\)$
'
,
self
[
1
])
if
m
:
use
.
a
ppen
d
(
m
.
group
(
1
))
use
.
a
d
d
(
m
.
group
(
1
))
else
:
use
.
a
ppen
d
(
self
[
1
])
use
.
a
d
d
(
self
[
1
])
# Case arg2
if
self
.
is_double_arithmetic
()
or
self
.
is_set_if_less
()
\
or
self
.
is_logical
()
or
self
.
is_truncate
()
\
or
self
.
is_command
(
'
addu
'
,
'
subu
'
,
'
div
'
):
if
not
isinstance
(
self
[
2
],
int
):
use
.
a
ppen
d
(
self
[
2
])
use
.
a
d
d
(
self
[
2
])
return
use
...
...
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