[pypy-svn] pypy arm-backed-float: continue implemeting float support in the calling convention

bivab commits-noreply at bitbucket.org
Fri Apr 1 11:03:18 CEST 2011


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backed-float
Changeset: r43072:70c086bd2476
Date: 2011-03-31 18:02 +0200
http://bitbucket.org/pypy/pypy/changeset/70c086bd2476/

Log:	continue implemeting float support in the calling convention

diff --git a/pypy/jit/backend/llsupport/regalloc.py b/pypy/jit/backend/llsupport/regalloc.py
--- a/pypy/jit/backend/llsupport/regalloc.py
+++ b/pypy/jit/backend/llsupport/regalloc.py
@@ -205,6 +205,18 @@
         self.reg_bindings[v] = loc
         return loc
 
+    def force_spill_var(self, var):
+        self._sync_var(var)
+        try:
+            loc = self.reg_bindings[var]
+            del self.reg_bindings[var]
+            self.free_regs.append(loc)
+        except KeyError:
+            if not we_are_translated():
+                import pdb; pdb.set_trace()
+            else:
+                raise ValueError
+
     def loc(self, box):
         """ Return the location of 'box'.
         """

diff --git a/pypy/jit/backend/arm/codebuilder.py b/pypy/jit/backend/arm/codebuilder.py
--- a/pypy/jit/backend/arm/codebuilder.py
+++ b/pypy/jit/backend/arm/codebuilder.py
@@ -89,6 +89,7 @@
                 | (rt & 0xF) << 12
                 | 0xB << 8
                 | (dm & 0xF))
+        self.write32(instr)
 
     # VMOV<c> <Dm>, <Rt>, <Rt2>
     def VMOV_cr(self, dm, rt, cond=cond.AL):
@@ -107,6 +108,7 @@
                 | (rt & 0xF) << 12
                 | 0xB << 8
                 | (dm & 0xF))
+        self.write32(instr)
 
     def VCVT_float_to_int(self, target, source, cond=cond.AL):
         opc2 = 0x5

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
@@ -98,7 +98,7 @@
         # One of INT, REF, FLOAT
         assert num_words == 1
         assert type == INT
-        #self.type = type
+        self.type = type
 
     def frame_size(self):
         return self.width // WORD

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
@@ -641,6 +641,7 @@
                 assert 0, 'unsupported case'
         elif loc.is_reg() and prev_loc.is_reg():
             self.mc.MOV_rr(loc.value, prev_loc.value, cond=cond)
+        #XXX these instructions do not work
         elif loc.is_reg() and prev_loc.is_vfp_reg():
             self.mc.VMOV_rc(loc.value, prev_loc.value, cond=cond)
         elif loc.is_vfp_reg() and prev_loc.is_reg():
@@ -655,6 +656,8 @@
             self.mc.PUSH([r.ip.value])
         elif loc.is_reg():
             self.mc.PUSH([loc.value])
+        elif loc.is_vfp_reg():
+            self.mc.VPUSH([loc.value])
         else:
             assert 0, 'ffuu'
 

diff --git a/pypy/jit/backend/arm/opassembler.py b/pypy/jit/backend/arm/opassembler.py
--- a/pypy/jit/backend/arm/opassembler.py
+++ b/pypy/jit/backend/arm/opassembler.py
@@ -269,16 +269,22 @@
             if reg_args > 4:
                 reg_args = x - 1
                 break
+        
+        #spill all vars that are stored in caller saved registers
+        #XXX good idea??
+        vars_to_spill = []
+        for v, reg in regalloc.rm.reg_bindings.iteritems():
+            if reg in r.caller_resp:
+                vars_to_spill.append(v)
 
-        # collect the locations of the arguments and spill those that are in
-        # the caller saved registers
+        for v in vars_to_spill:
+            regalloc.force_spill_var(v)
+        # collect the locations of the arguments that go in the argument
+        # registers
         locs = []
         for v in range(reg_args):
             var = args[v]
             loc = regalloc.loc(var)
-            if loc in r.caller_resp:
-                regalloc.force_spill(var)
-                loc = regalloc.loc(var)
             locs.append(loc)
 
         # save caller saved registers
@@ -300,9 +306,10 @@
         with saved_registers(self.mc, saved_regs, r.caller_vfp_resp, regalloc):
             # move variables to the argument registers
             num = 0
+            import pdb; pdb.set_trace()
             for i in range(reg_args):
                 arg = args[i]
-                reg = r.all_regs[num]
+                reg = r.caller_resp[num]
                 self.mov_loc_loc(locs[i], reg)
                 if arg.type == FLOAT:
                     num += 2
@@ -310,13 +317,14 @@
                     num += 1
 
             # all arguments past the 4th go on the stack
-            if n_args > 4:
-                stack_args = n_args - 4
-                n = stack_args*WORD
-                self._adjust_sp(n, fcond=fcond)
-                for i in range(4, n_args):
-                    self.mov_loc_loc(regalloc.loc(args[i]), r.ip)
-                    self.mc.STR_ri(r.ip.value, r.sp.value, (i-4)*WORD)
+            if n_args > reg_args:
+                n = 0
+                for i in range(n_args-1, reg_args-1, -1):
+                    if args[i].type == FLOAT:
+                        n += 2*WORD
+                    else:
+                        n += WORD
+                    self.regalloc_push(regalloc.loc(args[i]))
 
             #the actual call
             self.mc.BL(adr)
@@ -330,8 +338,8 @@
             if result is not None:
                 # support floats here
                 resloc = regalloc.after_call(result)
+                # XXX ugly and fragile
                 if result.type == FLOAT:
-                    # XXX ugly and fragile
                     # move result to the allocated register
                     self.mov_loc_loc(resloc, r.r0)
 

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
@@ -46,8 +46,9 @@
 
     @staticmethod
     def frame_pos(loc, type):
+        assert type == INT
         # XXX for now we only have one word stack locs
-        return locations.StackLocation(loc)
+        return locations.StackLocation(loc, type=type)
 
 def void(self, op, fcond):
     return []
@@ -228,17 +229,10 @@
 
 
     def force_spill_var(self, var):
-        self._sync_var(var)
-        try:
-            loc = self.reg_bindings[var]
-            del self.reg_bindings[var]
-            self.free_regs.append(loc)
-        except KeyError:
-            if not we_are_translated():
-                import pdb; pdb.set_trace()
-            else:
-                raise ValueError
-
+        if var.type == FLOAT:
+            self.vfprm.force_spill_var(var)
+        else:
+            self.rm.force_spill_var(var)
 
     def _ensure_value_is_boxed(self, thing, forbidden_vars=[]):
         box = None


More information about the Pypy-commit mailing list