Author: Maciej Fijalkowski <[email protected]>
Branch: unroll-if-const
Changeset: r45967:e7febacd5843
Date: 2011-07-25 17:52 +0200
http://bitbucket.org/pypy/pypy/changeset/e7febacd5843/
Log: jtransform support
diff --git a/pypy/jit/codewriter/jtransform.py
b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -342,9 +342,15 @@
argument is jitcode, then number of const arg then calldescr and
finally all other args
"""
- import pdb
- pdb.set_trace()
[targetgraph] = self.callcontrol.graphs_from(op)
+ jitcode = self.callcontrol.get_jitcode(targetgraph,
+ called_from=self.graph)
+ no = targetgraph.func._jit_unroll_if_const_[0]
+ calldescr = self.callcontrol.getcalldescr(op)
+ op0 = self.rewrite_call(op, 'inline_ifconst_call', [jitcode, no,
+ calldescr])
+ op1 = SpaceOperation('-live-', [], None)
+ return [op0, op1]
def handle_builtin_call(self, op):
oopspec_name, args = support.decode_builtin_call(op)
diff --git a/pypy/jit/codewriter/test/test_jtransform.py
b/pypy/jit/codewriter/test/test_jtransform.py
--- a/pypy/jit/codewriter/test/test_jtransform.py
+++ b/pypy/jit/codewriter/test/test_jtransform.py
@@ -54,6 +54,21 @@
assert graph == 'somegraph'
return 'somejitcode'
+class FakeRegularIfConstCallControl:
+ class somegraph:
+ class func:
+ _jit_unroll_if_const_ = (0,)
+
+ def guess_call_kind(self, op):
+ return 'regularifconst'
+ def graphs_from(self, op):
+ return [self.somegraph]
+ def get_jitcode(self, graph, called_from=None):
+ assert graph is self.somegraph
+ return 'somejitcode'
+ def getcalldescr(self, op):
+ return 'calldescr'
+
class FakeResidualIndirectCallControl:
def guess_call_kind(self, op):
return 'residual'
@@ -274,6 +289,7 @@
yield direct_call_test, ARGS, RESTYPE, expectedkind
yield indirect_residual_call_test, ARGS, RESTYPE, expectedkind
yield indirect_regular_call_test, ARGS, RESTYPE, expectedkind
+ yield regular_ifconst_call_test, ARGS, RESTYPE, expectedkind
def get_direct_call_op(argtypes, restype):
FUNC = lltype.FuncType(argtypes, restype)
@@ -305,6 +321,16 @@
assert op1.opname == '-live-'
assert op1.args == []
+def regular_ifconst_call_test(argtypes, restype, expectedkind):
+ op = get_direct_call_op(argtypes, restype)
+ tr = Transformer(FakeCPU(), FakeRegularIfConstCallControl())
+ tr.graph = 'graph'
+ oplist = tr.rewrite_operation(op)
+ op0, op1 = oplist
+ reskind = getkind(restype)[0]
+ assert op0.opname == 'inline_ifconst_call_%s_%s' % (expectedkind, reskind)
+ assert op0.args[0] == 'somejitcode'
+
def direct_call_test(argtypes, restype, expectedkind):
op = get_direct_call_op(argtypes, restype)
tr = Transformer(FakeCPU(), FakeRegularCallControl())
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit