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

ericvrp at codespeak.net ericvrp at codespeak.net
Thu Dec 28 14:18:18 CET 2006


Author: ericvrp
Date: Thu Dec 28 14:18:14 2006
New Revision: 36019

Modified:
   pypy/dist/pypy/jit/codegen/llvm/lib/libllvmjit.cpp
   pypy/dist/pypy/jit/codegen/llvm/llvmjit.py
   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_llvmjit.py
   pypy/dist/pypy/jit/codegen/llvm/test/test_operation.py
   pypy/dist/pypy/jit/codegen/llvm/test/test_rgenop.py
Log:
Make most jit/codegen/llvm test pass with llvm 1.9 too.
Skip those that have know issues.


Modified: pypy/dist/pypy/jit/codegen/llvm/lib/libllvmjit.cpp
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/lib/libllvmjit.cpp	(original)
+++ pypy/dist/pypy/jit/codegen/llvm/lib/libllvmjit.cpp	Thu Dec 28 14:18:14 2006
@@ -74,7 +74,7 @@
 
     PassManager passes;
     passes.add(new TargetData(gp_module));           // some passes need this as a first pass
-    passes.add(createVerifierPass());                // Make sure we start with a good graph
+    passes.add(createVerifierPass(PrintMessageAction)); // Make sure we start with a good graph
     //passes.add(new PrintModulePass());               // Visual feedback
 
     if (optLevel >= 1) {
@@ -143,7 +143,7 @@
     // Compile silly sequences
     passes.add(createInstructionCombiningPass());
     // Make sure everything is still good.
-    passes.add(createVerifierPass());
+    passes.add(createVerifierPass(PrintMessageAction));
     //passes.add(new PrintModulePass());               // Visual feedback
 
     return passes.run(*gp_module);

Modified: pypy/dist/pypy/jit/codegen/llvm/llvmjit.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/llvmjit.py	(original)
+++ pypy/dist/pypy/jit/codegen/llvm/llvmjit.py	Thu Dec 28 14:18:14 2006
@@ -44,6 +44,14 @@
     libraries = (os.path.join(os.path.dirname(path), 'llvmjit'),)
 llvmjit._FuncPtr = _FuncPtr
 
+MINIMAL_VERSION = 2.0
+
+def llvm_version():
+    v = os.popen('llvm-as -version 2>&1').read()
+    v = ''.join([c for c in v if c.isdigit()])
+    v = int(v) / 10.0
+    return v
+
 #ensure stable state (XXX this doesn't seem to get called when translated! We do it in parse!)
 llvmjit.restart()
 

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	Thu Dec 28 14:18:14 2006
@@ -20,14 +20,19 @@
 
 WORD = 4
 
+llvm2 = llvmjit.llvm_version() >= 2.0
 
-MINIMAL_VERSION = 2.0
+if llvm2:
+    icmp = 'icmp '
+    scmp = 'icmp s'
+    ucmp = 'icmp u'
+    fcmp = 'fcmp o'
+else:
+    icmp = scmp = ucmp = fcmp = 'set'
 
-def llvm_version():
-    v = os.popen('llvm-as -version 2>&1').read()
-    v = ''.join([c for c in v if c.isdigit()])
-    v = int(v) / 10.0
-    return v
+
+class ParseException(Exception):
+    pass
 
 
 class Logger:
@@ -422,25 +427,54 @@
     def op_float_truediv(self, gv_x, gv_y):  return self._rgenop2_generic('fdiv', gv_x, gv_y)
     def op_float_neg(self, gv_x): return self._rgenop2_generic('sub', FloatConst(0.0), gv_x)
 
-    def op_int_lt(self, gv_x, gv_y): return self._rgenop2_generic('icmp slt', gv_x, gv_y, 'bool')
-    def op_int_le(self, gv_x, gv_y): return self._rgenop2_generic('icmp sle', gv_x, gv_y, 'bool')
-    def op_int_eq(self, gv_x, gv_y): return self._rgenop2_generic('icmp eq' , gv_x, gv_y, 'bool')
-    def op_int_ne(self, gv_x, gv_y): return self._rgenop2_generic('icmp ne' , gv_x, gv_y, 'bool')
-    def op_int_gt(self, gv_x, gv_y): return self._rgenop2_generic('icmp sgt', gv_x, gv_y, 'bool')
-    def op_int_ge(self, gv_x, gv_y): return self._rgenop2_generic('icmp sge', gv_x, gv_y, 'bool')
-
-    def op_uint_lt(self, gv_x, gv_y): return self._rgenop2_generic('icmp ult', gv_x, gv_y, 'bool')
-    def op_uint_le(self, gv_x, gv_y): return self._rgenop2_generic('icmp ule', gv_x, gv_y, 'bool')
-    def op_uint_gt(self, gv_x, gv_y): return self._rgenop2_generic('icmp ugt', gv_x, gv_y, 'bool')
-    def op_uint_ge(self, gv_x, gv_y): return self._rgenop2_generic('icmp uge', gv_x, gv_y, 'bool')
-
-    def op_float_lt(self, gv_x, gv_y): return self._rgenop2_generic('fcmp olt', gv_x, gv_y, 'bool')
-    def op_float_le(self, gv_x, gv_y): return self._rgenop2_generic('fcmp ole', gv_x, gv_y, 'bool')
-    def op_float_eq(self, gv_x, gv_y): return self._rgenop2_generic('fcmp oeq', gv_x, gv_y, 'bool')
-    def op_float_ne(self, gv_x, gv_y): return self._rgenop2_generic('fcmp one', gv_x, gv_y, 'bool')
-    def op_float_gt(self, gv_x, gv_y): return self._rgenop2_generic('fcmp ogt', gv_x, gv_y, 'bool')
-    def op_float_ge(self, gv_x, gv_y): return self._rgenop2_generic('fcmp oge', gv_x, gv_y, 'bool')
+    def op_int_lt(self, gv_x, gv_y):
+        return self._rgenop2_generic(scmp + 'lt', gv_x, gv_y, 'bool')
+
+    def op_int_le(self, gv_x, gv_y):
+        return self._rgenop2_generic(scmp + 'le', gv_x, gv_y, 'bool')
+
+    def op_int_eq(self, gv_x, gv_y):
+        return self._rgenop2_generic(icmp + 'eq' , gv_x, gv_y, 'bool')
+
+    def op_int_ne(self, gv_x, gv_y):
+        return self._rgenop2_generic(icmp + 'ne' , gv_x, gv_y, 'bool')
+
+    def op_int_gt(self, gv_x, gv_y):
+        return self._rgenop2_generic(scmp + 'gt', gv_x, gv_y, 'bool')
+
+    def op_int_ge(self, gv_x, gv_y):
+        return self._rgenop2_generic(scmp + 'ge', gv_x, gv_y, 'bool')
+
+    def op_uint_lt(self, gv_x, gv_y):
+        return self._rgenop2_generic(ucmp + 'lt', gv_x, gv_y, 'bool')
+
+    def op_uint_le(self, gv_x, gv_y):
+        return self._rgenop2_generic(ucmp + 'le', gv_x, gv_y, 'bool')
 
+    def op_uint_gt(self, gv_x, gv_y):
+        return self._rgenop2_generic(ucmp + 'gt', gv_x, gv_y, 'bool')
+
+    def op_uint_ge(self, gv_x, gv_y):
+        return self._rgenop2_generic(ucmp + 'ge', gv_x, gv_y, 'bool')
+
+    def op_float_lt(self, gv_x, gv_y):
+        return self._rgenop2_generic(fcmp + 'lt', gv_x, gv_y, 'bool')
+
+    def op_float_le(self, gv_x, gv_y): 
+        return self._rgenop2_generic(fcmp + 'le', gv_x, gv_y, 'bool')
+    
+    def op_float_eq(self, gv_x, gv_y): 
+        return self._rgenop2_generic(fcmp + 'eq', gv_x, gv_y, 'bool')
+    
+    def op_float_ne(self, gv_x, gv_y): 
+        return self._rgenop2_generic(fcmp + 'ne', gv_x, gv_y, 'bool')
+
+    def op_float_gt(self, gv_x, gv_y): 
+        return self._rgenop2_generic(fcmp + 'gt', gv_x, gv_y, 'bool')
+
+    def op_float_ge(self, gv_x, gv_y): 
+        return self._rgenop2_generic(fcmp + 'ge', gv_x, gv_y, 'bool')
+    
     op_unichar_eq = op_ptr_eq = op_uint_eq = op_int_eq
     op_unichar_ne = op_ptr_ne = op_uint_ne = op_int_ne
 
@@ -469,9 +503,9 @@
         gv_abs_pos = Var(gv_x.type)
         gv_result  = Var(gv_x.type)
         if nullstr is '0':
-            l = ' %s=icmp sge %s,%s'
+            l = ' %s=' + scmp + 'ge %s,%s'
         else:
-            l = ' %s=fcmp oge %s,%s'
+            l = ' %s=' + fcmp + 'ge %s,%s'
         self.asm.append(l % (gv_comp.operand2(), gv_x.operand(), nullstr))
         self.asm.append(' %s=sub %s %s,%s' % (
             gv_abs_pos.operand2(), gv_x.type, nullstr, gv_x.operand2()))
@@ -611,9 +645,9 @@
         log('%s Builder._is_false %s' % (self.block.label, gv_x.operand()))
         gv_result = Var('bool')
         if nullstr is '0':
-            l = ' %s=icmp eq %s,%s'
+            l = ' %s=' + icmp + 'eq %s,%s'
         else:
-            l = ' %s=fcmp oeq %s,%s'
+            l = ' %s=' + fcmp + 'eq %s,%s'
         self.asm.append(l % (gv_result.operand2(), gv_x.operand(), nullstr))
         return gv_result
 
@@ -621,9 +655,9 @@
         log('%s Builder._is_true %s' % (self.block.label, gv_x.operand()))
         gv_result = Var('bool')
         if nullstr is '0':
-            l = ' %s=icmp ne %s,%s'
+            l = ' %s=' + icmp + 'ne %s,%s'
         else:
-            l = ' %s=fcmp one %s,%s'
+            l = ' %s=' + fcmp + 'ne %s,%s'
         self.asm.append(l % (gv_result.operand2(), gv_x.operand(), nullstr))
         return gv_result
 
@@ -864,7 +898,9 @@
         if PRINT_SOURCE:
             print asm_string
         logger.dump(asm_string)
-        llvmjit.parse(asm_string)
+        parse_ok = llvmjit.parse(asm_string)
+        if not parse_ok:
+            raise ParseException()
         llvmjit.transform(3) #optimize module (should be on functions actually)
         function   = llvmjit.getNamedFunction(self.name)
         entrypoint = llvmjit.getPointerToFunctionAsInt(function)

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	Thu Dec 28 14:18:14 2006
@@ -1,7 +1,8 @@
 import py
 from pypy.jit.codegen.i386.test.test_genc_ts import I386TimeshiftingTestMixin
 from pypy.jit.timeshifter.test import test_timeshift
-from pypy.jit.codegen.llvm.rgenop import RLLVMGenOp, llvm_version, MINIMAL_VERSION
+from pypy.jit.codegen.llvm.rgenop import RLLVMGenOp
+from pypy.jit.codegen.llvm.llvmjit import llvm_version, MINIMAL_VERSION
 
 
 skip_passing = False

Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_llvmjit.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/test/test_llvmjit.py	(original)
+++ pypy/dist/pypy/jit/codegen/llvm/test/test_llvmjit.py	Thu Dec 28 14:18:14 2006
@@ -26,18 +26,19 @@
 }'''
 
 #
-lldeadcode = '''int %deadcode(int %n) {
+llvm2 = llvmjit.llvm_version() >= 2.0
+lldeadcode = '''int %%deadcode(int %%n) {
 Test:
-    %cond = icmp eq int %n, %n
-    br bool %cond, label %IfEqual, label %IfUnequal
+    %%cond = %s int %%n, %%n
+    br bool %%cond, label %%IfEqual, label %%IfUnequal
 
 IfEqual:
-    %n2 = mul int %n, 2
-    ret int %n2
+    %%n2 = mul int %%n, 2
+    ret int %%n2
 
 IfUnequal:
     ret int -1
-}'''
+}''' % ('seteq', 'icmp eq')[llvm2]
 
 #
 llfuncA = '''int %func(int %n) {

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	Thu Dec 28 14:18:14 2006
@@ -1,7 +1,8 @@
 import py
 from pypy.jit.codegen.llvm.test.test_llvmjit import skip_unsupported_platform
 from pypy.jit.codegen.i386.test.test_operation import BasicTests
-from pypy.jit.codegen.llvm.rgenop import RLLVMGenOp, llvm_version, MINIMAL_VERSION
+from pypy.jit.codegen.llvm.rgenop import RLLVMGenOp
+from pypy.jit.codegen.llvm.llvmjit import llvm_version, MINIMAL_VERSION
 
 
 class LLVMTestBasicMixin(object):
@@ -21,7 +22,7 @@
         py.test.skip('found llvm %.1f, requires at least llvm %.1f(cvs)' % (
             llvm_version(), MINIMAL_VERSION))
 
-    if 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

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	Thu Dec 28 14:18:14 2006
@@ -1,5 +1,6 @@
 import py
-from pypy.jit.codegen.llvm.rgenop import RLLVMGenOp, llvm_version, MINIMAL_VERSION
+from pypy.jit.codegen.llvm.rgenop import RLLVMGenOp
+from pypy.jit.codegen.llvm.llvmjit import llvm_version, MINIMAL_VERSION
 from pypy.jit.codegen.test.rgenop_tests import AbstractRGenOpTests
 from sys import platform
 



More information about the Pypy-commit mailing list