[pypy-svn] r76504 - pypy/trunk/pypy/jit/backend/x86

arigo at codespeak.net arigo at codespeak.net
Fri Aug 6 12:55:00 CEST 2010


Author: arigo
Date: Fri Aug  6 12:54:59 2010
New Revision: 76504

Modified:
   pypy/trunk/pypy/jit/backend/x86/assembler.py
   pypy/trunk/pypy/jit/backend/x86/regalloc.py
   pypy/trunk/pypy/jit/backend/x86/regloc.py
Log:
Cancel r76493.  The fix works; test_ztranslation failed for
other reasons already before (and is fixed now).


Modified: pypy/trunk/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/assembler.py	Fri Aug  6 12:54:59 2010
@@ -818,10 +818,8 @@
 
         for i in range(start, len(arglocs)):
             loc = arglocs[i]
-            assert isinstance(loc, RegLoc) or isinstance(loc, ImmedLoc) or isinstance(loc, StackLoc)
-
             # XXX: Should be much simplier to tell whether a location is a float!
-            if (isinstance(loc, RegLoc) and loc.is_xmm) or (isinstance(loc, StackLoc) and loc.type == FLOAT):
+            if (isinstance(loc, RegLoc) and loc.is_xmm) or (loc.is_memory_reference() and loc.type == FLOAT):
                 if len(unused_xmm) > 0:
                     xmm_src_locs.append(loc)
                     xmm_dst_locs.append(unused_xmm.pop())

Modified: pypy/trunk/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/regalloc.py	Fri Aug  6 12:54:59 2010
@@ -53,6 +53,7 @@
 
     def __init__(self):
         self.cur_array_free = 0
+        self.const_id = 0
 
     def _get_new_array(self):
         n = self.BASE_CONSTANT_SIZE
@@ -68,7 +69,8 @@
         n = self.cur_array_free - 1
         arr[n] = floatval
         self.cur_array_free = n
-        return rffi.cast(lltype.Signed, arr) + n * 8
+        self.const_id += 1
+        return (self.const_id, rffi.cast(lltype.Signed, arr) + n * 8)
 
 
 class X86XMMRegisterManager(RegisterManager):
@@ -89,8 +91,8 @@
             self.float_constants = assembler._float_constants
 
     def convert_to_imm(self, c):
-        adr = self.float_constants.record_float(c.getfloat())
-        return AddressLoc(ImmedLoc(adr), ImmedLoc(0), 0, 0)
+        const_id, adr = self.float_constants.record_float(c.getfloat())
+        return ConstFloatLoc(adr, const_id)
         
     def after_call(self, v):
         # the result is stored in st0, but we don't have this around,

Modified: pypy/trunk/pypy/jit/backend/x86/regloc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/regloc.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/regloc.py	Fri Aug  6 12:54:59 2010
@@ -5,6 +5,7 @@
 from pypy.tool.sourcetools import func_with_new_name
 from pypy.rlib.objectmodel import specialize
 from pypy.rlib.rarithmetic import intmask
+from pypy.jit.metainterp.history import FLOAT
 
 #
 # This module adds support for "locations", which can be either in a Const,
@@ -145,6 +146,28 @@
     def value_m(self):
         return self.loc_m
 
+class ConstFloatLoc(AssemblerLocation):
+    # XXX: We have to use this class instead of just AddressLoc because
+    # AddressLoc is "untyped" and also we to have need some sort of unique
+    # identifier that we can use in _getregkey (for jump.py)
+
+    _immutable_ = True
+
+    width = 8
+    type = FLOAT
+
+    def __init__(self, address, const_id):
+        self.value = address
+        self.const_id = const_id
+
+    def _getregkey(self):
+        # XXX: 1000 is kind of magic: We just don't want to be confused
+        # with any registers
+        return 1000 + self.const_id
+
+    def location_code(self):
+        return 'j'
+
 REGLOCS = [RegLoc(i, is_xmm=False) for i in range(16)]
 XMMREGLOCS = [RegLoc(i, is_xmm=True) for i in range(16)]
 eax, ecx, edx, ebx, esp, ebp, esi, edi, r8, r9, r10, r11, r12, r13, r14, r15 = REGLOCS



More information about the Pypy-commit mailing list