[pypy-commit] pypy ppc-jit-backend: (bivab, hager): fix bug in assemble_loop and assemble_bridge regarding positions and make test_compile_asmlen pass
hager
noreply at buildbot.pypy.org
Mon Mar 5 15:38:06 CET 2012
Author: hager <sven.hager at uni-duesseldorf.de>
Branch: ppc-jit-backend
Changeset: r53228:cc60501c9b82
Date: 2012-03-05 06:15 -0800
http://bitbucket.org/pypy/pypy/changeset/cc60501c9b82/
Log: (bivab, hager): fix bug in assemble_loop and assemble_bridge
regarding positions and make test_compile_asmlen pass
diff --git a/pypy/jit/backend/detect_cpu.py b/pypy/jit/backend/detect_cpu.py
--- a/pypy/jit/backend/detect_cpu.py
+++ b/pypy/jit/backend/detect_cpu.py
@@ -31,8 +31,8 @@
'i86pc': 'x86', # Solaris/Intel
'x86': 'x86', # Apple
'Power Macintosh': 'ppc',
- 'ppc64': 'ppc64',
- 'ppc64_64': 'ppc64',
+ 'ppc64': 'ppc',
+ 'ppc64_64': 'ppc',
'x86_64': 'x86',
'amd64': 'x86', # freebsd
'AMD64': 'x86', # win64
diff --git a/pypy/jit/backend/ppc/ppc_assembler.py b/pypy/jit/backend/ppc/ppc_assembler.py
--- a/pypy/jit/backend/ppc/ppc_assembler.py
+++ b/pypy/jit/backend/ppc/ppc_assembler.py
@@ -571,7 +571,7 @@
looptoken._ppc_loop_code = start_pos
clt.frame_depth = clt.param_depth = -1
spilling_area, param_depth = self._assemble(operations, regalloc)
- size_excluding_failure_stuff = self.mc.get_relative_pos()
+ size_excluding_failure_stuff = self.mc.currpos()
clt.frame_depth = spilling_area
clt.param_depth = param_depth
@@ -611,8 +611,8 @@
loop_start))
debug_stop("jit-backend-addr")
- # XXX 3rd arg may not be correct yet
- return AsmInfo(ops_offset, real_start, size_excluding_failure_stuff)
+ return AsmInfo(ops_offset, loop_start,
+ size_excluding_failure_stuff - start_pos)
def _assemble(self, operations, regalloc):
regalloc.compute_hint_frame_locations(operations)
@@ -644,9 +644,9 @@
sp_patch_location = self._prepare_sp_patch_position()
- startpos = self.mc.get_relative_pos()
+ startpos = self.mc.currpos()
spilling_area, param_depth = self._assemble(operations, regalloc)
- codeendpos = self.mc.get_relative_pos()
+ codeendpos = self.mc.currpos()
self.write_pending_failure_recoveries()
diff --git a/pypy/jit/backend/ppc/test/test_runner.py b/pypy/jit/backend/ppc/test/test_runner.py
--- a/pypy/jit/backend/ppc/test/test_runner.py
+++ b/pypy/jit/backend/ppc/test/test_runner.py
@@ -18,6 +18,11 @@
pass
class TestPPC(LLtypeBackendTest):
+
+ add_loop_instructions = ["mr", "add", "cmpdi", "beq", "b"]
+ bridge_loop_instructions_short = ["lis", "ori", "mtctr", "bctr"]
+ bridge_loop_instructions_long = ["lis", "ori", "rldicr", "oris", "ori",
+ "mtctr", "bctr"]
def setup_method(self, meth):
self.cpu = PPC_CPU(rtyper=None, stats=FakeStats())
diff --git a/pypy/jit/backend/test/runner_test.py b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -17,6 +17,7 @@
from pypy.rpython.llinterp import LLException
from pypy.jit.codewriter import heaptracker, longlong
from pypy.rlib.rarithmetic import intmask
+from pypy.jit.backend.detect_cpu import autodetect_main_model_and_size
def boxfloat(x):
return BoxFloat(longlong.getfloatstorage(x))
@@ -3425,21 +3426,30 @@
"""
bridge = parse(bridge_ops, self.cpu, namespace=locals())
looptoken = JitCellToken()
- self.cpu.assembler.set_debug(False)
+ self.cpu.asm.set_debug(False)
info = self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
bridge_info = self.cpu.compile_bridge(faildescr, bridge.inputargs,
bridge.operations,
looptoken)
- self.cpu.assembler.set_debug(True) # always on untranslated
+ self.cpu.asm.set_debug(True) # always on untranslated
assert info.asmlen != 0
cpuname = autodetect_main_model_and_size()
# XXX we have to check the precise assembler, otherwise
# we don't quite know if borders are correct
- def checkops(mc, ops):
- assert len(mc) == len(ops)
- for i in range(len(mc)):
- assert mc[i].split("\t")[2].startswith(ops[i])
+ def checkops(mc, ops, ops2=None):
+ if ops2 is None:
+ assert len(mc) == len(ops)
+ for i in range(len(mc)):
+ assert mc[i].split("\t")[2].startswith(ops[i])
+ else:
+ if len(mc) != len(ops):
+ oplist = ops2
+ else:
+ oplist = ops
+ assert len(mc) == len(oplist)
+ for i in range(len(mc)):
+ assert mc[i].split("\t")[2].startswith(oplist[i])
data = ctypes.string_at(info.asmaddr, info.asmlen)
mc = list(machine_code_dump(data, info.asmaddr, cpuname))
@@ -3448,7 +3458,13 @@
data = ctypes.string_at(bridge_info.asmaddr, bridge_info.asmlen)
mc = list(machine_code_dump(data, bridge_info.asmaddr, cpuname))
lines = [line for line in mc if line.count('\t') >= 2]
- checkops(lines, self.bridge_loop_instructions)
+
+ # We have to check two alternatives here, since we emit different
+ # sequences of operations depending on the architecture and the
+ # size of the constant we want to load.
+ # Here: The constant is our jump target (an address).
+ checkops(lines, self.bridge_loop_instructions_short,
+ self.bridge_loop_instructions_long)
def test_compile_bridge_with_target(self):
# This test creates a loopy piece of code in a bridge, and builds another
More information about the pypy-commit
mailing list