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

arigo at codespeak.net arigo at codespeak.net
Mon Jun 8 11:46:04 CEST 2009


Author: arigo
Date: Mon Jun  8 11:46:02 2009
New Revision: 65656

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
Log:
oois, ooisnot, ooisnull, oononnull.


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	Mon Jun  8 11:46:02 2009
@@ -863,6 +863,30 @@
                                           self.cpu.ty_char_ptr, "")
         self.vars[op.result] = res
 
+    def generate_OOIS(self, op):
+        self.vars[op.result] = llvm_rffi.LLVMBuildICmp(
+            self.builder, llvm_rffi.Predicate.EQ,
+            self.getptrarg(op.args[0]),
+            self.getptrarg(op.args[1]), "")
+
+    def generate_OOISNOT(self, op):
+        self.vars[op.result] = llvm_rffi.LLVMBuildICmp(
+            self.builder, llvm_rffi.Predicate.NE,
+            self.getptrarg(op.args[0]),
+            self.getptrarg(op.args[1]), "")
+
+    def generate_OOISNULL(self, op):
+        self.vars[op.result] = llvm_rffi.LLVMBuildICmp(
+            self.builder, llvm_rffi.Predicate.EQ,
+            self.getptrarg(op.args[0]),
+            self.cpu.const_null_charptr, "")
+
+    def generate_OONONNULL(self, op):
+        self.vars[op.result] = llvm_rffi.LLVMBuildICmp(
+            self.builder, llvm_rffi.Predicate.NE,
+            self.getptrarg(op.args[0]),
+            self.cpu.const_null_charptr, "")
+
 # ____________________________________________________________
 
 class MissingOperation(Exception):

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	Mon Jun  8 11:46:02 2009
@@ -350,7 +350,41 @@
             assert self.execute_operation(opname, args, 'void') == None
             assert self.guard_failed
 
-            
+    def test_ooops(self):
+        u1_box, U_box = self.alloc_instance(self.U)
+        u2_box, U_box = self.alloc_instance(self.U)
+        r = self.execute_operation(rop.OOIS, [u1_box, u1_box], 'int')
+        assert r.value == 1
+        r = self.execute_operation(rop.OOISNOT, [u2_box, u2_box], 'int')
+        assert r.value == 0
+        r = self.execute_operation(rop.OOIS, [u1_box, u2_box], 'int')
+        assert r.value == 0
+        r = self.execute_operation(rop.OOISNOT, [u2_box, u1_box], 'int')
+        assert r.value == 1
+        r = self.execute_operation(rop.OOISNULL, [u1_box], 'int')
+        assert r.value == 0
+        r = self.execute_operation(rop.OONONNULL, [u2_box], 'int')
+        assert r.value == 1
+        #
+        null_box = self.null_instance()
+        r = self.execute_operation(rop.OOIS, [null_box, null_box], 'int')
+        assert r.value == 1
+        r = self.execute_operation(rop.OOIS, [u1_box, null_box], 'int')
+        assert r.value == 0
+        r = self.execute_operation(rop.OOIS, [null_box, u2_box], 'int')
+        assert r.value == 0
+        r = self.execute_operation(rop.OOISNOT, [null_box, null_box], 'int')
+        assert r.value == 0
+        r = self.execute_operation(rop.OOISNOT, [u2_box, null_box], 'int')
+        assert r.value == 1
+        r = self.execute_operation(rop.OOISNOT, [null_box, u1_box], 'int')
+        assert r.value == 1
+        r = self.execute_operation(rop.OOISNULL, [null_box], 'int')
+        assert r.value == 1
+        r = self.execute_operation(rop.OONONNULL, [null_box], 'int')
+        assert r.value == 0
+
+
 class LLtypeBackendTest(BaseBackendTest):
 
     type_system = 'lltype'
@@ -395,6 +429,9 @@
         T_box = ConstInt(self.cpu.cast_adr_to_int(vtable_for_T_addr))
         return t_box, T_box
 
+    def null_instance(self):
+        return BoxPtr(lltype.nullptr(llmemory.GCREF.TO))
+
 
     def test_casts(self):
         from pypy.rpython.lltypesystem import lltype, llmemory
@@ -446,3 +483,6 @@
         t_box = BoxObj(ootype.cast_to_object(t))
         T_box = ConstObj(ootype.cast_to_object(cls))
         return t_box, T_box
+
+    def null_instance(self):
+        return BoxObj(ootype.NULL)



More information about the Pypy-commit mailing list