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
d3dfaa10
Commit
d3dfaa10
authored
Dec 30, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added dummy block to prevent DCE in library fucntion calls.
parent
5c33f2be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
src/dataflow.py
src/dataflow.py
+18
-3
src/liveness.py
src/liveness.py
+5
-0
No files found.
src/dataflow.py
View file @
d3dfaa10
...
...
@@ -2,7 +2,7 @@ from statement import Block
class
BasicBlock
(
Block
):
def
__init__
(
self
,
statements
=
[]):
def
__init__
(
self
,
statements
=
[]
,
dummy
=
False
):
Block
.
__init__
(
self
,
statements
)
self
.
edges_to
=
[]
self
.
edges_from
=
[]
...
...
@@ -10,6 +10,8 @@ class BasicBlock(Block):
self
.
dominates
=
[]
self
.
dominated_by
=
[]
self
.
dummy
=
dummy
def
add_edge_to
(
self
,
block
):
if
block
not
in
self
.
edges_to
:
self
.
edges_to
.
append
(
block
)
...
...
@@ -58,13 +60,18 @@ def find_basic_blocks(statements):
blocks
.
append
(
BasicBlock
(
statements
[
leaders
[
-
1
]:]))
# Add a target block for unknown jump targets
blocks
.
append
(
BasicBlock
([],
dummy
=
True
))
return
blocks
def
generate_flow_graph
(
blocks
):
"""Add flow graph edge administration of an ordered sequence of basic
blocks."""
for
i
,
b
in
enumerate
(
blocks
):
dummy_block
=
blocks
[
-
1
]
for
i
,
b
in
enumerate
(
blocks
[:
-
1
]):
last_statement
=
b
[
-
1
]
if
last_statement
.
is_jump
():
...
...
@@ -72,9 +79,17 @@ def generate_flow_graph(blocks):
# Compare the target to all leading labels, add an edge if the
# label matches the jump target
for
other
in
blocks
:
target_found
=
False
for
other
in
blocks
[:
-
1
]:
if
other
[
0
].
is_label
(
target
):
b
.
add_edge_to
(
other
)
target_found
=
True
# If the jump target is outside the program, add an edge to the
# dummy block
if
not
target_found
:
b
.
add_edge_to
(
dummy_block
)
# A branch and jump-and-line instruction also creates an edge to
# the next block
...
...
src/liveness.py
View file @
d3dfaa10
...
...
@@ -28,6 +28,11 @@ def create_use_def(block):
used
=
set
()
defined
=
set
()
if
block
.
dummy
:
block
.
use_set
=
set
([
'$4'
,
'$5'
,
'$6'
,
'$7'
])
block
.
def_set
=
set
([
'$2'
,
'$3'
])
return
# Get the last of each definition series and put in in the `def' set
block
.
use_set
=
set
()
block
.
def_set
=
set
()
...
...
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