[pypy-svn] pypy jit-longlong: Initial tests for the branch in which the goal is to support
arigo
commits-noreply at bitbucket.org
Thu Jan 6 19:49:11 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong
Changeset: r40423:11b4ba96e1be
Date: 2011-01-06 19:48 +0100
http://bitbucket.org/pypy/pypy/changeset/11b4ba96e1be/
Log: Initial tests for the branch in which the goal is to support long
longs by passing them around as BoxFloat and ConstFloat.
diff --git a/pypy/jit/codewriter/test/test_longlong.py b/pypy/jit/codewriter/test/test_longlong.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/codewriter/test/test_longlong.py
@@ -0,0 +1,46 @@
+import py, sys
+
+from pypy.rlib.rarithmetic import r_longlong
+from pypy.objspace.flow.model import SpaceOperation, Variable, Constant
+from pypy.translator.unsimplify import varoftype
+from pypy.rpython.lltypesystem import lltype
+from pypy.jit.codewriter.jtransform import Transformer, NotSupported
+from pypy.jit.codewriter.test.test_jtransform import const
+
+
+class FakeCPU:
+ def __init__(self, supports_longlong):
+ self.supports_longlong = supports_longlong
+
+
+class TestLongLong:
+ def setup_class(cls):
+ if sys.maxint > 2147483647:
+ py.test.skip("only for 32-bit platforms")
+
+ def test_unsupported_op(self):
+ tr = Transformer(FakeCPU([]))
+ # without a long long
+ op = SpaceOperation('foobar', [const(123)], varoftype(lltype.Signed))
+ op1 = tr.rewrite_operation(op)
+ assert op1 == op
+ # with a long long argument
+ op = SpaceOperation('foobar', [const(r_longlong(123))],
+ varoftype(lltype.Signed))
+ py.test.raises(NotSupported, tr.rewrite_operation, op)
+ # with a long long result
+ op = SpaceOperation('foobar', [const(123)],
+ varoftype(lltype.SignedLongLong))
+ py.test.raises(NotSupported, tr.rewrite_operation, op)
+
+ def test_prebuilt_constant_32(self):
+ c_x = const(r_longlong(-171))
+ op = SpaceOperation('foobar', [c_x], None)
+ oplist = Transformer(FakeCPU(['foobar'])).rewrite_operation(op)
+ assert len(oplist) == 2
+ assert oplist[0].opname == 'cast_int_to_longlong'
+ assert oplist[0].args == [c_x]
+ v = oplist[0].result
+ assert isinstance(v, Variable)
+ assert oplist[1].opname == 'foobar'
+ assert oplist[1].args == [v]
More information about the Pypy-commit
mailing list