Author: Richard Plangger <[email protected]>
Branch: memop-simplify2
Changeset: r80944:4f4e031576c3
Date: 2015-11-25 16:19 +0100
http://bitbucket.org/pypy/pypy/changeset/4f4e031576c3/

Log:    two more tests checking different supported cpu factors and the
        skipped int_mul/int_add and renamed index to indexed

diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -134,13 +134,17 @@
             # ofs is NOT the offset!
             #index_box = ResOperation(rop.INT_ADD, [index_box, ConstInt(ofs)])
             #self.emit_op(index_box)
+
+        if sign:
+            itemsize = -itemsize
         if factor == 1 and offset == 0:
             newload = ResOperation(OpHelpers.get_gc_load(op.type),
-                        [ptr_box, index_box, ConstInt(itemsize), 
ConstInt(sign)])
+                        [ptr_box, index_box, ConstInt(itemsize)])
             self.replace_op_with(op, newload)
         else:
-            newload = ResOperation(OpHelpers.get_gc_load_scaled(op.type),
-                        [ptr_box, index_box, ConstInt(factor), 
ConstInt(itemsize), ConstInt(sign)])
+            newload = ResOperation(OpHelpers.get_gc_load_indexed(op.type),
+                        [ptr_box, index_box, ConstInt(factor),
+                         ConstInt(offset), ConstInt(itemsize)])
             self.replace_op_with(op, newload)
 
     def rewrite(self, operations):
diff --git a/rpython/jit/backend/llsupport/test/test_rewrite.py 
b/rpython/jit/backend/llsupport/test/test_rewrite.py
--- a/rpython/jit/backend/llsupport/test/test_rewrite.py
+++ b/rpython/jit/backend/llsupport/test/test_rewrite.py
@@ -45,6 +45,21 @@
         adescr.tid = 4321
         alendescr = adescr.lendescr
         #
+        A32 = lltype.GcArray(rffi.INT)
+        a32descr = get_array_descr(self.gc_ll_descr, A32)
+        a32descr.tid = 4322
+        a32lendescr = a32descr.lendescr
+        #
+        A16 = lltype.GcArray(rffi.SHORT)
+        a16descr = get_array_descr(self.gc_ll_descr, A16)
+        a16descr.tid = 4323
+        a16lendescr = a16descr.lendescr
+        #
+        A8 = lltype.GcArray(rffi.CHAR)
+        a8descr = get_array_descr(self.gc_ll_descr, A8)
+        a8descr.tid = 4323
+        a8lendescr = a8descr.lendescr
+        #
         B = lltype.GcArray(lltype.Char)
         bdescr = get_array_descr(self.gc_ll_descr, B)
         bdescr.tid = 8765
@@ -1091,22 +1106,28 @@
             jump()
         """)
 
-    @py.test.mark.parametrize('factors,suffix,ops,index,descr,off,factor', [
-        [ (1,), 'i', ['i2 = int_mul(i1,8)'], 'i2', 'adescr', 8, 1 ],
-        [ (1,), 'f', ['i2 = int_mul(i1,8)'], 'i2', 'fdescr', 8, 0 ],
-        [ (1,), 'i', ['i2 = int_mul(i1,4)'], 'i2', 'sfdescr', 4, 0 ],
-        [ (1,), 'r', ['i2 = int_mul(i1,8)'], 'i2', 'cdescr', 8, 0 ],
+    @py.test.mark.parametrize('factors,suffix,ops,index,descr,params', [
+        [ (1,), 'i', ['i2 = int_mul(i1,8)'], 'i2', 'adescr', (-8,) ],
+        [ (1,), 'f', ['i2 = int_mul(i1,8)'], 'i2', 'fdescr', (8,) ],
+        [ (1,), 'i', ['i2 = int_mul(i1,4)'], 'i2', 'sfdescr', (4,) ],
+        [ (1,), 'r', ['i2 = int_mul(i1,8)'], 'i2', 'cdescr', (8,) ],
+        [ (1,2), 'indexed_i', [''], 'i1', 'a16descr', (2, 0, -2) ],
+        [ (1,2), 'i', ['i2 = int_mul(i1,4)'], 'i2', 'a32descr', (-4,) ],
     ])
-    def test_getarrayitem(self, factors, suffix, ops, index, descr, off, 
factor):
+    def test_getarrayitem(self, factors, suffix, ops, index, descr, params):
         self.cpu.load_supported_factors = factors
         ops = '\n'.join(ops)
+        params = ','.join([str(i) for i in params])
+        getarray_suffix = suffix
+        if suffix.startswith('indexed_'):
+            getarray_suffix = suffix[-1:]
         self.check_rewrite("""
             [p0,i1]
-            i2 = getarrayitem_gc_{suffix}(p0,i1,descr={descr})
+            i2 = getarrayitem_gc_{getarray_suffix}(p0,i1,descr={descr})
             jump()
         """.format(**locals()), """
             [p0,i1]
             {ops}
-            i3 = gc_load_{suffix}(p0,{index},{off},{factor})
+            i3 = gc_load_{suffix}(p0,{index},{params})
             jump()
         """.format(**locals()))
diff --git a/rpython/jit/metainterp/executor.py 
b/rpython/jit/metainterp/executor.py
--- a/rpython/jit/metainterp/executor.py
+++ b/rpython/jit/metainterp/executor.py
@@ -400,9 +400,9 @@
                          rop.GC_LOAD_I,
                          rop.GC_LOAD_R,
                          rop.GC_LOAD_F,
-                         rop.GC_LOAD_INDEX_I,
-                         rop.GC_LOAD_INDEX_R,
-                         rop.GC_LOAD_INDEX_F,
+                         rop.GC_LOAD_INDEXED_I,
+                         rop.GC_LOAD_INDEXED_R,
+                         rop.GC_LOAD_INDEXED_F,
                          ):      # list of opcodes never executed by pyjitpl
                 continue
             if rop._VEC_PURE_FIRST <= value <= rop._VEC_PURE_LAST:
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
@@ -1099,8 +1099,8 @@
     #
     '_ALWAYS_PURE_LAST',  # ----- end of always_pure operations -----
 
-    'GC_LOAD/4/rfi',
-    'GC_LOAD_INDEX/5/rfi',
+    'GC_LOAD/3/rfi',
+    'GC_LOAD_INDEXED/4/rfi',
 
     '_RAW_LOAD_FIRST',
     'GETARRAYITEM_GC/2d/rfi',
@@ -1616,14 +1616,14 @@
             return rop.GC_LOAD_R
 
     @staticmethod
-    def get_gc_load_caled(tp):
+    def get_gc_load_indexed(tp):
         if tp == 'i':
-            return rop.GC_LOAD_SCALED_I
+            return rop.GC_LOAD_INDEXED_I
         elif tp == 'f':
-            return rop.GC_LOAD_SCALED_F
+            return rop.GC_LOAD_INDEXED_F
         else:
             assert tp == 'r'
-            return rop.GC_LOAD_SCALED_R
+            return rop.GC_LOAD_INDEXED_R
 
     @staticmethod
     def inputarg_from_tp(tp):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to