Author: David Schneider <[email protected]>
Branch: arm-backed-float
Changeset: r44337:3c608f0bf4d6
Date: 2011-05-20 20:57 +0200
http://bitbucket.org/pypy/pypy/changeset/3c608f0bf4d6/
Log: extract counting of arguments passed in registers to a call to a
helper function
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
@@ -1,4 +1,4 @@
-from pypy.jit.backend.arm.helper.assembler import saved_registers
+from pypy.jit.backend.arm.helper.assembler import saved_registers,
count_reg_args
from pypy.jit.backend.arm import conditions as c
from pypy.jit.backend.arm import locations
from pypy.jit.backend.arm import registers as r
@@ -435,25 +435,11 @@
self.mc.VLDR(r.vfp_ip.value, r.ip.value)
self.mov_loc_loc(r.vfp_ip, loc)
- 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
-
def gen_direct_bootstrap_code(self, loop_head, looptoken, inputargs):
self.gen_func_prolog()
nonfloatlocs, floatlocs = looptoken._arm_arglocs
- reg_args = self._count_reg_args(inputargs)
+ reg_args = count_reg_args(inputargs)
stack_locs = len(inputargs) - reg_args
selected_reg = 0
diff --git a/pypy/jit/backend/arm/helper/assembler.py
b/pypy/jit/backend/arm/helper/assembler.py
--- a/pypy/jit/backend/arm/helper/assembler.py
+++ b/pypy/jit/backend/arm/helper/assembler.py
@@ -2,7 +2,7 @@
from pypy.jit.backend.arm import conditions as c
from pypy.jit.backend.arm import registers as r
from pypy.jit.backend.arm.codebuilder import AbstractARMv7Builder
-from pypy.jit.metainterp.history import ConstInt, BoxInt
+from pypy.jit.metainterp.history import ConstInt, BoxInt, FLOAT
def gen_emit_op_unary_cmp(true_cond, false_cond):
def f(self, op, arglocs, regalloc, fcond):
@@ -115,3 +115,22 @@
if reg in vfp_regs_to_save and self.regalloc.stays_alive(box):
regs.append(reg)
self.vfp_regs = regs
+def count_reg_args(args):
+ reg_args = 0
+ words = 0
+ count = 0
+ for x in range(min(len(args), 4)):
+ if args[x].type == FLOAT:
+ words += 2
+ if count % 2 != 0:
+ words += 1
+ count = 0
+ else:
+ count += 1
+ words += 1
+ reg_args += 1
+ if words > 4:
+ reg_args = x
+ break
+ return reg_args
+
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
@@ -12,7 +12,9 @@
gen_emit_cmp_op,
gen_emit_float_op,
gen_emit_float_cmp_op,
- gen_emit_unary_float_op,
saved_registers)
+ gen_emit_unary_float_op,
+ saved_registers,
+ count_reg_args)
from pypy.jit.backend.arm.codebuilder import ARMv7Builder, OverwritingBuilder
from pypy.jit.backend.arm.jump import remap_frame_layout
from pypy.jit.backend.arm.regalloc import Regalloc, TempInt, TempPtr
@@ -291,18 +293,7 @@
# XXX improve freeing of stuff here
def _emit_call(self, adr, args, regalloc, fcond=c.AL, result=None):
n_args = len(args)
- #XXX replace with _count_reg_args
- reg_args = 0
- words = 0
- for x in range(min(n_args, 4)):
- if args[x].type == FLOAT:
- words += 2
- else:
- words += 1
- reg_args += 1
- if words > 4:
- reg_args = x
- break
+ reg_args = count_reg_args(args)
#spill all vars that are stored in caller saved registers
#XXX good idea??
diff --git a/pypy/jit/backend/arm/test/test_helper.py
b/pypy/jit/backend/arm/test/test_helper.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/backend/arm/test/test_helper.py
@@ -0,0 +1,20 @@
+from pypy.jit.backend.arm.helper.assembler import count_reg_args
+from pypy.jit.metainterp.history import (BoxInt, BoxPtr, BoxFloat,
+ INT, REF, FLOAT)
+
+def test_count_reg_args():
+ assert count_reg_args([BoxPtr()]) == 1
+ assert count_reg_args([BoxPtr()] * 2) == 2
+ assert count_reg_args([BoxPtr()] * 3) == 3
+ assert count_reg_args([BoxPtr()] * 4) == 4
+ assert count_reg_args([BoxPtr()] * 5) == 4
+ assert count_reg_args([BoxFloat()] * 1) == 1
+ assert count_reg_args([BoxFloat()] * 2) == 2
+ assert count_reg_args([BoxFloat()] * 3) == 2
+
+ assert count_reg_args([BoxInt(), BoxInt(), BoxFloat()]) == 3
+ assert count_reg_args([BoxInt(), BoxFloat(), BoxInt()]) == 2
+
+ assert count_reg_args([BoxInt(), BoxFloat(), BoxInt()]) == 2
+ assert count_reg_args([BoxInt(), BoxInt(), BoxInt(), BoxFloat()]) == 3
+
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit