[pypy-commit] pypy memop-simplify: added indexing_factors to CPU, started to rewrite jtransform to emit gc_load/raw_load for getarrayitem

plan_rich noreply at buildbot.pypy.org
Mon Nov 23 03:58:40 EST 2015


Author: Richard Plangger <planrichi at gmail.com>
Branch: memop-simplify
Changeset: r80852:4a41f12f2981
Date: 2015-11-23 09:59 +0100
http://bitbucket.org/pypy/pypy/changeset/4a41f12f2981/

Log:	added indexing_factors to CPU, started to rewrite jtransform to emit
	gc_load/raw_load for getarrayitem

diff --git a/rpython/jit/backend/llsupport/llmodel.py b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -32,6 +32,10 @@
     done_with_this_frame_descr_void     = None
     exit_frame_with_exception_descr_ref = None
 
+    # which operations can be specified in the ISA of this
+    # cpu? E.g. x86 can multiply an index with 1,2,4,8 while loading/storing
+    indexing_factors = [1]
+
     vector_extension = False
     vector_register_size = 0 # in bytes
     vector_horizontal_operations = False
diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -703,16 +703,14 @@
             pure = '_pure'
         arraydescr = self.cpu.arraydescrof(ARRAY)
         kind = getkind(op.result.concretetype)
-        if ARRAY._gckind != 'gc':
-            assert ARRAY._gckind == 'raw'
-            if kind == 'r':
-                raise Exception("getarrayitem_raw_r not supported")
-            pure = ''   # always redetected from pyjitpl.py: we don't need
-                        # a '_pure' version of getarrayitem_raw
-        return SpaceOperation('getarrayitem_%s_%s%s' % (ARRAY._gckind,
-                                                        kind[0], pure),
-                              [op.args[0], op.args[1], arraydescr],
-                              op.result)
+        index_ops = []
+        obj = op.args[0]
+        index = op.args[1]
+
+        assert ARRAY._gckind in ('gc','raw')
+        name = '%s_load_%s' % (ARRAY._gckind, kind[0])
+        args = [obj, index, arraydescr]
+        return index_ops + [SpaceOperation(name, args, op.result)]
 
     def rewrite_op_setarrayitem(self, op):
         ARRAY = op.args[0].concretetype.TO
diff --git a/rpython/jit/codewriter/test/test_jtransform.py b/rpython/jit/codewriter/test/test_jtransform.py
--- a/rpython/jit/codewriter/test/test_jtransform.py
+++ b/rpython/jit/codewriter/test/test_jtransform.py
@@ -1,19 +1,7 @@
 
 import py
 import random
-try:
-    from itertools import product
-except ImportError:
-    # Python 2.5, this is taken from the CPython docs, but simplified.
-    def product(*args):
-        # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
-        # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
-        pools = map(tuple, args)
-        result = [[]]
-        for pool in pools:
-            result = [x+[y] for x in result for y in pool]
-        for prod in result:
-            yield tuple(prod)
+from itertools import product
 
 from rpython.flowspace.model import FunctionGraph, Block, Link, c_last_exception
 from rpython.flowspace.model import SpaceOperation, Variable, Constant
@@ -996,7 +984,7 @@
     v2 = varoftype(lltype.Char)
     op = SpaceOperation('getfield', [v1, Constant('x', lltype.Void)], v2)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
-    assert op1.opname == 'getfield_gc_i'
+    assert op1.opname == 'gc_load_i'
     assert op1.args == [v1, ('fielddescr', S, 'x')]
     assert op1.result == v2
 
diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -1087,14 +1087,14 @@
     'INSTANCE_PTR_NE/2b/i',
     'NURSERY_PTR_INCREMENT/2/r',
     #
-    #'ARRAYLEN_GC/1d/i',
-    #'STRLEN/1/i',
-    # DEL 'STRGETITEM/2/i',
-    # DEL 'GETFIELD_GC_PURE/1d/rfi',
+    # DEL 'ARRAYLEN_GC/1d/i',
+    # DEL 'STRLEN/1/i',
+    'STRGETITEM/2/i',
+    'GETFIELD_GC_PURE/1d/rfi',
     # DEL 'GETARRAYITEM_GC_PURE/2d/rfi',
     #'GETFIELD_RAW_PURE/1d/rfi',     these two operations not useful and
     #'GETARRAYITEM_RAW_PURE/2d/fi',  dangerous when unrolling speculatively
-    #'UNICODELEN/1/i',
+    # DEL 'UNICODELEN/1/i',
     # DEL 'UNICODEGETITEM/2/i',
     #
     '_ALWAYS_PURE_LAST',  # ----- end of always_pure operations -----
@@ -1374,17 +1374,20 @@
 _opvector = {
     rop.RAW_LOAD_I:         rop.VEC_RAW_LOAD_I,
     rop.RAW_LOAD_F:         rop.VEC_RAW_LOAD_F,
-    rop.GETARRAYITEM_RAW_I: rop.VEC_GETARRAYITEM_RAW_I,
-    rop.GETARRAYITEM_RAW_F: rop.VEC_GETARRAYITEM_RAW_F,
-    rop.GETARRAYITEM_GC_I: rop.VEC_GETARRAYITEM_GC_I,
-    rop.GETARRAYITEM_GC_F: rop.VEC_GETARRAYITEM_GC_F,
+    rop.GC_LOAD_I:         rop.VEC_RAW_LOAD_I,
+    rop.GC_LOAD_F:         rop.VEC_RAW_LOAD_F,
+    #rop.GETARRAYITEM_RAW_I: rop.VEC_GETARRAYITEM_RAW_I,
+    #rop.GETARRAYITEM_RAW_F: rop.VEC_GETARRAYITEM_RAW_F,
+    #rop.GETARRAYITEM_GC_I: rop.VEC_GETARRAYITEM_GC_I,
+    #rop.GETARRAYITEM_GC_F: rop.VEC_GETARRAYITEM_GC_F,
     # note that there is no _PURE operation for vector operations.
     # reason: currently we do not care if it is pure or not!
-    rop.GETARRAYITEM_GC_PURE_I: rop.VEC_GETARRAYITEM_GC_I,
-    rop.GETARRAYITEM_GC_PURE_F: rop.VEC_GETARRAYITEM_GC_F,
+    #rop.GETARRAYITEM_GC_PURE_I: rop.VEC_GETARRAYITEM_GC_I,
+    #rop.GETARRAYITEM_GC_PURE_F: rop.VEC_GETARRAYITEM_GC_F,
     rop.RAW_STORE:        rop.VEC_RAW_STORE,
-    rop.SETARRAYITEM_RAW: rop.VEC_SETARRAYITEM_RAW,
-    rop.SETARRAYITEM_GC: rop.VEC_SETARRAYITEM_GC,
+    rop.GC_STORE:         rop.VEC_RAW_STORE, # TODO
+    #rop.SETARRAYITEM_RAW: rop.VEC_SETARRAYITEM_RAW,
+    #rop.SETARRAYITEM_GC: rop.VEC_SETARRAYITEM_GC,
 
     rop.INT_ADD:   rop.VEC_INT_ADD,
     rop.INT_SUB:   rop.VEC_INT_SUB,


More information about the pypy-commit mailing list