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
82759127
Commit
82759127
authored
13 years ago
by
Richard Torenvliet
Browse files
Options
Downloads
Patches
Plain Diff
tried to implement gen and kill set, commented implementation
parent
870d25ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/dataflow.py
+30
-30
30 additions, 30 deletions
src/dataflow.py
src/optimize/advanced.py
+1
-1
1 addition, 1 deletion
src/optimize/advanced.py
tests/test_dataflow.py
+13
-6
13 additions, 6 deletions
tests/test_dataflow.py
with
44 additions
and
37 deletions
src/dataflow.py
+
30
−
30
View file @
82759127
...
...
@@ -25,38 +25,38 @@ class BasicBlock(Block):
if
block
not
in
self
.
dominates
:
self
.
dominates
.
append
(
block
)
block
.
dominated_by
.
append
(
self
)
def
get_gen
(
self
):
for
s
in
self
.
statements
:
if
s
.
is_arith
():
self
.
gen_set
.
add
(
s
[
0
])
print
'
added:
'
,
s
[
0
]
return
self
.
gen_set
def
get_kill
(
self
):
# if self.edges_from != []:
for
backw
in
self
.
edges_from
:
self
.
kill_set
=
self
.
kill_set
|
backw
.
get_kill
()
self
.
kill_set
=
self
.
kill_set
-
self
.
get_gen
()
print
'
get_kill_set
'
,
self
.
kill_set
return
self
.
kill_set
def
get_in
(
self
):
for
backw
in
self
.
edges_from
:
self
.
in_set
=
self
.
in_set
|
backw
.
get_out
()
print
'
in_set
'
,
self
.
in_set
return
self
.
in_set
def
get_out
(
self
):
print
'
gen_set
'
,
self
.
gen_set
print
'
get_in
'
,
self
.
get_in
()
print
'
get_kill
'
,
self
.
get_kill
()
self
.
out_set
=
self
.
gen_set
|
(
self
.
get_in
()
-
self
.
get_kill
())
# def get_gen(self):
# for s in self.statements:
# if s.is_arith():
# self.gen_set.add(s[0])
# print 'added: ', s[0]
#
# return self.gen_set
#
# def get_kill(self):
## if self.edges_from != []:
#
# for backw in self.edges_from:
# self.kill_set = self.gen_set & backw.kill_set
#
# self.kill_set = self.kill_set - self.get_gen()
# print 'get_kill_set', self.kill_set
# return self.kill_set
# def get_in(self):
# for backw in self.edges_from:
# self.in_set = self.in_set | backw.out_set
# print 'in_set', self.in_set
# return self.in_set
# def get_out(self):
# print 'gen_set', self.gen_set
# print 'get_in', self.get_in()
# print 'get_kill', self.get_kill()
# self.out_set = self.gen_set | (self.get_in() - self.get_kill())
def
reaching_definition
(
blocks
):
generate_flow_graph
(
blocks
)
...
...
This diff is collapsed.
Click to expand it.
src/optimize/advanced.py
+
1
−
1
View file @
82759127
...
...
@@ -55,7 +55,7 @@ def eliminate_common_subexpressions(block):
block
.
reverse_statements
()
return
found
def
to_hex
(
value
):
"""
Create the hexadecimal string of an integer.
"""
...
...
This diff is collapsed.
Click to expand it.
tests/test_dataflow.py
+
13
−
6
View file @
82759127
...
...
@@ -43,14 +43,21 @@ class TestDataflow(unittest.TestCase):
#
# blocks = [b1, b2]
#
# # initialize out[B] = gen[B] for every block
# for block in blocks:
# block.out_set = block.get_gen()
# print 'block.out_set', block.out_set
# generate_flow_graph(blocks)
# print b1.get_gen()
# print b2.get_gen()
# print b2.get_out()
# print 'block.out_set', block.out_set
#
# generate_flow_graph(blocks)
# change = True
# 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
):
...
...
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