Commits

Sven Hager committed 8799195 Merge

merge

  • Participants
  • Parent commits 62baa02, 49d4fc7
  • Branches ppc-jit-backend

Comments (0)

Files changed (3)

File pypy/jit/backend/ppc/opassembler.py

 from pypy.jit.backend.ppc.helper.assembler import (count_reg_args,
                                                           Saved_Volatiles)
 from pypy.jit.backend.ppc.jump import remap_frame_layout
-from pypy.jit.backend.ppc.codebuilder import OverwritingBuilder
+from pypy.jit.backend.ppc.codebuilder import OverwritingBuilder, scratch_reg
 from pypy.jit.backend.ppc.regalloc import TempPtr, TempInt
 from pypy.jit.backend.llsupport import symbolic
 from pypy.rpython.lltypesystem import rstr, rffi, lltype
                     adr = self.fail_boxes_int.get_addr_for_num(i)
                 else:
                     assert 0
-                self.mc.alloc_scratch_reg()
-                self.mc.load_imm(r.SCRATCH, adr)
-                self.mc.storex(loc.value, 0, r.SCRATCH.value)
-                self.mc.free_scratch_reg()
+                with scratch_reg(self.mc):
+                    self.mc.load_imm(r.SCRATCH, adr)
+                    self.mc.storex(loc.value, 0, r.SCRATCH.value)
             elif loc.is_vfp_reg():
                 assert box.type == FLOAT
                 assert 0, "not implemented yet"
                         adr = self.fail_boxes_int.get_addr_for_num(i)
                     else:
                         assert 0
-                    self.mc.alloc_scratch_reg()
-                    self.mov_loc_loc(loc, r.SCRATCH)
-                    # store content of r5 temporary in ENCODING AREA
-                    self.mc.store(r.r5.value, r.SPP.value, 0)
-                    self.mc.load_imm(r.r5, adr)
-                    self.mc.store(r.SCRATCH.value, r.r5.value, 0)
-                    self.mc.free_scratch_reg()
+                    with scratch_reg(self.mc):
+                        self.mov_loc_loc(loc, r.SCRATCH)
+                        # store content of r5 temporary in ENCODING AREA
+                        self.mc.store(r.r5.value, r.SPP.value, 0)
+                        self.mc.load_imm(r.r5, adr)
+                        self.mc.store(r.SCRATCH.value, r.r5.value, 0)
                     # restore r5
                     self.mc.load(r.r5.value, r.SPP.value, 0)
             else:
 
     def emit_guard_call_may_force(self, op, guard_op, arglocs, regalloc):
         ENCODING_AREA = len(r.MANAGED_REGS) * WORD
-        self.mc.alloc_scratch_reg()
-        self.mc.load(r.SCRATCH.value, r.SPP.value, ENCODING_AREA)
-        self.mc.cmp_op(0, r.SCRATCH.value, 0, imm=True)
-        self.mc.free_scratch_reg()
+        with scratch_reg(self.mc):
+            self.mc.load(r.SCRATCH.value, r.SPP.value, ENCODING_AREA)
+            self.mc.cmp_op(0, r.SCRATCH.value, 0, imm=True)
         self._emit_guard(guard_op, arglocs, c.LT, save_exc=True)
 
     emit_guard_call_release_gil = emit_guard_call_may_force

File pypy/jit/backend/ppc/ppc_assembler.py

 from pypy.jit.backend.ppc.ppc_form import PPCForm as Form
 from pypy.jit.backend.ppc.ppc_field import ppc_fields
 from pypy.jit.backend.ppc.regalloc import (TempInt, PPCFrameManager,
-                                                  Regalloc)
+                                                  Regalloc, PPCRegisterManager)
 from pypy.jit.backend.ppc.assembler import Assembler
 from pypy.jit.backend.ppc.opassembler import OpAssembler
 from pypy.jit.backend.ppc.symbol_lookup import lookup
     EMPTY_LOC = '\xFE'
     END_OF_LOCS = '\xFF'
 
+    FORCE_INDEX_AREA            = len(r.MANAGED_REGS) * WORD
     ENCODING_AREA               = len(r.MANAGED_REGS) * WORD
     OFFSET_SPP_TO_GPR_SAVE_AREA = (FORCE_INDEX + FLOAT_INT_CONVERSION
                                    + ENCODING_AREA)
 
     def _build_malloc_slowpath(self):
         mc = PPCBuilder()
+        if IS_PPC_64:
+            for _ in range(6):
+                mc.write32(0)
+
         with Saved_Volatiles(mc):
             # Values to compute size stored in r3 and r4
             mc.subf(r.r3.value, r.r3.value, r.r4.value)
             addr = self.cpu.gc_ll_descr.get_malloc_slowpath_addr()
+            for reg, ofs in PPCRegisterManager.REGLOC_TO_COPY_AREA_OFS.items():
+                if IS_PPC_32:
+                    mc.stw(reg.value, r.SPP.value, ofs)
+                else:
+                    mc.std(reg.value, r.SPP.value, ofs)
             mc.call(addr)
+            for reg, ofs in PPCRegisterManager.REGLOC_TO_COPY_AREA_OFS.items():
+                if IS_PPC_32:
+                    mc.lwz(reg.value, r.SPP.value, ofs)
+                else:
+                    mc.ld(reg.value, r.SPP.value, ofs)
 
         mc.cmp_op(0, r.r3.value, 0, imm=True)
         jmp_pos = mc.currpos()
         pmc.overwrite()
         mc.b_abs(self.propagate_exception_path)
         rawstart = mc.materialize(self.cpu.asmmemmgr, [])
+        if IS_PPC_64:
+            self.write_64_bit_func_descr(rawstart, rawstart+3*WORD)
         self.malloc_slowpath = rawstart
 
     def _build_propagate_exception_path(self):
         memaddr = self.gen_descr_encoding(descr, args, arglocs)
 
         # store addr in force index field
-        self.mc.alloc_scratch_reg()
-        self.mc.load_imm(r.SCRATCH, memaddr)
-        self.mc.store(r.SCRATCH.value, r.SPP.value, self.ENCODING_AREA)
-        self.mc.free_scratch_reg()
+        with scratch_reg(self.mc):
+            self.mc.load_imm(r.SCRATCH, memaddr)
+            self.mc.store(r.SCRATCH.value, r.SPP.value, self.FORCE_INDEX_AREA)
 
         if save_exc:
             path = self._leave_jitted_hook_save_exc
             return 0
 
     def _write_fail_index(self, fail_index):
-        self.mc.alloc_scratch_reg()
-        self.mc.load_imm(r.SCRATCH, fail_index)
-        self.mc.store(r.SCRATCH.value, r.SPP.value, self.ENCODING_AREA)
-        self.mc.free_scratch_reg()
+        with scratch_reg(self.mc):
+            self.mc.load_imm(r.SCRATCH, fail_index)
+            self.mc.store(r.SCRATCH.value, r.SPP.value, self.FORCE_INDEX_AREA)
             
     def load(self, loc, value):
         assert loc.is_reg() and value.is_imm()

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

     save_around_call_regs = r.VOLATILES
 
     REGLOC_TO_COPY_AREA_OFS = {
-        r.r0:   MY_COPY_OF_REGS + 0 * WORD,
-        r.r2:   MY_COPY_OF_REGS + 1 * WORD,
-        r.r3:   MY_COPY_OF_REGS + 2 * WORD,
-        r.r4:   MY_COPY_OF_REGS + 3 * WORD,
-        r.r5:   MY_COPY_OF_REGS + 4 * WORD,
-        r.r6:   MY_COPY_OF_REGS + 5 * WORD,
-        r.r7:   MY_COPY_OF_REGS + 6 * WORD,
-        r.r8:   MY_COPY_OF_REGS + 7 * WORD,
-        r.r9:   MY_COPY_OF_REGS + 8 * WORD,
-        r.r10:  MY_COPY_OF_REGS + 9 * WORD,
-        r.r11:  MY_COPY_OF_REGS + 10 * WORD,
-        r.r12:  MY_COPY_OF_REGS + 11 * WORD,
-        r.r13:  MY_COPY_OF_REGS + 12 * WORD,
-        r.r14:  MY_COPY_OF_REGS + 13 * WORD,
-        r.r15:  MY_COPY_OF_REGS + 14 * WORD,
-        r.r16:  MY_COPY_OF_REGS + 15 * WORD,
-        r.r17:  MY_COPY_OF_REGS + 16 * WORD,
-        r.r18:  MY_COPY_OF_REGS + 17 * WORD,
-        r.r19:  MY_COPY_OF_REGS + 18 * WORD,
-        r.r20:  MY_COPY_OF_REGS + 19 * WORD,
-        r.r21:  MY_COPY_OF_REGS + 20 * WORD,
-        r.r22:  MY_COPY_OF_REGS + 21 * WORD,
-        r.r23:  MY_COPY_OF_REGS + 22 * WORD,
-        r.r24:  MY_COPY_OF_REGS + 23 * WORD,
-        r.r25:  MY_COPY_OF_REGS + 24 * WORD,
-        r.r26:  MY_COPY_OF_REGS + 25 * WORD,
-        r.r27:  MY_COPY_OF_REGS + 26 * WORD,
-        r.r28:  MY_COPY_OF_REGS + 27 * WORD,
-        r.r29:  MY_COPY_OF_REGS + 28 * WORD,
-        r.r30:  MY_COPY_OF_REGS + 29 * WORD,
-        r.r31:  MY_COPY_OF_REGS + 30 * WORD,
+        r.r3:   MY_COPY_OF_REGS + 0 * WORD,
+        r.r4:   MY_COPY_OF_REGS + 1 * WORD,
+        r.r5:   MY_COPY_OF_REGS + 2 * WORD,
+        r.r6:   MY_COPY_OF_REGS + 3 * WORD,
+        r.r7:   MY_COPY_OF_REGS + 4 * WORD,
+        r.r8:   MY_COPY_OF_REGS + 5 * WORD,
+        r.r9:   MY_COPY_OF_REGS + 6 * WORD,
+        r.r10:  MY_COPY_OF_REGS + 7 * WORD,
+        r.r11:  MY_COPY_OF_REGS + 8 * WORD,
+        r.r12:  MY_COPY_OF_REGS + 9 * WORD,
+        r.r14:  MY_COPY_OF_REGS + 10 * WORD,
+        r.r15:  MY_COPY_OF_REGS + 11 * WORD,
+        r.r16:  MY_COPY_OF_REGS + 12 * WORD,
+        r.r17:  MY_COPY_OF_REGS + 13 * WORD,
+        r.r18:  MY_COPY_OF_REGS + 14 * WORD,
+        r.r19:  MY_COPY_OF_REGS + 15 * WORD,
+        r.r20:  MY_COPY_OF_REGS + 16 * WORD,
+        r.r21:  MY_COPY_OF_REGS + 17 * WORD,
+        r.r22:  MY_COPY_OF_REGS + 18 * WORD,
+        r.r23:  MY_COPY_OF_REGS + 19 * WORD,
+        r.r24:  MY_COPY_OF_REGS + 20 * WORD,
+        r.r25:  MY_COPY_OF_REGS + 21 * WORD,
+        r.r26:  MY_COPY_OF_REGS + 22 * WORD,
+        r.r27:  MY_COPY_OF_REGS + 23 * WORD,
+        r.r28:  MY_COPY_OF_REGS + 24 * WORD,
+        r.r29:  MY_COPY_OF_REGS + 25 * WORD,
+        r.r30:  MY_COPY_OF_REGS + 26 * WORD,
     }
 
     def __init__(self, longevity, frame_manager=None, assembler=None):