[pypy-svn] r67982 - in pypy/branch/floats-via-sse2/pypy/jit/backend/x86: . test

fijal at codespeak.net fijal at codespeak.net
Tue Sep 29 16:08:21 CEST 2009


Author: fijal
Date: Tue Sep 29 16:08:19 2009
New Revision: 67982

Modified:
   pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py
   pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py
Log:
Start supporting float constants. Support MODRM64 etc.


Modified: pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py	Tue Sep 29 16:08:19 2009
@@ -49,6 +49,8 @@
             print "convert_to_imm: got a %s" % c
             raise AssertionError
 
+BASE_CONSTANT_SIZE = 1000
+
 class X86XMMRegisterManager(RegisterManager):
 
     all_regs = [xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7]
@@ -56,9 +58,25 @@
     save_around_call_regs = all_regs
     reg_width = 2
 
-    def convert_to_imm(self, c):
-        xxx # what to do here...
+    def new_const_array(self):
+        return lltype.malloc(rffi.CArray(lltype.Float), BASE_CONSTANT_SIZE,
+                             flavor='raw')
+
+    def __init__(self, *args, **kwds):
+        RegisterManager.__init__(self, *args, **kwds)
+        self.constant_arrays = [self.new_const_array()]
+        self.constant_arrays_counter = 0
 
+    def convert_to_imm(self, c):
+        if self.constant_arrays_counter >= BASE_CONSTANT_SIZE:
+            self.constant_arrays.append(self.new_const_array)
+            self.constant_arrays_counter = 0
+        res = self.constant_arrays_counter
+        self.constant_arrays_counter += 1
+        arr = self.constant_arrays[-1]
+        arr[res] = c.getfloat()
+        return heap64(rffi.cast(lltype.Signed, arr) + res * WORD * 2)
+        
     def after_call(self, v):
         xxx # test
         # the result is stored in st0, but we don't have this around,

Modified: pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py
==============================================================================
--- pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py	(original)
+++ pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py	Tue Sep 29 16:08:19 2009
@@ -497,7 +497,7 @@
         assert s[1] == 'a'
 
 class TestRegallocFloats(BaseTestRegalloc):
-    def test_float_adds(self):
+    def test_float_add(self):
         ops = '''
         [f0, f1]
         f2 = float_add(f0, f1)
@@ -505,3 +505,13 @@
         '''
         self.interpret(ops, [3.0, 1.5])
         assert self.getfloats(3) == [4.5, 3.0, 1.5]
+
+    def test_float_adds_stack(self):
+        ops = '''
+        [f0, f1, f2, f3, f4, f5, f6, f7, f8]
+        f9 = float_add(f0, f1)
+        f10 = float_add(f8, 3.5)
+        fail(f9, f10, f2, f3, f4, f5, f6, f7, f8)
+        '''
+        self.interpret(ops, [0.1, .2, .3, .4, .5, .6, .7, .8, .9])
+        assert self.getfloats(9) == [.1+.2, .9+3.5, .3, .4, .5, .6, .7, .8, .9]



More information about the Pypy-commit mailing list