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
7a6c0ad9
Commit
7a6c0ad9
authored
Dec 31, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved pred/succ functions to dataflow.py for common usage.
parent
03268eb5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
19 deletions
+33
-19
src/dataflow.py
src/dataflow.py
+28
-2
src/liveness.py
src/liveness.py
+5
-17
No files found.
src/dataflow.py
View file @
7a6c0ad9
from
copy
import
copy
from
statement
import
Block
...
...
@@ -83,12 +85,12 @@ def generate_flow_graph(blocks):
# Compare the target to all leading labels, add an edge if the
# label matches the jump target
target_found
=
False
#
target_found = False
for
other
in
blocks
:
if
other
[
0
].
is_label
(
target
):
b
.
add_edge_to
(
other
)
target_found
=
True
#
target_found = True
# If the jump target is outside the program, add an edge to the
# dummy block
...
...
@@ -102,3 +104,27 @@ def generate_flow_graph(blocks):
b
.
add_edge_to
(
blocks
[
i
+
1
])
elif
i
<
len
(
blocks
)
-
1
:
b
.
add_edge_to
(
blocks
[
i
+
1
])
def
pred
(
block
,
known
=
[]):
"""Recursively find all predecessors of a node."""
direct
=
filter
(
lambda
b
:
b
!=
block
and
b
not
in
known
,
block
.
edges_from
)
p
=
copy
(
direct
)
for
predecessor
in
direct
:
p
+=
pred
(
predecessor
,
known
+
direct
)
return
p
return
p
def
succ
(
block
,
known
=
[]):
"""Recursively find all successors of a node."""
direct
=
filter
(
lambda
b
:
b
!=
block
and
b
not
in
known
,
block
.
edges_to
)
s
=
copy
(
direct
)
for
successor
in
direct
:
s
+=
succ
(
successor
,
known
+
direct
)
return
s
return
s
src/liveness.py
View file @
7a6c0ad9
from
copy
import
copy
from
dataflow
import
succ
RETURN_REGS
=
[
'$2'
,
'$3'
]
...
...
@@ -20,10 +20,10 @@ def is_reg_dead_after(reg, block, index, known_jump_targets=[]):
# of reserved argument registers are not removed
if
reg
in
RESERVED_USE
and
block
[
-
1
].
is_command
(
'jal'
)
\
and
block
[
-
1
][
0
]
not
in
known_jump_targets
:
if
block
.
verbose
:
block
[
index
].
set_inline_comment
(
' Register %s cannot be removed due to "jal %s"'
%
(
reg
,
block
[
-
1
][
0
]))
#
if block.verbose:
#
block[index].set_inline_comment(
#
' Register %s cannot be removed due to "jal %s"'
#
% (reg, block[-1][0]))
return
False
if
index
<
len
(
block
)
-
1
:
...
...
@@ -72,18 +72,6 @@ def create_use_def(block):
block
.
def_set
.
add
(
reg
)
def
succ
(
block
,
known
=
[]):
"""Recursively find all successors of a node."""
direct
=
filter
(
lambda
b
:
b
!=
block
and
b
not
in
known
,
block
.
edges_to
)
s
=
copy
(
direct
)
for
successor
in
direct
:
s
+=
succ
(
successor
,
known
+
direct
)
return
s
return
s
def
create_in_out
(
blocks
):
for
b
in
blocks
:
create_use_def
(
b
)
...
...
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