[pypy-commit] pypy arm-backed-float: fix the alignment of values passed in registers to a call
bivab
noreply at buildbot.pypy.org
Fri May 20 21:10:45 CEST 2011
Author: David Schneider <david.schneider at picle.org>
Branch: arm-backed-float
Changeset: r44338:0e3fd1494d16
Date: 2011-05-20 20:58 +0200
http://bitbucket.org/pypy/pypy/changeset/0e3fd1494d16/
Log: fix the alignment of values passed in registers to a call
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
@@ -353,14 +353,18 @@
self.regalloc_push(regalloc.loc(arg))
# move variables to the argument registers
num = 0
+ count = 0
for i in range(reg_args):
arg = args[i]
+ if arg.type == FLOAT and count % 2 != 0:
+ num += 1
reg = r.caller_resp[num]
self.mov_loc_loc(locs[i], reg)
if arg.type == FLOAT:
num += 2
else:
num += 1
+ count += 1
regalloc.before_call(save_all_regs=2)
#the actual call
diff --git a/pypy/jit/backend/arm/test/test_calling_convention.py b/pypy/jit/backend/arm/test/test_calling_convention.py
--- a/pypy/jit/backend/arm/test/test_calling_convention.py
+++ b/pypy/jit/backend/arm/test/test_calling_convention.py
@@ -80,3 +80,38 @@
'float', descr=calldescr)
assert abs(res.getfloat() - result) < 0.0001
+ def test_call_alignment_register_args(self):
+ from pypy.rlib.libffi import types
+ cpu = self.cpu
+ if not cpu.supports_floats:
+ py.test.skip('requires floats')
+
+
+ def func(*args):
+ return sum(args)
+
+ F = lltype.Float
+ I = lltype.Signed
+ floats = [0.7, 5.8]
+ ints = [7, 11]
+ result = sum(floats + ints)
+ for args in itertools.permutations([I, I, F, F]):
+ local_floats = list(floats)
+ local_ints = list(ints)
+ FUNC = self.FuncType(args, F)
+ FPTR = self.Ptr(FUNC)
+ func_ptr = llhelper(FPTR, func)
+ calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+ funcbox = self.get_funcbox(cpu, func_ptr)
+ argslist = []
+ for x in args:
+ if x is F:
+ argslist.append(boxfloat(local_floats.pop()))
+ else:
+ argslist.append(BoxInt(local_ints.pop()))
+
+ res = self.execute_operation(rop.CALL,
+ [funcbox] + argslist,
+ 'float', descr=calldescr)
+ assert abs(res.getfloat() - result) < 0.0001
+
More information about the pypy-commit
mailing list