[pypy-svn] r72934 - in pypy/branch/blackhole-improvement/pypy/tool/algo: . test
fijal at codespeak.net
fijal at codespeak.net
Sat Mar 27 00:58:33 CET 2010
Author: fijal
Date: Sat Mar 27 00:58:31 2010
New Revision: 72934
Added:
pypy/branch/blackhole-improvement/pypy/tool/algo/color.py (contents, props changed)
pypy/branch/blackhole-improvement/pypy/tool/algo/test/test_color.py (contents, props changed)
Log:
Start writing graph coloring algorithm.
Not much so far, that was arguably not a very productive day.
Added: pypy/branch/blackhole-improvement/pypy/tool/algo/color.py
==============================================================================
--- (empty file)
+++ pypy/branch/blackhole-improvement/pypy/tool/algo/color.py Sat Mar 27 00:58:31 2010
@@ -0,0 +1,7 @@
+
+class DependencyGraph(object):
+ """ A dependency graph for a given control flow graph (CFG).
+
+ Each variable is an node in a graph and we have an edge
+ if two variables are alive at the same point of time
+ """
Added: pypy/branch/blackhole-improvement/pypy/tool/algo/test/test_color.py
==============================================================================
--- (empty file)
+++ pypy/branch/blackhole-improvement/pypy/tool/algo/test/test_color.py Sat Mar 27 00:58:31 2010
@@ -0,0 +1,16 @@
+
+from pypy.translator.translator import graphof
+from pypy.annotation.annrpython import RPythonAnnotator
+from pypy.tool.algo.color import DependencyGraph
+
+def test_one():
+ def f(a, b, c):
+ d = a + b
+ e = b + c
+ f = d + e
+ return d + e + f
+
+ a = RPythonAnnotator()
+ a.build_types(f, [int, int, int])
+ graph = graphof(a.translator, f)
+ dep_graph = DependencyGraph(graph)
More information about the Pypy-commit
mailing list