Author: Richard Plangger <planri...@gmail.com> Branch: memop-simplify3 Changeset: r81453:710abc88181b Date: 2015-12-28 13:44 +0100 http://bitbucket.org/pypy/pypy/changeset/710abc88181b/
Log: updated test_rewrite and added parameters through a helper function 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 @@ -535,7 +535,7 @@ v_scale = ConstInt(scale) # there is probably no point in doing _emit_mul_if.. for # c_zero! - args = [v_arr, self.c_zero, v_length_scaled, v_scale, v_scale] + args = [v_arr, self.c_zero, v_length_scaled, ConstInt(scale), v_scale] o = ResOperation(rop.ZERO_ARRAY, args, descr=arraydescr) self.emit_op(o) if isinstance(v_length, ConstInt): @@ -660,11 +660,17 @@ try: intset = self.setarrayitems_occurred(box) except KeyError: + start_box = op.getarg(1) + length_box = op.getarg(2) + if isinstance(start_box, ConstInt): + start = start_box.getint() + op.setarg(1, ConstInt(start * scale)) + op.setarg(3, ConstInt(1)) if isinstance(length_box, ConstInt): stop = length_box.getint() scaled_len = stop * scale op.setarg(2, ConstInt(scaled_len)) - op.setarg(3, ConstInt(1)) + op.setarg(4, ConstInt(1)) continue assert op.getarg(1).getint() == 0 # always 'start=0' initially start = 0 @@ -678,6 +684,7 @@ op.setarg(2, ConstInt((stop - start) * scale)) # ^^ may be ConstInt(0); then the operation becomes a no-op op.setarg(3, ConstInt(1)) # set scale to 1 + op.setarg(4, ConstInt(1)) # set scale to 1 del self.last_zero_arrays[:] self._setarrayitems_occurred.clear() # 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 @@ -36,6 +36,21 @@ assert not isinstance(descr, (str, int)) return 'gc_store(%s, %d, %s, %d)' % (baseptr, descr.offset, newvalue, descr.field_size) + def zero_array(baseptr, start, length, descr_name, descr): + assert isinstance(baseptr, str) + assert isinstance(start, (str, int)) + assert isinstance(length, (str, int)) + assert isinstance(descr_name, str) + assert not isinstance(descr, (str,int)) + itemsize = descr.itemsize + start = start * itemsize + length_scale = 1 + if isinstance(length, str): + length_scale = itemsize + else: + length = length * itemsize + return 'zero_array(%s, %s, %s, 1, %d, descr=%s)' % \ + (baseptr, start, length, length_scale, descr_name) def setarrayitem(baseptr, index, newvalue, descr): assert isinstance(baseptr, str) assert isinstance(index, (str, int)) @@ -681,7 +696,7 @@ %(cdescr.basesize + 129 * cdescr.itemsize)d) gc_store(p1, 0, 8111, %(tiddescr.field_size)s) gc_store(p1, 0, 129, %(clendescr.field_size)s) - zero_array(p1, 0, 129, %(cdescr.itemsize)d, descr=cdescr) + %(zero_array('p1', 0, 129, 'cdescr', cdescr))s call_n(123456) cond_call_gc_wb(p1, descr=wbdescr) %(setarrayitem('p1', 'i2', 'p3', cdescr))s @@ -703,7 +718,7 @@ %(cdescr.basesize + 130 * cdescr.itemsize)d) gc_store(p1, 0, 8111, %(tiddescr.field_size)s) gc_store(p1, 0, 130, %(clendescr.field_size)s) - zero_array(p1, 0, 130, %(cdescr.itemsize)d, descr=cdescr) + %(zero_array('p1', 0, 130, 'cdescr', cdescr))s call_n(123456) cond_call_gc_wb_array(p1, i2, descr=wbdescr) %(setarrayitem('p1', 'i2', 'p3', cdescr))s @@ -735,7 +750,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p1, 0, 8111, %(tiddescr.field_size)s) gc_store(p1, 0, 5, %(clendescr.field_size)s) - zero_array(p1, 0, 5, descr=cdescr) + %(zero_array('p1', 0, 5, 'cdescr', cdescr))s label(p1, i2, p3) cond_call_gc_wb_array(p1, i2, descr=wbdescr) %(setarrayitem('p1', 'i2', 'p3', cdescr))s @@ -810,7 +825,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p0, 0, 8111, %(tiddescr.field_size)s) gc_store(p0, 0, 5, %(clendescr.field_size)s) - zero_array(p0, 0, 5, descr=cdescr) + %(zero_array('p0', 0, 5, 'cdescr', cdescr))s %(setarrayitem('p0', 'i2', 'p1', cdescr))s jump() """) @@ -828,7 +843,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p0, 0, 8111, %(tiddescr.field_size)s) gc_store(p0, 0, 5, %(clendescr.field_size)s) - zero_array(p0, %(2*WORD)d, %(3*WORD)d, 1, descr=cdescr) + %(zero_array('p0', 2, 3, 'cdescr', cdescr))s %(setarrayitem('p0', 1, 'p1', cdescr))s %(setarrayitem('p0', 0, 'p2', cdescr))s jump() @@ -847,7 +862,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p0, 0, 8111, %(tiddescr.field_size)s) gc_store(p0, 0, 5, %(clendescr.field_size)s) - zero_array(p0, 0, %(3*WORD)d, 1, descr=cdescr) + %(zero_array('p0', 0, 3, 'cdescr', cdescr))s %(setarrayitem('p0', 3, 'p1', cdescr))s %(setarrayitem('p0', 4, 'p2', cdescr))s jump() @@ -867,7 +882,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p0, 0, 8111, %(tiddescr.field_size)s) gc_store(p0, 0, 5, %(clendescr.field_size)s) - zero_array(p0, 0, 5, descr=cdescr) + %(zero_array('p0', 0, 5, 'cdescr', cdescr))s %(setarrayitem('p0', 3, 'p1', cdescr))s %(setarrayitem('p0', 2, 'p2', cdescr))s %(setarrayitem('p0', 1, 'p2', cdescr))s @@ -890,7 +905,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p0, 0, 8111, %(tiddescr.field_size)s) gc_store(p0, 0, 5, %(clendescr.field_size)s) - zero_array(p0, %(5*WORD)d, 0, 1, descr=cdescr) + %(zero_array('p0', 5, 0, 'cdescr', cdescr))s %(setarrayitem('p0', 3, 'p1', cdescr))s %(setarrayitem('p0', 4, 'p2', cdescr))s %(setarrayitem('p0', 0, 'p1', cdescr))s @@ -913,7 +928,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p0, 0, 8111, %(tiddescr.field_size)s) gc_store(p0, 0, 5, %(clendescr.field_size)s) - zero_array(p0, 1, 4, descr=cdescr) + %(zero_array('p0', 1, 4, 'cdescr', cdescr))s %(setarrayitem('p0', 0, 'p1', cdescr))s call_n(321321) cond_call_gc_wb(p0, descr=wbdescr) @@ -935,7 +950,7 @@ %(cdescr.basesize + 5 * cdescr.itemsize)d) gc_store(p0, 0, 8111, %(tiddescr.field_size)s) gc_store(p0, 0, 5, %(clendescr.field_size)s) - zero_array(p0, 1, 4, descr=cdescr) + %(zero_array('p0', 1, 4, 'cdescr', cdescr))s %(setarrayitem('p0', 0, 'p1', cdescr))s label(p0, p2) cond_call_gc_wb_array(p0, 1, descr=wbdescr) @@ -952,7 +967,7 @@ [p1, p2, i3] p0 = call_malloc_nursery_varsize(0, 1, i3, descr=bdescr) gc_store(p0, 0, i3, %(blendescr.field_size)s) - zero_array(p0, 0, i3, descr=bdescr) + %(zero_array('p0', 0, 'i3', 'bdescr', bdescr))s jump() """) @@ -966,7 +981,7 @@ [p1, p2, i3] p0 = call_malloc_nursery_varsize(0, 1, i3, descr=bdescr) gc_store(p0, 0, i3, %(blendescr.field_size)s) - zero_array(p0, 0, i3, descr=bdescr) + %(zero_array('p0', 0, 'i3', 'bdescr', bdescr))s cond_call_gc_wb_array(p0, 0, descr=wbdescr) %(setarrayitem('p0', 0, 'p1', bdescr))s jump() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit