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