Armin Rigo avatar Armin Rigo committed ac8ce2a

Finish this small refactoring. Now we no longer have pairs of calls to
remap_frame_layout().

Comments (0)

Files changed (4)

pypy/jit/backend/x86/assembler.py

                 else:
                     get_from_stack.append((floc, True))
 
-        remap_frame_layout(self, src_locs, dst_locs, X86_64_SCRATCH_REG)
-        remap_frame_layout(self, xmm_src_locs, xmm_dst_locs, X86_64_XMM_SCRATCH_REG)
+        remap_frame_layout(self,
+                           src_locs + xmm_src_locs,
+                           dst_locs + xmm_dst_locs,
+                           X86_64_SCRATCH_REG, X86_64_XMM_SCRATCH_REG)
 
         for i in range(len(get_from_stack)):
             loc, is_xmm = get_from_stack[i]
                     self.mc.MOV_sr(i*WORD, loc.value)
 
         # Handle register arguments
-        remap_frame_layout(self, src_locs, dst_locs, X86_64_SCRATCH_REG)
-        remap_frame_layout(self, xmm_src_locs, xmm_dst_locs, X86_64_XMM_SCRATCH_REG)
+        remap_frame_layout(self,
+                           src_locs + xmm_src_locs,
+                           dst_locs + xmm_dst_locs,
+                           X86_64_SCRATCH_REG, X86_64_XMM_SCRATCH_REG)
 
         self._regalloc.reserve_param(len(pass_on_stack))
         self.mc.CALL(x)
             # arglocs[2:] too, so they are saved on the stack above and
             # restored below.
             remap_frame_layout(self, arglocs[:2], [edi, esi],
-                               X86_64_SCRATCH_REG)
+                               X86_64_SCRATCH_REG, X86_64_XMM_SCRATCH_REG)
 
         # misaligned stack in the call, but it's ok because the write barrier
         # is not going to call anything more.  Also, this assumes that the

pypy/jit/backend/x86/jump.py

 
 class ConcreteJumpRemapper(JumpRemapper):
 
-    def get_tmp_reg(self, src):
-        """Get a temporary register suitable for copying src."""
+    def get_tmp_reg(self, dst):
+        """Get a temporary register suitable for copying into dst."""
         raise NotImplementedError
 
     def move(self, src, dst):
         if dst.is_memory_reference() and src.is_memory_reference():
-            tmpreg = self.get_tmp_reg(src)
+            tmpreg = self.get_tmp_reg(dst)
             self.simple_move(src, tmpreg)
             src = tmpreg
         self.simple_move(src, dst)
 
     def simple_move(self, src, dst):
         raise NotImplementedError
+
+
+class X86JumpRemapper(ConcreteJumpRemapper):
+    def __init__(self, assembler, tmp, xmmtmp):
+        self.assembler = assembler
+        self.tmpreg = tmp
+        self.xmmtmpreg = xmmtmp
+
+    def get_tmp_reg(self, dst):
+        if dst.is_xmm_location():
+            return self.xmmtmpreg
+        else:
+            return self.tmpreg
+
+    def simple_move(self, src, dst):
+        self.assembler.regalloc_mov(src, dst)
+
+    def push(self, src):
+        self.assembler.regalloc_push(src)
+
+    def pop(self, dst):
+        self.assembler.regalloc_pop(dst)
+
+def remap_frame_layout(assembler, src_locations, dst_locations, tmp, xmmtmp):
+    # X86-specific logic
+    remapper = X86JumpRemapper(assembler, tmp, xmmtmp)
+    remapper.remap_frame_layout(src_locations, dst_locations)

pypy/jit/backend/x86/regalloc.py

 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib import rgc
 from pypy.jit.backend.llsupport import symbolic
-#from pypy.jit.backend.x86.jump import remap_frame_layout
+from pypy.jit.backend.x86.jump import remap_frame_layout
 from pypy.jit.codewriter import heaptracker, longlong
 from pypy.jit.codewriter.effectinfo import EffectInfo
 from pypy.jit.metainterp.resoperation import rop
         xmmtmploc = self.xrm.force_allocate_reg(box1, selected_reg=xmmtmp)
         # Part about non-floats
         # XXX we don't need a copy, we only just the original list
-        src_locations = [self.loc(op.getarg(i)) for i in range(op.numargs()) 
+        src_locations1 = [self.loc(op.getarg(i)) for i in range(op.numargs()) 
                          if op.getarg(i).type != FLOAT]
         assert tmploc not in nonfloatlocs
-        dst_locations = [loc for loc in nonfloatlocs if loc is not None]
-        remap_frame_layout(assembler, src_locations, dst_locations, tmploc)
+        dst_locations1 = [loc for loc in nonfloatlocs if loc is not None]
         # Part about floats
-        src_locations = [self.loc(op.getarg(i)) for i in range(op.numargs()) 
+        src_locations2 = [self.loc(op.getarg(i)) for i in range(op.numargs()) 
                          if op.getarg(i).type == FLOAT]
-        dst_locations = [loc for loc in floatlocs if loc is not None]
-        remap_frame_layout(assembler, src_locations, dst_locations, xmmtmp)
+        dst_locations2 = [loc for loc in floatlocs if loc is not None]
+        # Do the remapping
+        remap_frame_layout(assembler,
+                           src_locations1 + src_locations2,
+                           dst_locations1 + dst_locations2,
+                           tmploc, xmmtmp)
         self.rm.possibly_free_var(box)
         self.xrm.possibly_free_var(box1)
         self.possibly_free_vars_for_op(op)

pypy/jit/backend/x86/regloc.py

 
     def find_unused_reg(self): return eax
 
+    def is_xmm_location(self): raise NotImplementedError
+
 class StackLoc(AssemblerLocation):
     _immutable_ = True
     def __init__(self, position, ebp_offset, num_words, type):
         # One of INT, REF, FLOAT
         self.type = type
 
+    def is_xmm_location(self):
+        return self.type == FLOAT
+
     def frame_size(self):
         return self.width // WORD
 
             self.width = 8
         else:
             self.width = WORD
+
     def __repr__(self):
         if self.is_xmm:
             return rx86.R.xmmnames[self.value]
         else:
             return rx86.R.names[self.value]
 
+    def is_xmm_location(self):
+        return self.is_xmm
+
     def lowest8bits(self):
         assert not self.is_xmm
         return RegLoc(rx86.low_byte(self.value), False)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.