[pypy-svn] r48385 - in pypy/dist/pypy/translator/llvm: . module test

rxe at codespeak.net rxe at codespeak.net
Thu Nov 8 01:23:23 CET 2007


Author: rxe
Date: Thu Nov  8 01:23:21 2007
New Revision: 48385

Modified:
   pypy/dist/pypy/translator/llvm/module/support.py
   pypy/dist/pypy/translator/llvm/opwriter.py
   pypy/dist/pypy/translator/llvm/structnode.py
   pypy/dist/pypy/translator/llvm/test/test_exc_operation.py
   pypy/dist/pypy/translator/llvm/test/test_typed.py
Log:
thats us pretty much passing everything as before, except for test_rint.py

Modified: pypy/dist/pypy/translator/llvm/module/support.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/module/support.py	(original)
+++ pypy/dist/pypy/translator/llvm/module/support.py	Thu Nov  8 01:23:21 2007
@@ -38,30 +38,28 @@
     ret double %result
 }
 
-"""
-"""
-internal CC WORD %pypyop_int_abs(WORD %x) {
+define internal CC i32 @pypyop_int_abs(i32 %x) {
 block0:
-    %cond1 = setge WORD %x, 0
-    br bool %cond1, label %return_block, label %block1
+    %cond1 = icmp sge i32 %x, 0
+    br i1 %cond1, label %return_block, label %block1
 block1:
-    %x2 = sub WORD 0, %x
+    %x2 = sub i32 0, %x
     br label %return_block
 return_block:
-    %result = phi WORD [%x, %block0], [%x2, %block1]
-    ret WORD %result
+    %result = phi i32 [%x, %block0], [%x2, %block1]
+    ret i32 %result
 }
 
-internal CC long %pypyop_llong_abs(long %x) {
+define internal CC i64 @pypyop_llong_abs(i64 %x) {
 block0:
-    %cond1 = setge long %x, 0
-    br bool %cond1, label %return_block, label %block1
+    %cond1 = icmp sge i64 %x, 0
+    br i1 %cond1, label %return_block, label %block1
 block1:
-    %x2 = sub long 0, %x
+    %x2 = sub i64 0, %x
     br label %return_block
 return_block:
-    %result = phi long [%x, %block0], [%x2, %block1]
-    ret long %result
+    %result = phi i64 [%x, %block0], [%x2, %block1]
+    ret i64 %result
 }
 
 """

Modified: pypy/dist/pypy/translator/llvm/opwriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/opwriter.py	(original)
+++ pypy/dist/pypy/translator/llvm/opwriter.py	Thu Nov  8 01:23:21 2007
@@ -88,7 +88,7 @@
 
     for tt in 'float'.split():
         for oo in 'lt le eq ne ge gt'.split():
-            binary_operations['%s_%s' % (tt, oo)] = 'fcmp u%s' % oo
+            binary_operations['%s_%s' % (tt, oo)] = 'fcmp o%s' % oo
 
     # ZZZ check that operation should be checking unsigned
     binary_operations.update({'char_lt': 'icmp ult',
@@ -234,14 +234,18 @@
                 else:
                     pass
             else:
-                if (fromtype[0] == 'i' and totype == 'double'):
+                if (fromtype[0] == 'i' and totype in ['double', 'float']):
                     # ZZZ signed
                     casttype = "sitofp"
-                elif (fromtype == 'double' and totype[0] == 'i'):
+                elif (fromtype in ['double', 'float'] and totype[0] == 'i'):
                     # ZZZ signed
                     casttype = "fptosi"
                 else:
-                    assert False, "this shouldtnt be possible"
+                    if fromtype != totype:
+                        if fromtype == "double":
+                            casttype = 'fptrunc'
+                        else:
+                            casttype = 'fpext'
         else:
             assert '*' in totype
 
@@ -553,8 +557,7 @@
 
     def is_early_constant(self, opr):
         # If it gets this far it is always false
-        self.codewriter.cast(opr.retref, 'bool',
-                             'false', opr.rettype)
+        self.codewriter.cast(opr.retref, 'i1', 'false', opr.rettype)
 
     def debug_llinterpcall(self, opr):
         self.codewriter.call(None, "void", "@abort", [], [])

Modified: pypy/dist/pypy/translator/llvm/structnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/structnode.py	(original)
+++ pypy/dist/pypy/translator/llvm/structnode.py	Thu Nov  8 01:23:21 2007
@@ -94,7 +94,7 @@
                 
                 
 class FixedSizeArrayNode(StructNode):
-    prefix = '%fixarrayinstance_'
+    prefix = '@fixarrayinstance_'
 
     def __init__(self, db, struct): 
         super(FixedSizeArrayNode, self).__init__(db, struct)

Modified: pypy/dist/pypy/translator/llvm/test/test_exc_operation.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_exc_operation.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_exc_operation.py	Thu Nov  8 01:23:21 2007
@@ -72,8 +72,6 @@
     for i in (-sys.maxint-1, -sys.maxint, 0, sys.maxint-1, sys.maxint):
         assert f(i) == abs_int_ovf(i)
 
-############################
-
 def test_int_overflow():
     def fn(i):
         try:
@@ -98,9 +96,7 @@
     assert fn(0) == 1234
 
 def test_int_mod_ovf_zer():
-    #without raisingop2direct_call the operation is not found
-    #with    raisingop2direct_call the wrong result is returned
-    py.test.skip("operation int_mod_ovf_zer not found")
+    py.test.skip("XXX fix this : the wrong result is returned")
     def fn(i):
         try:
             return snippet.mod_func(i)
@@ -139,7 +135,6 @@
     assert f(1) == 1234
 
 def test_uint_arith():
-    py.test.skip("zer operator exception not implemented")
     def fn(i):
         try:
             return ~(i*(i+1))/(i-1)
@@ -174,8 +169,8 @@
     assert f(-sys.maxint) == 123
 
 def test_int_mul_ovf():
-    if sys.maxint != 2**31-1:
-        py.test.skip("WIP on 64 bit architectures")
+    #if sys.maxint != 2**31-1:
+    #    py.test.skip("WIP on 64 bit architectures")
     def mul_func(i):
         try:
             return ovfcheck(i * 100)

Modified: pypy/dist/pypy/translator/llvm/test/test_typed.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_typed.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_typed.py	Thu Nov  8 01:23:21 2007
@@ -3,7 +3,7 @@
 import py
 from py.test import raises
 from pypy.translator.test import snippet 
-from pypy.rlib.rarithmetic import r_uint, ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import r_uint, r_longlong, ovfcheck, ovfcheck_lshift
 
 from pypy.translator.llvm.test.runtest import *
 
@@ -288,11 +288,18 @@
         assert str(f(i)) == str(fn(i))
 
 def test_int_abs():
-    def int_abs_(n):
+    def int_abs(n):
         return abs(n)
-    f = compile_function(int_abs_, [int])
+    f = compile_function(int_abs, [int])
     for i in (-25, 0, 75):
-        assert f(i) == int_abs_(i)
+        assert f(i) == int_abs(i)
+
+def test_long_abs():
+    def long_abs(n):
+        return abs(r_longlong(n))
+    f = compile_function(long_abs, [int])
+    for i in (-25, 0, 75):
+        assert f(i) == long_abs(i)
 
 def test_float_abs():
     def float_abs_(n):



More information about the Pypy-commit mailing list