Commits

Armin Rigo  committed 7ae9b2f

64-bit support.

  • Participants
  • Parent commits 793032b
  • Branches jit-simplify-backendintf

Comments (0)

Files changed (1)

File pypy/jit/backend/x86/regalloc.py

 
     def _set_initial_bindings(self, inputargs):
         if IS_X86_64:
-            return self._set_initial_bindings_64(inputargs)
+            inputargs = self._set_initial_bindings_regs_64(inputargs)
         #                   ...
         # stack layout:     arg2
         #                   arg1
         assert get_ebp_ofs(cur_frame_pos-1) == 2*WORD
         assert get_ebp_ofs(cur_frame_pos-2) == 3*WORD
         #
-        for i in range(len(inputargs)):
-            box = inputargs[i]
+        for box in inputargs:
             assert isinstance(box, Box)
             #
-            if box.type == FLOAT:
+            if IS_X86_32 and box.type == FLOAT:
                 cur_frame_pos -= 2
             else:
                 cur_frame_pos -= 1
             loc = self.fm.frame_pos(cur_frame_pos, box.type)
             self.fm.set_binding(box, loc)
 
+    def _set_initial_bindings_regs_64(self, inputargs):
+        # In reverse order for use with pop()
+        unused_gpr = [r9, r8, ecx, edx, esi, edi]
+        unused_xmm = [xmm7, xmm6, xmm5, xmm4, xmm3, xmm2, xmm1, xmm0]
+        #
+        pass_on_stack = []
+        #
+        for box in inputargs:
+            assert isinstance(box, Box)
+            #
+            if box.type == FLOAT:
+                if len(unused_xmm) > 0:
+                    ask = unused_xmm.pop()
+                    got = self.xrm.try_allocate_reg(box, selected_reg=ask)
+                    assert ask == got
+                else:
+                    pass_on_stack.append(box)
+            else:
+                if len(unused_gpr) > 0:
+                    ask = unused_gpr.pop()
+                    got = self.rm.try_allocate_reg(box, selected_reg=ask)
+                    assert ask == got
+                else:
+                    pass_on_stack.append(box)
+        #
+        return pass_on_stack
+
     def possibly_free_var(self, var):
         if var.type == FLOAT:
             self.xrm.possibly_free_var(var)