[pypy-svn] r20953 - in pypy/dist/pypy/jit: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Dec 9 18:02:24 CET 2005
Author: arigo
Date: Fri Dec 9 18:02:24 2005
New Revision: 20953
Added:
pypy/dist/pypy/jit/test/test_jit_tl.py
Modified:
pypy/dist/pypy/jit/llabstractinterp.py
Log:
(mwh, arigo)
Intermediate check-in to switch machines.
Modified: pypy/dist/pypy/jit/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp.py Fri Dec 9 18:02:24 2005
@@ -53,6 +53,11 @@
def match(self, other):
return isinstance(other, LLRuntimeValue) # XXX and ...
+orig_v = Constant(None)
+orig_v.concretetype = lltype.Void
+ll_no_return_value = LLRuntimeValue(orig_v)
+del orig_v
+
class BlockState(object):
"""Entry state of a block, as a combination of LLAbstractValues
@@ -205,10 +210,20 @@
self.flowin(state)
next.settarget(state.copyblock)
for link in state.copyblock.exits:
- if (link not in seen and link.target is not graph.returnblock
- and link.target is not graph.exceptblock):
- pending.append(link)
+ if link not in seen:
seen[link] = True
+ if link.target is None or link.target.operations != ():
+ pending.append(link)
+ else:
+ # link.target is a return or except block; make sure
+ # that it is really the one from 'graph' -- by patching
+ # 'graph' if necessary.
+ if len(link.target.inputargs) == 1:
+ graph.returnblock = link.target
+ elif len(link.target.inputargs) == 2:
+ graph.exceptblock = link.target
+ else:
+ raise Exception("uh?")
# the graph should be complete now; sanity-check
checkgraph(graph)
@@ -308,10 +323,10 @@
self.residual_operations.append(op)
def residualize(self, op, args_a, constant_op=None):
- RESULT = op.result.concretetype
- if RESULT is lltype.Void:
- return XXX_later
if constant_op:
+ RESULT = op.result.concretetype
+ if RESULT is lltype.Void:
+ return ll_no_return_value
a_result = self.constantfold(constant_op, args_a)
if a_result is not None:
return a_result
@@ -333,6 +348,15 @@
def op_int_mul(self, op, a1, a2):
return self.residualize(op, [a1, a2], operator.mul)
+ def op_int_and(self, op, a1, a2):
+ return self.residualize(op, [a1, a2], operator.and_)
+
+ def op_int_rshift(self, op, a1, a2):
+ return self.residualize(op, [a1, a2], operator.rshift)
+
+ def op_int_neg(self, op, a1):
+ return self.residualize(op, [a1], operator.neg)
+
def op_int_gt(self, op, a1, a2):
return self.residualize(op, [a1, a2], operator.gt)
@@ -409,4 +433,14 @@
constant_op = operator.getitem
return self.residualize(op, [a_ptr, a_index], constant_op)
-
+ def op_malloc(self, op, a_T):
+ return self.residualize(op, [a_T])
+
+ def op_malloc_varsize(self, op, a_T, a_size):
+ return self.residualize(op, [a_T, a_size])
+
+ def op_setfield(self, op, a_ptr, a_attrname, a_value):
+ return self.residualize(op, [a_ptr, a_attrname, a_value])
+
+ def op_setarrayitem(self, op, a_ptr, a_index, a_value):
+ return self.residualize(op, [a_ptr, a_index, a_value])
Added: pypy/dist/pypy/jit/test/test_jit_tl.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/jit/test/test_jit_tl.py Fri Dec 9 18:02:24 2005
@@ -0,0 +1,28 @@
+# "coughcoughcough" applies to most of this file
+
+from pypy.translator.translator import TranslationContext
+from pypy.jit import tl
+from pypy.jit.llabstractinterp import LLAbstractInterp
+from pypy.rpython.rstr import string_repr
+
+
+def jit_tl(code):
+ t = TranslationContext()
+ t.buildannotator().build_types(tl.interp, [str, int])
+ rtyper = t.buildrtyper()
+ rtyper.specialize()
+ graph1 = t.graphs[0]
+
+ interp = LLAbstractInterp()
+ hints = {graph1.getargs()[0]: string_repr.convert_const(code),
+ graph1.getargs()[1]: 0}
+
+ graph2 = interp.eval(graph1, hints)
+ graph2.show()
+
+
+def INPROGRESS_test_jit_tl_1():
+ code = tl.compile("""
+ PUSH 42
+ """)
+ jit_tl(code)
More information about the Pypy-commit
mailing list