Commits

David Schneider committed 9a2e9cc

start adding support for floats to call_assembler

Comments (0)

Files changed (3)

pypy/jit/backend/arm/assembler.py

         return arglocs
 
     def gen_direct_bootstrap_code(self, arglocs, loop_head, looptoken):
-        #XXX fixme later, when float calling conv works
-        return
         self.gen_func_prolog()
-        if len(arglocs) > 4:
-            reg_args = 4
-        else:
-            reg_args = len(arglocs)
+        #import pdb; pdb.set_trace()
+        reg_args = self._count_reg_args(arglocs)
 
         stack_locs = len(arglocs) - reg_args
 
+        selected_reg = 0
         for i in range(reg_args):
             loc = arglocs[i]
-            self.mov_loc_loc(r.all_regs[i], loc)
+            self.mov_loc_loc(r.all_regs[selected_reg], loc)
+            if arglocs[i].type == FLOAT:
+                selected_reg += 2
+            else:
+                selected_reg += 1
 
         for i in range(stack_locs):
             loc = arglocs[reg_args + i]

pypy/jit/backend/arm/locations.py

-from pypy.jit.metainterp.history import INT
+from pypy.jit.metainterp.history import INT, FLOAT
 from pypy.jit.backend.arm.arch import WORD
 class AssemblerLocation(object):
     _immutable_ = True
+    type = INT
 
     def is_imm(self):
         return False
 
 class VFPRegisterLocation(RegisterLocation):
     _immutable_ = True
+    type = FLOAT 
 
     def get_single_precision_regs(self):
         return [VFPRegisterLocation(i) for i in [self.value*2, self.value*2+1]]
     """This class represents an imm float value which is stored in memory at
     the address stored in the field value"""
     _immutable_ = True
+    type = FLOAT
 
     def __init__(self, value):
         self.value = value

pypy/jit/backend/arm/opassembler.py

             self._ensure_result_bit_extension(loc, size, signed)
         return cond
 
+    def _count_reg_args(self, args):
+        reg_args = 0
+        words = 0
+        for x in range(min(len(args), 4)):
+            if args[x].type == FLOAT:
+                words += 2
+            else:
+                words += 1
+            reg_args += 1
+            if words > 4:
+                reg_args = x
+                break
+        return reg_args
     # XXX improve this interface
     # emit_op_call_may_force
     # XXX improve freeing of stuff here
 
             # restore the argumets stored on the stack
             if result is not None:
-                # support floats here
                 resloc = regalloc.after_call(result)
                 # XXX ugly and fragile
                 if result.type == FLOAT:
             # resbox is allready in r0
             self.mov_loc_loc(arglocs[1], r.r1)
             self.mc.BL(asm_helper_adr)
-        if op.result:
-            regalloc.after_call(op.result)
+            if op.result:
+                resloc = regalloc.after_call(op.result)
+                # XXX ugly and fragile
+                if op.result.type == FLOAT:
+                    # move result to the allocated register
+                    self.mov_loc_loc(r.r0, resloc)
+
         # jump to merge point
         jmp_pos = self.mc.currpos()
         #jmp_location = self.mc.curraddr()
             fielddescr = jd.vable_token_descr
             assert isinstance(fielddescr, BaseFieldDescr)
             ofs = fielddescr.offset
+            import pdb; pdb.set_trace()
             resloc = regalloc.force_allocate_reg(resbox)
             self.mov_loc_loc(arglocs[1], r.ip)
             self.mc.MOV_ri(resloc.value, 0)
                 adr = self.fail_boxes_int.get_addr_for_num(0)
             elif kind == REF:
                 adr = self.fail_boxes_ptr.get_addr_for_num(0)
+            elif kind == FLOAT:
+                adr = self.fail_boxes_float.get_addr_for_num(0)
             else:
                 raise AssertionError(kind)
             resloc = regalloc.force_allocate_reg(op.result)
             regalloc.possibly_free_var(resbox)
             self.mc.gen_load_int(r.ip.value, adr)
-            self.mc.LDR_ri(resloc.value, r.ip.value)
+            if op.result.type == FLOAT:
+                self.mc.VLDR(resloc.value, r.ip.value)
+            else:
+                self.mc.LDR_ri(resloc.value, r.ip.value)
 
         # merge point
         offset = self.mc.currpos() - jmp_pos