[pypy-svn] r65687 - in pypy/branch/pyjitpl5-experiments/pypy/jit/backend: llvm test

arigo at codespeak.net arigo at codespeak.net
Tue Jun 9 13:38:09 CEST 2009


Author: arigo
Date: Tue Jun  9 13:38:05 2009
New Revision: 65687

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
Log:
Finish the do_xxx operations.


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py	Tue Jun  9 13:38:05 2009
@@ -659,6 +659,16 @@
         else:
             return BoxInt(self.get_latest_value_int(0))
 
+    def do_cast_int_to_ptr(self, args, descr=None):
+        int = args[0].getint()
+        res = rffi.cast(llmemory.GCREF, int)
+        return BoxPtr(res)
+
+    def do_cast_ptr_to_int(self, args, descr=None):
+        ptr = args[0].getptr_base()
+        res = rffi.cast(lltype.Signed, ptr)
+        return BoxInt(res)
+
 
 class SizeDescr(AbstractDescr):
     def __init__(self, size):

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py	Tue Jun  9 13:38:05 2009
@@ -751,6 +751,13 @@
         #
         cpu.do_strsetitem([x, BoxInt(4), BoxInt(ord('/'))])
         assert x.getptr(lltype.Ptr(rstr.STR)).chars[4] == '/'
+        #
+        x = cpu.do_newstr([BoxInt(5)])
+        y = cpu.do_cast_ptr_to_int([x])
+        assert isinstance(y, BoxInt)
+        z = cpu.do_cast_int_to_ptr([y])
+        assert isinstance(z, BoxPtr)
+        assert z.value == x.value
 
 
 class OOtypeBackendTest(BaseBackendTest):



More information about the Pypy-commit mailing list