[pypy-commit] pypy arm-backend-2: modify stack_locations store position and the offset to the FP. Get rid of the special case for the first slot in the spilling area currently used for the FORCE_TOKEN

bivab noreply at buildbot.pypy.org
Mon Jan 9 11:56:50 CET 2012


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backend-2
Changeset: r51166:5e9aadf0b867
Date: 2012-01-04 15:57 +0100
http://bitbucket.org/pypy/pypy/changeset/5e9aadf0b867/

Log:	modify stack_locations store position and the offset to the FP. Get
	rid of the special case for the first slot in the spilling area
	currently used for the FORCE_TOKEN

diff --git a/pypy/jit/backend/arm/assembler.py b/pypy/jit/backend/arm/assembler.py
--- a/pypy/jit/backend/arm/assembler.py
+++ b/pypy/jit/backend/arm/assembler.py
@@ -680,9 +680,7 @@
                                 OverwritingBuilder.size_of_gen_load_int + WORD)
         # Note: the frame_depth is one less than the value stored in the frame
         # manager
-        if frame_depth == 1:
-            return
-        n = (frame_depth - 1) * WORD
+        n = frame_depth * WORD
 
         # ensure the sp is 8 byte aligned when patching it
         if n % 8 != 0:
@@ -840,7 +838,7 @@
                 temp = r.lr
             else:
                 temp = r.ip
-            offset = loc.position * WORD
+            offset = loc.value
             if not check_imm_arg(offset, size=0xFFF):
                 self.mc.PUSH([temp.value], cond=cond)
                 self.mc.gen_load_int(temp.value, -offset, cond=cond)
@@ -861,7 +859,7 @@
             assert loc is not r.lr, 'lr is not supported as a target \
                 when moving from the stack'
             # unspill a core register
-            offset = prev_loc.position * WORD
+            offset = prev_loc.value
             if not check_imm_arg(offset, size=0xFFF):
                 self.mc.PUSH([r.lr.value], cond=cond)
                 pushed = True
@@ -875,7 +873,7 @@
             assert prev_loc.type == FLOAT, 'trying to load from an \
                 incompatible location into a float register'
             # load spilled value into vfp reg
-            offset = prev_loc.position * WORD
+            offset = prev_loc.value
             self.mc.PUSH([r.ip.value], cond=cond)
             pushed = True
             if not check_imm_arg(offset):
@@ -905,7 +903,7 @@
                 incompatible location from a float register'
             # spill vfp register
             self.mc.PUSH([r.ip.value], cond=cond)
-            offset = loc.position * WORD
+            offset = loc.value
             if not check_imm_arg(offset):
                 self.mc.gen_load_int(r.ip.value, offset, cond=cond)
                 self.mc.SUB_rr(r.ip.value, r.fp.value, r.ip.value, cond=cond)
@@ -948,7 +946,7 @@
             self.mc.POP([r.ip.value], cond=cond)
         elif vfp_loc.is_stack() and vfp_loc.type == FLOAT:
             # load spilled vfp value into two core registers
-            offset = vfp_loc.position * WORD
+            offset = vfp_loc.value
             if not check_imm_arg(offset, size=0xFFF):
                 self.mc.PUSH([r.ip.value], cond=cond)
                 self.mc.gen_load_int(r.ip.value, -offset, cond=cond)
@@ -971,7 +969,7 @@
             self.mc.VMOV_cr(vfp_loc.value, reg1.value, reg2.value, cond=cond)
         elif vfp_loc.is_stack():
             # move from two core registers to a float stack location
-            offset = vfp_loc.position * WORD
+            offset = vfp_loc.value
             if not check_imm_arg(offset, size=0xFFF):
                 self.mc.PUSH([r.ip.value], cond=cond)
                 self.mc.gen_load_int(r.ip.value, -offset, cond=cond)
diff --git a/pypy/jit/backend/arm/locations.py b/pypy/jit/backend/arm/locations.py
--- a/pypy/jit/backend/arm/locations.py
+++ b/pypy/jit/backend/arm/locations.py
@@ -1,5 +1,5 @@
 from pypy.jit.metainterp.history import INT, FLOAT
-from pypy.jit.backend.arm.arch import WORD
+from pypy.jit.backend.arm.arch import WORD, DOUBLE_WORD
 
 
 class AssemblerLocation(object):
@@ -110,9 +110,13 @@
 class StackLocation(AssemblerLocation):
     _immutable_ = True
 
-    def __init__(self, position, num_words=1, type=INT):
+    def __init__(self, position, fp_offset, type=INT):
+        if type == FLOAT:
+            self.width = DOUBLE_WORD
+        else:
+            self.width = WORD
         self.position = position
-        self.width = num_words * WORD
+        self.value = fp_offset
         self.type = type
 
     def __repr__(self):
diff --git a/pypy/jit/backend/arm/regalloc.py b/pypy/jit/backend/arm/regalloc.py
--- a/pypy/jit/backend/arm/regalloc.py
+++ b/pypy/jit/backend/arm/regalloc.py
@@ -54,26 +54,28 @@
         return "<TempFloat at %s>" % (id(self),)
 
 
+def get_fp_offset(i):
+    if i >= 0:
+        # Take the FORCE_TOKEN into account
+        return (1 + i) * WORD
+    else:
+        return i * WORD
+
+
 class ARMFrameManager(FrameManager):
 
     def __init__(self):
         FrameManager.__init__(self)
-        self.used = [True]  # keep first slot free
+        #self.used = [True]  # keep first slot free
         # XXX refactor frame to avoid this issue of keeping the first slot
         # reserved
 
     @staticmethod
-    def frame_pos(loc, type):
-        num_words = ARMFrameManager.frame_size(type)
-        if type == FLOAT:
-            if loc > 0:
-                # Make sure that loc is an even value
-                # the frame layout requires loc to be even if it is a spilled
-                # value!!
-                assert (loc & 1) == 0
-            return locations.StackLocation(loc + 1,
-                            num_words=num_words, type=type)
-        return locations.StackLocation(loc, num_words=num_words, type=type)
+    def frame_pos(i, box_type):
+        if box_type == FLOAT:
+            return locations.StackLocation(i, get_fp_offset(i + 1), box_type)
+        else:
+            return locations.StackLocation(i, get_fp_offset(i), box_type)
 
     @staticmethod
     def frame_size(type):
@@ -84,10 +86,7 @@
     @staticmethod
     def get_loc_index(loc):
         assert loc.is_stack()
-        if loc.type == FLOAT:
-            return loc.position - 1
-        else:
-            return loc.position
+        return loc.position
 
 
 def void(self, op, fcond):
@@ -721,7 +720,6 @@
             else:
                 src_locations2.append(src_loc)
                 dst_locations2.append(dst_loc)
-
         remap_frame_layout_mixed(self.assembler,
                                  src_locations1, dst_locations1, tmploc,
                                  src_locations2, dst_locations2, vfptmploc)
@@ -960,6 +958,7 @@
             if (isinstance(v, BoxPtr) and self.rm.stays_alive(v)):
                 assert val.is_stack()
                 gcrootmap.add_frame_offset(shape, val.position * -WORD)
+                gcrootmap.add_frame_offset(shape, -val.value)
         for v, reg in self.rm.reg_bindings.items():
             if reg is r.r0:
                 continue


More information about the pypy-commit mailing list