[pypy-commit] pypy ppc-jit-backend: Implemented COPYUNICODECONTENT
hager
noreply at buildbot.pypy.org
Mon Nov 14 19:38:07 CET 2011
Author: hager <sven.hager at uni-duesseldorf.de>
Branch: ppc-jit-backend
Changeset: r49413:34e139792020
Date: 2011-11-14 19:37 +0100
http://bitbucket.org/pypy/pypy/changeset/34e139792020/
Log: Implemented COPYUNICODECONTENT
diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -462,6 +462,10 @@
assert len(arglocs) == 0
self._emit_copystrcontent(op, regalloc, is_unicode=False)
+ def emit_copyunicodecontent(self, op, arglocs, regalloc):
+ assert len(arglocs) == 0
+ self._emit_copystrcontent(op, regalloc, is_unicode=True)
+
def _emit_copystrcontent(self, op, regalloc, is_unicode):
# compute the source address
args = list(op.getarglist())
@@ -502,7 +506,18 @@
length_loc, length_box = regalloc._ensure_value_is_boxed(args[4], forbidden_vars)
args.append(length_box)
if is_unicode:
- assert 0, "not implemented yet"
+ forbidden_vars = [srcaddr_box, dstaddr_box]
+ bytes_box = TempPtr()
+ bytes_loc = regalloc.force_allocate_reg(bytes_box, forbidden_vars)
+ scale = self._get_unicode_item_scale()
+ assert length_loc.is_reg()
+ self.mc.li(r.r0.value, 1<<scale)
+ if IS_PPC_32:
+ self.mc.mullw(bytes_loc.value, r.r0.value, length_loc.value)
+ else:
+ self.mc.mulld(bytes_loc.value, r.r0.value, length_loc.value)
+ length_box = bytes_box
+ length_loc = bytes_loc
# call memcpy()
self._emit_call(NO_FORCE_INDEX, self.memcpy_addr,
[dstaddr_box, srcaddr_box, length_box], regalloc)
@@ -542,6 +557,16 @@
else:
self.mc.addi(result.value, scaled_loc.value, baseofs)
+ def _get_unicode_item_scale(self):
+ _, itemsize, _ = symbolic.get_array_token(rstr.UNICODE,
+ self.cpu.translate_support_code)
+ if itemsize == 4:
+ return 2
+ elif itemsize == 2:
+ return 1
+ else:
+ raise AssertionError("bad unicode item size")
+
emit_unicodelen = emit_strlen
# XXX 64 bit adjustment
diff --git a/pypy/jit/backend/ppc/ppcgen/regalloc.py b/pypy/jit/backend/ppc/ppcgen/regalloc.py
--- a/pypy/jit/backend/ppc/ppcgen/regalloc.py
+++ b/pypy/jit/backend/ppc/ppcgen/regalloc.py
@@ -533,6 +533,7 @@
return [value_loc, base_loc, ofs_loc, imm(basesize)]
prepare_copystrcontent = void
+ prepare_copyunicodecontent = void
def prepare_unicodelen(self, op):
l0, box = self._ensure_value_is_boxed(op.getarg(0))
More information about the pypy-commit
mailing list