[pypy-commit] pypy ppc-jit-backend: begin reimplementation of CALL on PPC64

hager noreply at buildbot.pypy.org
Thu Dec 8 16:02:59 CET 2011


Author: hager <sven.hager at uni-duesseldorf.de>
Branch: ppc-jit-backend
Changeset: r50305:103beedd8034
Date: 2011-12-08 07:02 -0800
http://bitbucket.org/pypy/pypy/changeset/103beedd8034/

Log:	begin reimplementation of CALL on PPC64

diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -456,7 +456,12 @@
         if IS_PPC_32:
             self.mc.bl_abs(adr)
         else:
-            assert 0
+            self.mc.load_from_addr(r.r0, adr)
+            self.mc.load_from_addr(r.r2, adr + WORD)
+            self.mc.load_from_addr(r.r11, adr + 2 * WORD)
+            self.mc.mtctr(r.r0.value)
+            self.mc.bctrl()
+            
 
         self.mark_gc_roots(force_index)
         regalloc.possibly_free_vars(args)
diff --git a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/ppc_assembler.py
@@ -10,7 +10,7 @@
 from pypy.jit.backend.ppc.ppcgen.codebuilder import PPCBuilder
 from pypy.jit.backend.ppc.ppcgen.jump import remap_frame_layout
 from pypy.jit.backend.ppc.ppcgen.arch import (IS_PPC_32, IS_PPC_64, WORD,
-                                              NONVOLATILES,
+                                              NONVOLATILES, MAX_REG_PARAMS,
                                               GPR_SAVE_AREA, BACKCHAIN_SIZE,
                                               FPR_SAVE_AREA,
                                               FLOAT_INT_CONVERSION, FORCE_INDEX)
@@ -80,40 +80,6 @@
     EMPTY_LOC = '\xFE'
     END_OF_LOCS = '\xFF'
 
-
-    '''
-    PyPy's PPC stack frame layout
-    =============================
-
-    .                          .
-    .                          . 
-    ----------------------------
-    |         BACKCHAIN        |       OLD  FRAME
-    ------------------------------------------------------
-    |                          |       PyPy Frame
-    |      GPR  SAVE  AREA     |
-    |                          |
-    ----------------------------
-    |       FORCE  INDEX       |
-    ----------------------------  <- Spilling Pointer (SPP) 
-    |                          |
-    |       SPILLING  AREA     |
-    |                          |
-    ----------------------------  <- Stack Pointer (SP)
-
-    The size of the GPR save area and the force index area fixed:
-
-        GPR SAVE AREA: len(NONVOLATILES) * WORD
-        FORCE INDEX  : WORD
-
-
-    The size of the spilling area is known when the trace operations
-    have been generated.
-    '''
-
-    #GPR_SAVE_AREA_AND_FORCE_INDEX = GPR_SAVE_AREA + WORD
-                                  # ^^^^^^^^^^^^^   ^^^^
-                                  # save GRP regs   force index
     ENCODING_AREA               = len(r.MANAGED_REGS) * WORD
     OFFSET_SPP_TO_GPR_SAVE_AREA = (FORCE_INDEX + FLOAT_INT_CONVERSION
                                    + ENCODING_AREA)
@@ -229,6 +195,7 @@
             stack_loc   : pointer to top of the stack
             spp_loc     : pointer to begin of the spilling area
             '''
+
         enc = rffi.cast(rffi.CCHARP, mem_loc)
         managed_size = WORD * len(r.MANAGED_REGS)
         # XXX do some sanity considerations
@@ -346,6 +313,7 @@
     #   - jump back to the calling code
     def _gen_exit_path(self):
         mc = PPCBuilder() 
+        mc.mr(r.r6.value, r.r3.value)
         self._save_managed_regs(mc)
         decode_func_addr = llhelper(self.recovery_func_sign,
                 self.failure_recovery_func)
@@ -358,6 +326,8 @@
             r2_value = descr[1]
             r11_value = descr[2]
 
+
+
         # load parameters into parameter registers
         if IS_PPC_32:
             mc.lwz(r.r3.value, r.SPP.value, self.ENCODING_AREA)     # address of state encoding 
@@ -369,6 +339,7 @@
         # load address of decoding function into r0
         mc.alloc_scratch_reg(addr)
         if IS_PPC_64:
+            mc.li(r.r2.value, 99)
             mc.std(r.r2.value, r.SP.value, 3 * WORD)
             # load TOC pointer and environment pointer
             mc.load_imm(r.r2, r2_value)
@@ -749,13 +720,22 @@
                               self.cpu.gc_ll_descr.gcrootmap)
 
     def compute_frame_depth(self, regalloc):
+        PARAMETER_AREA = self.max_stack_params * WORD
+        if IS_PPC_64:
+            PARAMETER_AREA += MAX_REG_PARAMS * WORD
+        SPILLING_AREA = regalloc.frame_manager.frame_depth * WORD
+
+        print "PARAMETER SAVE AREA = %d" % PARAMETER_AREA
+        print "SPILLING AREA       = %d" % SPILLING_AREA
+        print "OFFSET TO ENCODING  = %d" % (PARAMETER_AREA + SPILLING_AREA)
+
         frame_depth = (  GPR_SAVE_AREA
                        + FPR_SAVE_AREA
                        + FLOAT_INT_CONVERSION
                        + FORCE_INDEX
                        + self.ENCODING_AREA
-                       + regalloc.frame_manager.frame_depth * WORD
-                       + self.max_stack_params * WORD
+                       + SPILLING_AREA
+                       + PARAMETER_AREA
                        + BACKCHAIN_SIZE * WORD)
 
         return frame_depth


More information about the pypy-commit mailing list