aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfijal <unknown>2016-03-22 09:49:17 +0200
committerfijal <unknown>2016-03-22 09:49:17 +0200
commite805ad6c695947438d6c71662e1614b7e5ef7757 (patch)
treee52df96c363675282434204b1fc0de9b6c6d178f /rpython/jit/tool
parentfix some tests (diff)
downloadpypy-e805ad6c695947438d6c71662e1614b7e5ef7757.tar.gz
pypy-e805ad6c695947438d6c71662e1614b7e5ef7757.tar.bz2
pypy-e805ad6c695947438d6c71662e1614b7e5ef7757.zip
whack at this test until it passes
Diffstat (limited to 'rpython/jit/tool')
-rw-r--r--rpython/jit/tool/oparser.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py
index 63a693598e..8fe7f023b7 100644
--- a/rpython/jit/tool/oparser.py
+++ b/rpython/jit/tool/oparser.py
@@ -413,6 +413,54 @@ def parse(input, cpu=None, namespace=None,
return OpParser(input, cpu, namespace, boxkinds,
invent_fail_descr, nonstrict, postprocess).parse()
+def pick_cls(inp):
+ from rpython.jit.metainterp import history
+
+ if inp.type == 'i':
+ return history.IntFrontendOp
+ elif inp.type == 'r':
+ return history.RefFrontendOp
+ else:
+ assert inp.type == 'f'
+ return history.FloatFrontendOp
+
+def convert_loop_to_trace(loop, skip_last=False):
+ from rpython.jit.metainterp.opencoder import Trace
+ from rpython.jit.metainterp.test.test_opencoder import FakeFrame
+ from rpython.jit.metainterp import history, resume
+
+ def get(a):
+ if isinstance(a, history.Const):
+ return a
+ return mapping[a]
+
+ class jitcode:
+ index = 200
+
+ inputargs = [pick_cls(inparg)(i) for i, inparg in
+ enumerate(loop.inputargs)]
+ mapping = {}
+ for one, two in zip(loop.inputargs, inputargs):
+ mapping[one] = two
+ trace = Trace(inputargs)
+ ops = loop.operations
+ if skip_last:
+ ops = ops[:-1]
+ for op in ops:
+ newpos = trace.record_op(op.getopnum(), [get(arg) for arg in
+ op.getarglist()], op.getdescr())
+ if rop.is_guard(op.getopnum()):
+ failargs = []
+ if op.getfailargs():
+ failargs = [get(arg) for arg in op.getfailargs()]
+ frame = FakeFrame(100, jitcode, failargs)
+ resume.capture_resumedata([frame], None, [], trace)
+ if op.type != 'v':
+ newop = pick_cls(op)(newpos)
+ mapping[op] = newop
+ trace._mapping = mapping # for tests
+ return trace
+
def pure_parse(*args, **kwds):
kwds['invent_fail_descr'] = None
return parse(*args, **kwds)