[pypy-svn] r36051 - in pypy/dist/pypy/jit/codegen/llvm: . test

ericvrp at codespeak.net ericvrp at codespeak.net
Sat Dec 30 00:09:49 CET 2006


Author: ericvrp
Date: Sat Dec 30 00:09:37 2006
New Revision: 36051

Added:
   pypy/dist/pypy/jit/codegen/llvm/compatibility.py   (contents, props changed)
Modified:
   pypy/dist/pypy/jit/codegen/llvm/rgenop.py
   pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py
   pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py
   pypy/dist/pypy/jit/codegen/llvm/test/test_rgenop.py
Log:
Moved llvm 1.9/2/0 specific code into its own file.
More tests now pass on with versions.
1.9 failures are mostly caused by segfaults. Need to look into this...
probably a broken llvm transformation.


Added: pypy/dist/pypy/jit/codegen/llvm/compatibility.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/jit/codegen/llvm/compatibility.py	Sat Dec 30 00:09:37 2006
@@ -0,0 +1,20 @@
+'''
+Use this file to hide differences between llvm 1.x and 2.x .
+'''
+from pypy.jit.codegen.llvm.llvmjit import llvm_version
+
+
+if llvm_version() < 2.0:
+    icmp = scmp = ucmp = fcmp = 'set'
+    inttoptr = trunc = zext = bitcast = 'cast'
+    shr_prefix = ('', '')
+else:   # >= 2.0
+    icmp = 'icmp '
+    scmp = 'icmp s'
+    ucmp = 'icmp u'
+    fcmp = 'fcmp o'
+    inttoptr = 'inttoptr'
+    trunc = 'trunc'
+    zext = 'zext'
+    bitcast = 'bitcast'
+    shr_prefix = ('l', 'a')

Modified: pypy/dist/pypy/jit/codegen/llvm/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/llvm/rgenop.py	Sat Dec 30 00:09:37 2006
@@ -7,29 +7,16 @@
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.jit.codegen.i386.rgenop import gc_malloc_fnaddr
 from pypy.jit.codegen.llvm.conftest import option
+from pypy.jit.codegen.llvm.compatibility import icmp, scmp, ucmp, fcmp, inttoptr,\
+    trunc, zext, bitcast, shr_prefix
 
 
-#note: To use this code you'll need llvm 2.0 . At the time of writing that
-#      version is still somewhere in the future so use cvs head that gets
-#      closest! Version 2.0 introduces fileformat changes as described here:
-#      http://nondot.org/sabre/LLVMNotes/TypeSystemChanges.txt
-
 LINENO       = option.lineno
 PRINT_SOURCE = option.print_source
 PRINT_DEBUG  = option.print_debug
 
 WORD = 4
 
-llvm2 = llvmjit.llvm_version() >= 2.0
-
-if llvm2:
-    icmp = 'icmp '
-    scmp = 'icmp s'
-    ucmp = 'icmp u'
-    fcmp = 'fcmp o'
-else:
-    icmp = scmp = ucmp = fcmp = 'set'
-
 
 class ParseException(Exception):
     pass
@@ -399,7 +386,8 @@
 
     def op_int_lshift(self, gv_x, gv_y):
         gv_y_ubyte = Var('ubyte')
-        self.asm.append(' %s=trunc %s to ubyte' % (gv_y_ubyte.operand2(), gv_y.operand()))
+        self.asm.append(' %s=%s %s to ubyte' % (
+            gv_y_ubyte.operand2(), trunc, gv_y.operand()))
         gv_result = Var(gv_x.type)
         self.asm.append(' %s=shl %s,%s' % (
             gv_result.operand2(), gv_x.operand(), gv_y_ubyte.operand()))
@@ -407,10 +395,11 @@
 
     def op_int_rshift(self, gv_x, gv_y):
         gv_y_ubyte = Var('ubyte')
-        self.asm.append(' %s=trunc %s to ubyte' % (gv_y_ubyte.operand2(), gv_y.operand()))
+        self.asm.append(' %s=%s %s to ubyte' % (
+            gv_y_ubyte.operand2(), trunc, gv_y.operand()))
         gv_result = Var(gv_x.type)
         self.asm.append(' %s=%sshr %s,%s' % (
-            gv_result.operand2(), 'la'[gv_x.signed], gv_x.operand(), gv_y_ubyte.operand()))
+            gv_result.operand2(), shr_prefix[gv_x.signed], gv_x.operand(), gv_y_ubyte.operand()))
         return gv_result
 
     op_uint_add = op_float_add = op_int_add
@@ -523,8 +512,8 @@
     def genop_same_as(self, kind, gv_x):
         if gv_x.is_const:    # must always return a var
             gv_result = Var(gv_x.type)
-            self.asm.append(' %s=bitcast %s to %s' % (
-                gv_result.operand2(), gv_x.operand(), gv_x.type))
+            self.asm.append(' %s=%s %s to %s' % (
+                gv_result.operand2(), bitcast, gv_x.operand(), gv_x.type))
             return gv_result
         else:
             return gv_x
@@ -534,8 +523,8 @@
         if restype is gv_x.type:
             return self.genop_same_as(None, gv_x)
         gv_result = Var(restype)
-        self.asm.append(' %s=zext %s to %s' % (
-            gv_result.operand2(), gv_x.operand(), restype))
+        self.asm.append(' %s=%s %s to %s' % (
+            gv_result.operand2(), zext, gv_x.operand(), restype))
         return gv_result
 
     def _trunc_to(self, gv_x, restype=None):
@@ -543,8 +532,8 @@
         if restype is gv_x.type:
             return self.genop_same_as(None, gv_x)
         gv_result = Var(restype)
-        self.asm.append(' %s=trunc %s to %s' % (
-            gv_result.operand2(), gv_x.operand(), restype))
+        self.asm.append(' %s=%s %s to %s' % (
+            gv_result.operand2(), trunc, gv_x.operand(), restype))
         return gv_result
 
     def _cast_to_bool(self, gv_x):      return self._cast_to(gv_x, 'bool')
@@ -776,8 +765,8 @@
         if gv.is_const:
             gv_var = Var(gv.type)
             #XXX provide correct cast here
-            self.asm.append(' %s=inttoptr int %s to %s' % (
-                gv_var.operand2(), gv.operand2(), gv_var.type))
+            self.asm.append(' %s=%s int %s to %s' % (
+                gv_var.operand2(), inttoptr, gv.operand2(), gv_var.type))
             return gv_var
         return gv
         
@@ -807,8 +796,8 @@
         gv_result = Var('ubyte*') #XXX or opaque* ???
         gv_gc_malloc_fnaddr = Var('%s (int)*' % gv_result.type)
         #XXX or use addGlobalFunctionMapping in libllvmjit.restart()
-        self.asm.append(' %s=inttoptr int %d to %s ;gc_malloc_fnaddr' % (
-            gv_gc_malloc_fnaddr.operand2(), gc_malloc_fnaddr(), gv_gc_malloc_fnaddr.type))
+        self.asm.append(' %s=%s int %d to %s ;gc_malloc_fnaddr' % (
+            gv_gc_malloc_fnaddr.operand2(), inttoptr, gc_malloc_fnaddr(), gv_gc_malloc_fnaddr.type))
         self.asm.append(' %s=call %s(int %d)' % (
             gv_result.operand2(), gv_gc_malloc_fnaddr.operand(), size))
         return gv_result
@@ -819,8 +808,8 @@
         gv_result = Var('ubyte*') #XXX or opaque* ???
         gv_gc_malloc_fnaddr = Var('%s (int)*' % gv_result.type)
         #XXX or use addGlobalFunctionMapping in libllvmjit.restart()
-        self.asm.append(' %s=inttoptr int %d to %s ;gc_malloc_fnaddr' % (
-            gv_gc_malloc_fnaddr.operand2(), gc_malloc_fnaddr(), gv_gc_malloc_fnaddr.type))
+        self.asm.append(' %s=%s int %d to %s ;gc_malloc_fnaddr' % (
+            gv_gc_malloc_fnaddr.operand2(), inttoptr, gc_malloc_fnaddr(), gv_gc_malloc_fnaddr.type))
         self.asm.append(' %s=call %s(%s)' % (
             gv_result.operand2(), gv_gc_malloc_fnaddr.operand(), gv_size.operand()))
         #XXX TODO set length field
@@ -836,8 +825,8 @@
         gv_returnvar = Var(restype)
         if isinstance(gv_fnptr, AddrConst):
             gv_fn = Var(self._funcsig_type(args_gv, restype))
-            self.asm.append(' %s=bitcast %s to %s' % (
-                gv_fnptr.operand2(), gv_fnptr.operand(), gv_fn.type))
+            self.asm.append(' %s=%s %s to %s' % (
+                gv_fnptr.operand2(), bitcast, gv_fnptr.operand(), gv_fn.type))
             funcsig = gv_fn.operand()
         else:
             #XXX we probably need to call an address directly if we can't resolve the funcsig

Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py	(original)
+++ pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py	Sat Dec 30 00:09:37 2006
@@ -26,17 +26,9 @@
         py.test.skip('found llvm %.1f, requires at least llvm %.1f(cvs)' % (
             llvm_version(), MINIMAL_VERSION))
 
-    if llvm_version() < MINIMAL_VERSION:
-        test_loop_merging = skip_too_minimal
-        test_two_loops_merging = skip_too_minimal
-        test_merge_3_redconsts_before_return = skip_too_minimal
-        test_degenerated_before_return = skip_too_minimal
-        test_degenerated_before_return_2 = skip_too_minimal
-        test_setarrayitem = skip_too_minimal
-        test_degenerated_via_substructure = skip_too_minimal
-        test_merge_structures = skip_too_minimal
-        test_split_on_green_return = skip_too_minimal
-        test_normalize_indirect_call_more = skip_too_minimal
+    if llvm_version() < 2.0:
+        test_loop_merging = skip_too_minimal #segfault
+        test_two_loops_merging = skip_too_minimal #segfault
 
     if skip_passing:
         test_very_simple = skip
@@ -93,3 +85,5 @@
         test_residual_red_call = skip
         test_residual_red_call_with_exc = skip
 
+    test_green_char_at_merge = skip #->SomeObject() (CharRepr @rgenop.py:141 ?)
+

Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py	(original)
+++ pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py	Sat Dec 30 00:09:37 2006
@@ -23,14 +23,7 @@
             llvm_version(), MINIMAL_VERSION))
 
     if llvm_version() < 2.0:
-        test_arithmetic = skip_too_minimal
-        test_comparison = skip_too_minimal
-        test_char_comparison = skip_too_minimal
-        test_unichar_comparison = skip_too_minimal
-        test_char_array = skip_too_minimal
-        test_char_varsize_array = skip_too_minimal
-        test_unsigned = skip_too_minimal
-        test_float_arithmetic = skip_too_minimal
+        test_float_arithmetic = skip_too_minimal #segfault
 
     test_float_pow = skip
     test_unichar_array = skip

Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/test/test_rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/llvm/test/test_rgenop.py	Sat Dec 30 00:09:37 2006
@@ -19,9 +19,9 @@
         py.test.skip('found llvm %.1f, requires at least llvm %.1f(cvs)' % (
             llvm_version(), MINIMAL_VERSION))
 
-    if llvm_version() < MINIMAL_VERSION:
-        test_goto_direct = skip_too_minimal
-        test_goto_compile = skip_too_minimal
-        test_fact_direct = skip_too_minimal
+    if llvm_version() < 2.0:
+        test_goto_direct = skip_too_minimal #segfault
+        test_goto_compile = skip_too_minimal #segfault
+        test_fact_direct = skip_too_minimal #segfault
 
     test_fact_compile = skip #XXX Blocked block, introducted by this checkin (I don't understand)



More information about the Pypy-commit mailing list