[pypy-svn] pypy default: add the possibility to completely skip certain ops during the match
antocuni
commits-noreply at bitbucket.org
Fri Apr 15 11:54:38 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r43382:d3939c552848
Date: 2011-04-15 11:42 +0200
http://bitbucket.org/pypy/pypy/changeset/d3939c552848/
Log: add the possibility to completely skip certain ops during the match
diff --git a/pypy/module/pypyjit/test_pypy_c/model.py b/pypy/module/pypyjit/test_pypy_c/model.py
--- a/pypy/module/pypyjit/test_pypy_c/model.py
+++ b/pypy/module/pypyjit/test_pypy_c/model.py
@@ -314,7 +314,7 @@
# it matched! The '...' operator ends here
return op
- def match_loop(self, expected_ops):
+ def match_loop(self, expected_ops, ignore_ops):
"""
A note about partial matching: the '...' operator is non-greedy,
i.e. it matches all the operations until it finds one that matches
@@ -333,13 +333,16 @@
return
op = self.match_until(exp_op, iter_ops)
else:
- op = self._next_op(iter_ops)
+ while True:
+ op = self._next_op(iter_ops)
+ if op.name not in ignore_ops:
+ break
self.match_op(op, exp_op)
#
# make sure we exhausted iter_ops
self._next_op(iter_ops, assert_raises=True)
- def match(self, expected_src):
+ def match(self, expected_src, ignore_ops=[]):
def format(src):
if src is None:
return ''
@@ -348,7 +351,7 @@
expected_src = self.preprocess_expected_src(expected_src)
expected_ops = self.parse_ops(expected_src)
try:
- self.match_loop(expected_ops)
+ self.match_loop(expected_ops, ignore_ops)
except InvalidMatch, e:
#raise # uncomment this and use py.test --pdb for better debugging
print '@' * 40
@@ -357,6 +360,7 @@
print e.args
print e.msg
print
+ print "Ignore ops:", ignore_ops
print "Got:"
print format(self.src)
print
diff --git a/pypy/module/pypyjit/test_pypy_c/test_model.py b/pypy/module/pypyjit/test_pypy_c/test_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_model.py
@@ -100,11 +100,11 @@
class TestOpMatcher(object):
- def match(self, src1, src2):
+ def match(self, src1, src2, **kwds):
from pypy.tool.jitlogparser.parser import SimpleParser
loop = SimpleParser.parse_from_input(src1)
matcher = OpMatcher(loop.operations, src=src1)
- return matcher.match(src2)
+ return matcher.match(src2, **kwds)
def test_match_var(self):
match_var = OpMatcher([]).match_var
@@ -234,6 +234,21 @@
"""
assert self.match(loop, expected)
+ def test_ignore_opcodes(self):
+ loop = """
+ [i0]
+ i1 = int_add(i0, 1)
+ i4 = force_token()
+ i2 = int_sub(i1, 10)
+ jump(i4)
+ """
+ expected = """
+ i1 = int_add(i0, 1)
+ i2 = int_sub(i1, 10)
+ jump(i4, descr=...)
+ """
+ assert self.match(loop, expected, ignore_ops=['force_token'])
+
class TestRunPyPyC(BaseTestPyPyC):
More information about the Pypy-commit
mailing list