Commits

Sven Hager committed d174132

started refactoring of stackframes

Comments (0)

Files changed (5)

pypy/jit/backend/ppc/ppcgen/arch.py

 # Constants that depend on whether we are on 32-bit or 64-bit
 
-from pypy.jit.backend.ppc.ppcgen.register import NONVOLATILES
+from pypy.jit.backend.ppc.ppcgen.register import (NONVOLATILES,
+                                                  NONVOLATILES_FLOAT)
 
 import sys
 if sys.maxint == (2**31 - 1):
     WORD = 4
     IS_PPC_32 = True
-    BACKCHAIN_SIZE = 2 * WORD
 else:
     WORD = 8
     IS_PPC_32 = False
-    BACKCHAIN_SIZE = 4 * WORD
 
-IS_PPC_64 = not IS_PPC_32
-MY_COPY_OF_REGS = 0
+DWORD                   = 2 * WORD
+BACKCHAIN_SIZE          = 6 * WORD
+IS_PPC_64               = not IS_PPC_32
+MY_COPY_OF_REGS         = 0
 
-GPR_SAVE_AREA   = len(NONVOLATILES) * WORD
-MAX_REG_PARAMS = 8
+FORCE_INDEX             = WORD
+GPR_SAVE_AREA           = len(NONVOLATILES) * WORD
+FPR_SAVE_AREA           = len(NONVOLATILES_FLOAT) * DWORD
+FLOAT_INT_CONVERSION    = 4 * WORD
+MAX_REG_PARAMS          = 8

pypy/jit/backend/ppc/ppcgen/locations.py

 from pypy.jit.metainterp.history import INT, FLOAT, REF
-from pypy.jit.backend.arm.arch import WORD
+import sys
+
+# XXX import from arch.py, currently we have a circular import
+if sys.maxint == (2**31 - 1):
+    WORD = 4
+else:
+    WORD = 8
+DWORD = 2 * WORD
+
 class AssemblerLocation(object):
     _immutable_ = True
     type = INT
     def as_key(self):
         return self.value
 
+class FPRegisterLocation(RegisterLocation):
+    _immutable_ = True
+    type = FLOAT 
+    width = DWORD
+
+    def __repr__(self):
+        return 'fp%d' % self.value
+
+    def is_reg(self):
+        return False
+
+    def is_fp_reg(self):
+        return True
+
+    def as_key(self):
+        return self.value
+
 class ImmLocation(AssemblerLocation):
     _immutable_ = True
     width = WORD

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

 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,
-                                              GPR_SAVE_AREA, BACKCHAIN_SIZE)
+                                              GPR_SAVE_AREA, BACKCHAIN_SIZE,
+                                              FPR_SAVE_AREA,
+                                              FLOAT_INT_CONVERSION, FORCE_INDEX)
 from pypy.jit.backend.ppc.ppcgen.helper.assembler import (gen_emit_cmp_op, 
                                                           encode32, decode32,
                                                           decode64,
         self.fail_boxes_count = 0
         self.current_clt = None
         self._regalloc = None
+        self.max_stack_params = 0
 
     def _save_nonvolatiles(self):
         for i, reg in enumerate(NONVOLATILES):
         self.datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr,
                                                         allblocks)
         self.stack_in_use = False
+        self.max_stack_params = 0
 
     def setup_once(self):
         gc_ll_descr = self.cpu.gc_ll_descr
         self._regalloc = None
         assert self.datablockwrapper is None
         self.stack_in_use = False
+        self.max_stack_params = 0
 
     def _walk_operations(self, operations, regalloc):
         self._regalloc = regalloc
         return mc.materialize(self.cpu.asmmemmgr, [], 
                               self.cpu.gc_ll_descr.gcrootmap)
 
+    #def compute_frame_depth(self, regalloc):
+    #    frame_depth = (GPR_SAVE_AREA                        # GPR space
+    #                   + WORD                               # FORCE INDEX
+    #                   + regalloc.frame_manager.frame_depth * WORD)
+    #    return frame_depth
     def compute_frame_depth(self, regalloc):
-        frame_depth = (GPR_SAVE_AREA                        # GPR space
-                       + WORD                               # FORCE INDEX
-                       + regalloc.frame_manager.frame_depth * WORD)
+        frame_depth = (  GPR_SAVE_AREA
+                       + FPR_SAVE_AREA
+                       + FLOAT_INT_CONVERSION
+                       + FORCE_INDEX
+                       + regalloc.frame_manager.frame_depth * WORD
+                       + len(r.MANAGED_REGS) * WORD
+                       + self.max_stack_params * WORD
+                       + BACKCHAIN_SIZE)
+
         return frame_depth
     
     def materialize_loop(self, looptoken, show):

pypy/jit/backend/ppc/ppcgen/register.py

-from pypy.jit.backend.ppc.ppcgen.locations import RegisterLocation
+from pypy.jit.backend.ppc.ppcgen.locations import (RegisterLocation,
+                                                   FPRegisterLocation)
 
-ALL_REGS = [RegisterLocation(i) for i in range(32)]
+ALL_REGS        = [RegisterLocation(i) for i in range(32)]
+ALL_FLOAT_REGS  = [FPRegisterLocation(i) for i in range(32)]
 
 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16,\
     r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, r31\
     = ALL_REGS
 
-NONVOLATILES    = [r14, r15, r16, r17, r18, r19, r20, r21, r22, r23,
+f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16,\
+    f17, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27, f28, f29, f30, f31\
+    = ALL_FLOAT_REGS
+
+NONVOLATILES        = [r14, r15, r16, r17, r18, r19, r20, r21, r22, r23,
                     r24, r25, r26, r27, r28, r29, r30, r31]
-VOLATILES       = [r0, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13]
+VOLATILES           = [r0, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13]
+
+NONVOLATILES_FLOAT  = [f14, f15, f16, f17, f18, f19, f20, f21, f22, f23,
+                    f24, f25, f26, f27, f28, f29, f30, f31]
+
 
 SPP = r31
 SP  = r1

pypy/jit/backend/ppc/ppcgen/test/test_stackframe.py

             |                         |          |
             ---------------------------         --
             |                         |          |
-            |   FLOAT/INT CONVERSION  |          |>> ? * WORD
+            |   FLOAT/INT CONVERSION  |          |>> 4 (?) * WORD
             |                         |          |
             ---------------------------         --
             |       FORCE  INDEX      | WORD     | 1 WORD