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
82759127
Commit
82759127
authored
Dec 28, 2011
by
Richard Torenvliet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tried to implement gen and kill set, commented implementation
parent
870d25ee
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
37 deletions
+44
-37
src/dataflow.py
src/dataflow.py
+30
-30
src/optimize/advanced.py
src/optimize/advanced.py
+1
-1
tests/test_dataflow.py
tests/test_dataflow.py
+13
-6
No files found.
src/dataflow.py
View file @
82759127
...
@@ -26,37 +26,37 @@ class BasicBlock(Block):
...
@@ -26,37 +26,37 @@ class BasicBlock(Block):
self
.
dominates
.
append
(
block
)
self
.
dominates
.
append
(
block
)
block
.
dominated_by
.
append
(
self
)
block
.
dominated_by
.
append
(
self
)
def
get_gen
(
self
):
for
s
in
self
.
statements
:
# def get_gen(self):
if
s
.
is_arith
():
# for s in self.statements:
self
.
gen_set
.
add
(
s
[
0
])
# if s.is_arith():
print
'added: '
,
s
[
0
]
# self.gen_set.add(s[0])
# print 'added: ', s[0]
return
self
.
gen_set
#
# return self.gen_set
def
get_kill
(
self
):
#
#
if self.edges_from != []
:
#
def get_kill(self)
:
for
backw
in
self
.
edges_from
:
## if self.edges_from != []
:
self
.
kill_set
=
self
.
kill_set
|
backw
.
get_kill
()
#
# for backw in self.edges_from:
self
.
kill_set
=
self
.
kill_set
-
self
.
get_gen
()
# self.kill_set = self.gen_set & backw.kill_set
print
'get_kill_set'
,
self
.
kill_set
#
return
self
.
kill_set
# self.kill_set = self.kill_set - self.get_gen()
# print 'get_kill_set', self.kill_set
def
get_in
(
self
):
# return self.kill_set
for
backw
in
self
.
edges_from
:
self
.
in_set
=
self
.
in_set
|
backw
.
get_out
()
# def get_in(self):
print
'in_set'
,
self
.
in_set
# for backw in self.edges_from:
return
self
.
in
_set
# self.in_set = self.in_set | backw.out
_set
# print 'in_set', self.in_set
def
get_out
(
self
):
# return self.in_set
print
'gen_set'
,
self
.
gen_set
print
'get_in'
,
self
.
get_in
()
# def get_out(self):
print
'get_kill'
,
self
.
get_kill
()
# print 'gen_set', self.gen_set
self
.
out_set
=
self
.
gen_set
|
(
self
.
get_in
()
-
self
.
get_kill
()
)
# print 'get_in', self.get_in(
)
# print 'get_kill', self.get_kill()
def
reaching_definition
(
blocks
):
# self.out_set = self.gen_set | (self.get_in() - self.get_kill())
generate_flow_graph
(
blocks
)
...
...
src/optimize/advanced.py
View file @
82759127
tests/test_dataflow.py
View file @
82759127
...
@@ -43,14 +43,21 @@ class TestDataflow(unittest.TestCase):
...
@@ -43,14 +43,21 @@ class TestDataflow(unittest.TestCase):
#
#
# blocks = [b1, b2]
# blocks = [b1, b2]
#
#
# # initialize out[B] = gen[B] for every block
# for block in blocks:
# for block in blocks:
# block.out_set = block.get_gen()
# block.out_set = block.get_gen()
# print 'block.out_set', block.out_set
# print 'block.out_set', block.out_set
#
# generate_flow_graph(blocks)
# generate_flow_graph(blocks)
# print b1.get_gen()
# print b2.get_gen()
# change = True
# print b2.get_out()
# while change:
# for i, block in enumerate(blocks):
# block.get_in()
# oldout = block.out_set
# newout = block.get_out()
# if (block.out_set == block.get_out()):
# change = False
def
test_generate_flow_graph_simple
(
self
):
def
test_generate_flow_graph_simple
(
self
):
...
...
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