Author: Richard Plangger <planri...@gmail.com> Branch: vecopt-merge Changeset: r79582:bd74760268d5 Date: 2015-09-10 11:51 +0200 http://bitbucket.org/pypy/pypy/changeset/bd74760268d5/
Log: syntax error from merging and wrong indentation, started to revive the dependency construction diff --git a/rpython/jit/backend/llgraph/runner.py b/rpython/jit/backend/llgraph/runner.py --- a/rpython/jit/backend/llgraph/runner.py +++ b/rpython/jit/backend/llgraph/runner.py @@ -1274,56 +1274,56 @@ def _new_execute_call_assembler(def_val): def _execute_call_assembler(self, descr, *args): - # XXX simplify the following a bit - # - # pframe = CALL_ASSEMBLER(args..., descr=looptoken) - # ==> - # pframe = CALL looptoken.loopaddr(*args) - # JUMP_IF_FAST_PATH @fastpath - # res = CALL assembler_call_helper(pframe) - # jmp @done - # @fastpath: - # res = GETFIELD(pframe, 'result') - # @done: - # - call_op = self.lltrace.operations[self.current_index] - guard_op = self.lltrace.operations[self.current_index + 1] - assert guard_op.getopnum() == rop.GUARD_NOT_FORCED - self.force_guard_op = guard_op - pframe = self.cpu._execute_token(descr, *args) - del self.force_guard_op - # - jd = descr.outermost_jitdriver_sd - assert jd is not None, ("call_assembler(): the loop_token needs " - "to have 'outermost_jitdriver_sd'") - if jd.index_of_virtualizable != -1: - vable = args[jd.index_of_virtualizable] - else: - vable = lltype.nullptr(llmemory.GCREF.TO) - # - # Emulate the fast path - # - faildescr = self.cpu.get_latest_descr(pframe) - if faildescr == self.cpu.done_with_this_frame_descr_int: - return self.cpu.get_int_value(pframe, 0) - elif faildescr == self.cpu.done_with_this_frame_descr_ref: - return self.cpu.get_ref_value(pframe, 0) - elif faildescr == self.cpu.done_with_this_frame_descr_float: - return self.cpu.get_float_value(pframe, 0) - elif faildescr == self.cpu.done_with_this_frame_descr_void: - return None + # XXX simplify the following a bit + # + # pframe = CALL_ASSEMBLER(args..., descr=looptoken) + # ==> + # pframe = CALL looptoken.loopaddr(*args) + # JUMP_IF_FAST_PATH @fastpath + # res = CALL assembler_call_helper(pframe) + # jmp @done + # @fastpath: + # res = GETFIELD(pframe, 'result') + # @done: + # + call_op = self.lltrace.operations[self.current_index] + guard_op = self.lltrace.operations[self.current_index + 1] + assert guard_op.getopnum() == rop.GUARD_NOT_FORCED + self.force_guard_op = guard_op + pframe = self.cpu._execute_token(descr, *args) + del self.force_guard_op + # + jd = descr.outermost_jitdriver_sd + assert jd is not None, ("call_assembler(): the loop_token needs " + "to have 'outermost_jitdriver_sd'") + if jd.index_of_virtualizable != -1: + vable = args[jd.index_of_virtualizable] + else: + vable = lltype.nullptr(llmemory.GCREF.TO) + # + # Emulate the fast path + # + faildescr = self.cpu.get_latest_descr(pframe) + if faildescr == self.cpu.done_with_this_frame_descr_int: + return self.cpu.get_int_value(pframe, 0) + elif faildescr == self.cpu.done_with_this_frame_descr_ref: + return self.cpu.get_ref_value(pframe, 0) + elif faildescr == self.cpu.done_with_this_frame_descr_float: + return self.cpu.get_float_value(pframe, 0) + elif faildescr == self.cpu.done_with_this_frame_descr_void: + return None - assembler_helper_ptr = jd.assembler_helper_adr.ptr # fish - try: - result = assembler_helper_ptr(pframe, vable) - except LLException, lle: - assert self.last_exception is None, "exception left behind" - self.last_exception = lle - # fish op + assembler_helper_ptr = jd.assembler_helper_adr.ptr # fish + try: + result = assembler_helper_ptr(pframe, vable) + except LLException, lle: + assert self.last_exception is None, "exception left behind" + self.last_exception = lle + # fish op result = def_val - if isinstance(result, float): - result = support.cast_to_floatstorage(result) - return result + if isinstance(result, float): + result = support.cast_to_floatstorage(result) + return result return _execute_call_assembler execute_call_assembler_i = _new_execute_call_assembler(0) 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 @@ -17,37 +17,37 @@ @specialize.arg(4) def _do_call(cpu, metainterp, argboxes, descr, rettype): - assert metainterp is not None - # count the number of arguments of the different types - count_i = count_r = count_f = 0 - for i in range(1, len(argboxes)): - type = argboxes[i].type - if type == INT: count_i += 1 - elif type == REF: count_r += 1 - elif type == FLOAT: count_f += 1 - # allocate lists for each type that has at least one argument - if count_i: args_i = [0] * count_i - else: args_i = None - if count_r: args_r = [NULL] * count_r - else: args_r = None - if count_f: args_f = [longlong.ZEROF] * count_f - else: args_f = None - # fill in the lists - count_i = count_r = count_f = 0 - for i in range(1, len(argboxes)): - box = argboxes[i] - if box.type == INT: - args_i[count_i] = box.getint() - count_i += 1 - elif box.type == REF: - args_r[count_r] = box.getref_base() - count_r += 1 - elif box.type == FLOAT: - args_f[count_f] = box.getfloatstorage() - count_f += 1 - # get the function address as an integer - func = argboxes[0].getint() - # do the call using the correct function from the cpu + assert metainterp is not None + # count the number of arguments of the different types + count_i = count_r = count_f = 0 + for i in range(1, len(argboxes)): + type = argboxes[i].type + if type == INT: count_i += 1 + elif type == REF: count_r += 1 + elif type == FLOAT: count_f += 1 + # allocate lists for each type that has at least one argument + if count_i: args_i = [0] * count_i + else: args_i = None + if count_r: args_r = [NULL] * count_r + else: args_r = None + if count_f: args_f = [longlong.ZEROF] * count_f + else: args_f = None + # fill in the lists + count_i = count_r = count_f = 0 + for i in range(1, len(argboxes)): + box = argboxes[i] + if box.type == INT: + args_i[count_i] = box.getint() + count_i += 1 + elif box.type == REF: + args_r[count_r] = box.getref_base() + count_r += 1 + elif box.type == FLOAT: + args_f[count_f] = box.getfloatstorage() + count_f += 1 + # get the function address as an integer + func = argboxes[0].getint() + # do the call using the correct function from the cpu if rettype == INT: try: result = cpu.bh_call_i(func, args_i, args_r, args_f, descr) @@ -386,11 +386,14 @@ rop.CALL_MALLOC_NURSERY_VARSIZE_FRAME, rop.NURSERY_PTR_INCREMENT, rop.LABEL, - rop.VEC_RAW_LOAD, + rop.VEC_RAW_LOAD_I, + rop.VEC_RAW_LOAD_F, rop.VEC_RAW_STORE, - rop.VEC_GETARRAYITEM_RAW, + rop.VEC_GETARRAYITEM_RAW_I, + rop.VEC_GETARRAYITEM_RAW_F, rop.VEC_SETARRAYITEM_RAW, - rop.VEC_GETARRAYITEM_GC, + rop.VEC_GETARRAYITEM_GC_I, + rop.VEC_GETARRAYITEM_GC_F, rop.VEC_SETARRAYITEM_GC, ): # list of opcodes never executed by pyjitpl continue diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -369,92 +369,6 @@ # ____________________________________________________________ -class Accum(object): - PLUS = '+' - MULTIPLY = '*' - - def __init__(self, opnum, var, pos): - self.var = var - self.pos = pos - self.operator = Accum.PLUS - if opnum == rop.FLOAT_MUL: - self.operator = Accum.MULTIPLY - - def getoriginalbox(self): - return self.var - - def getop(self): - return self.operator - - def accumulates_value(self): - return True - -class BoxVector(Box): - type = VECTOR - _attrs_ = ('item_type','item_count','item_size','item_signed','accum') - _extended_display = False - - def __init__(self, item_type=FLOAT, item_count=2, item_size=8, item_signed=False, accum=None): - assert item_type in (FLOAT, INT) - self.item_type = item_type - self.item_count = item_count - self.item_size = item_size - self.item_signed = item_signed - self.accum = None - - def gettype(self): - return self.item_type - - def getsize(self): - return self.item_size - - def getsigned(self): - return self.item_signed - - def getcount(self): - return self.item_count - - def fully_packed(self, vec_reg_size): - return self.item_size * self.item_count == vec_reg_size - - def forget_value(self): - raise NotImplementedError("cannot forget value of vector") - - def clonebox(self): - return BoxVector(self.item_type, self.item_count, self.item_size, self.item_signed) - - def constbox(self): - raise NotImplementedError("not possible to have a constant vector box") - - def nonnull(self): - raise NotImplementedError("no value known, nonnull is unkown") - - def repr_rpython(self): - return repr_rpython(self, 'bv') - - def same_shape(self, other): - if not isinstance(other, BoxVector): - return False - # - if other.item_size == -1 or self.item_size == -1: - # fallback for tests that do not specify the size - return True - # - if self.item_type != other.item_type: - return False - if self.item_size != other.item_size: - return False - if self.item_count != other.item_count: - return False - if self.item_signed != other.item_signed: - return False - return True - - def getaccum(self): - return self.accum - -# ____________________________________________________________ - def make_hashable_int(i): from rpython.rtyper.lltypesystem.ll2ctypes import NotCtypesAllocatedStructure @@ -815,7 +729,7 @@ ops = op.getdescr()._debug_suboperations TreeLoop.check_consistency_of_branch(ops, seen.copy()) for box in op.getfailargs() or []: - if box is not None: + if box is not None: assert not isinstance(box, Const) assert box in seen elif check_descr: diff --git a/rpython/jit/metainterp/optimizeopt/__init__.py b/rpython/jit/metainterp/optimizeopt/__init__.py --- a/rpython/jit/metainterp/optimizeopt/__init__.py +++ b/rpython/jit/metainterp/optimizeopt/__init__.py @@ -4,7 +4,6 @@ from rpython.jit.metainterp.optimizeopt.virtualize import OptVirtualize from rpython.jit.metainterp.optimizeopt.heap import OptHeap from rpython.jit.metainterp.optimizeopt.vstring import OptString -from rpython.jit.metainterp.optimizeopt.unroll import optimize_unroll from rpython.jit.metainterp.optimizeopt.simplify import OptSimplify from rpython.jit.metainterp.optimizeopt.pure import OptPure from rpython.jit.metainterp.optimizeopt.earlyforce import OptEarlyForce diff --git a/rpython/jit/metainterp/optimizeopt/dependency.py b/rpython/jit/metainterp/optimizeopt/dependency.py --- a/rpython/jit/metainterp/optimizeopt/dependency.py +++ b/rpython/jit/metainterp/optimizeopt/dependency.py @@ -6,8 +6,8 @@ from rpython.jit.metainterp.resume import Snapshot from rpython.jit.metainterp.compile import ResumeGuardDescr from rpython.jit.codewriter.effectinfo import EffectInfo -from rpython.jit.metainterp.history import (BoxPtr, ConstPtr, ConstInt, BoxInt, - Box, Const, BoxFloat, AbstractValue) +from rpython.jit.metainterp.history import (ConstPtr, ConstInt,Const, + AbstractValue) from rpython.rtyper.lltypesystem import llmemory from rpython.rlib.unroll import unrolling_iterable from rpython.rlib.objectmodel import we_are_translated @@ -25,12 +25,12 @@ , (rop.UNICODESETITEM, 0, -1) ] -LOAD_COMPLEX_OBJ = [ (rop.GETARRAYITEM_GC, 0, 1) - , (rop.GETARRAYITEM_RAW, 0, 1) - , (rop.RAW_LOAD, 0, 1) - , (rop.GETINTERIORFIELD_GC, 0, 1) - , (rop.GETFIELD_GC, 0, -1) - , (rop.GETFIELD_RAW, 0, -1) +LOAD_COMPLEX_OBJ = [ (rop.GETARRAYITEM_GC_I, 0, 1) + , (rop.GETARRAYITEM_GC_F, 0, 1) + , (rop.GETARRAYITEM_RAW_I, 0, 1) + , (rop.GETARRAYITEM_RAW_F, 0, 1) + , (rop.RAW_LOAD_I, 0, 1) + , (rop.RAW_LOAD_F, 0, 1) ] class Path(object): @@ -554,9 +554,9 @@ continue intformod.inspect_operation(op,node) # definition of a new variable - if op.result is not None: + if op.type != 'v': # In SSA form. Modifications get a new variable - tracker.define(op.result, node) + tracker.define(op.result(), node) # usage of defined variables if op.is_always_pure() or op.is_final(): # normal case every arguments definition is set @@ -847,9 +847,7 @@ additive_func_source = """ def operation_{name}(self, op, node): - box_r = op.result - if not box_r: - return + box_r = op box_a0 = op.getarg(0) box_a1 = op.getarg(1) if self.is_const_integral(box_a0) and self.is_const_integral(box_a1): @@ -914,15 +912,21 @@ self.memory_refs[node] = node.memory_ref """ exec py.code.Source(array_access_source - .format(name='RAW_LOAD',raw_access=True)).compile() + .format(name='RAW_LOAD_I',raw_access=True)).compile() + exec py.code.Source(array_access_source + .format(name='RAW_LOAD_F',raw_access=True)).compile() exec py.code.Source(array_access_source .format(name='RAW_STORE',raw_access=True)).compile() exec py.code.Source(array_access_source - .format(name='GETARRAYITEM_RAW',raw_access=False)).compile() + .format(name='GETARRAYITEM_RAW_I',raw_access=False)).compile() + exec py.code.Source(array_access_source + .format(name='GETARRAYITEM_RAW_F',raw_access=False)).compile() exec py.code.Source(array_access_source .format(name='SETARRAYITEM_RAW',raw_access=False)).compile() exec py.code.Source(array_access_source - .format(name='GETARRAYITEM_GC',raw_access=False)).compile() + .format(name='GETARRAYITEM_GC_I',raw_access=False)).compile() + exec py.code.Source(array_access_source + .format(name='GETARRAYITEM_GC_F',raw_access=False)).compile() exec py.code.Source(array_access_source .format(name='SETARRAYITEM_GC',raw_access=False)).compile() del array_access_source diff --git a/rpython/jit/metainterp/optimizeopt/guard.py b/rpython/jit/metainterp/optimizeopt/guard.py --- a/rpython/jit/metainterp/optimizeopt/guard.py +++ b/rpython/jit/metainterp/optimizeopt/guard.py @@ -4,12 +4,11 @@ gathered with IntegralForwardModification """ -from rpython.jit.metainterp.optimizeopt.util import Renamer +from rpython.jit.metainterp.optimizeopt.renamer import Renamer from rpython.jit.metainterp.optimizeopt.dependency import (DependencyGraph, MemoryRef, Node, IndexVar) from rpython.jit.metainterp.resoperation import (rop, ResOperation, GuardResOp) -from rpython.jit.metainterp.history import (ConstInt, BoxVector, - BoxFloat, BoxInt, ConstFloat, Box, Const) +from rpython.jit.metainterp.history import (ConstInt, ConstFloat, Const) from rpython.jit.metainterp.compile import ResumeGuardDescr, CompileLoopVersionDescr from rpython.rlib.objectmodel import we_are_translated diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py b/rpython/jit/metainterp/optimizeopt/optimizer.py --- a/rpython/jit/metainterp/optimizeopt/optimizer.py +++ b/rpython/jit/metainterp/optimizeopt/optimizer.py @@ -599,9 +599,7 @@ assert pendingfields is not None if op.getdescr() is not None: descr = op.getdescr() - assert isinstance(descr, compile.ResumeAtPositionDescr) or \ - isinstance(descr, compile.ResumeAtLoopHeaderDescr) - + assert isinstance(descr, compile.ResumeAtPositionDescr) else: descr = compile.invent_fail_descr_for_op(op.getopnum(), self) op.setdescr(descr) @@ -745,10 +743,11 @@ # These are typically removed already by OptRewrite, but it can be # dissabled and unrolling emits some SAME_AS ops to setup the # optimizier state. These needs to always be optimized out. - def optimize_MARK_OPAQUE_PTR(self, op): + def optimize_SAME_AS_I(self, op): self.make_equal_to(op, op.getarg(0)) optimize_SAME_AS_R = optimize_SAME_AS_I optimize_SAME_AS_F = optimize_SAME_AS_I dispatch_opt = make_dispatcher_method(Optimizer, 'optimize_', default=Optimizer.optimize_default) + diff --git a/rpython/jit/metainterp/optimizeopt/renamer.py b/rpython/jit/metainterp/optimizeopt/renamer.py new file mode 100644 --- /dev/null +++ b/rpython/jit/metainterp/optimizeopt/renamer.py @@ -0,0 +1,48 @@ + +class Renamer(object): + def __init__(self): + self.rename_map = {} + + def rename_box(self, box): + return self.rename_map.get(box, box) + + def start_renaming(self, var, tovar): + self.rename_map[var] = tovar + + def rename(self, op): + for i, arg in enumerate(op.getarglist()): + arg = self.rename_map.get(arg, arg) + op.setarg(i, arg) + + if op.is_guard(): + assert isinstance(op, resoperation.GuardResOp) + op.rd_snapshot = self.rename_rd_snapshot(op.rd_snapshot) + self.rename_failargs(op) + + return True + + def rename_failargs(self, guard, clone=False): + if guard.getfailargs() is not None: + if clone: + args = guard.getfailargs()[:] + else: + args = guard.getfailargs() + for i,arg in enumerate(args): + args[i] = self.rename_map.get(arg,arg) + return args + return None + + def rename_rd_snapshot(self, snapshot, clone=False): + # snapshots are nested like the MIFrames + if snapshot is None: + return None + if clone: + boxes = snapshot.boxes[:] + else: + boxes = snapshot.boxes + for i,box in enumerate(boxes): + value = self.rename_map.get(box,box) + boxes[i] = value + # + rec_snap = self.rename_rd_snapshot(snapshot.prev, clone) + return Snapshot(rec_snap, boxes) diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py b/rpython/jit/metainterp/optimizeopt/schedule.py --- a/rpython/jit/metainterp/optimizeopt/schedule.py +++ b/rpython/jit/metainterp/optimizeopt/schedule.py @@ -1,10 +1,9 @@ - -from rpython.jit.metainterp.history import (VECTOR,FLOAT,INT,ConstInt,BoxVector, - BoxFloat,BoxInt,ConstFloat,TargetToken,Box) +from rpython.jit.metainterp.history import (VECTOR, FLOAT, INT, + ConstInt, ConstFloat, TargetToken) from rpython.jit.metainterp.resoperation import (rop, ResOperation, GuardResOp) from rpython.jit.metainterp.optimizeopt.dependency import (DependencyGraph, MemoryRef, Node, IndexVar) -from rpython.jit.metainterp.optimizeopt.util import Renamer +from rpython.jit.metainterp.optimizeopt.renamer import Renamer from rpython.rlib.objectmodel import we_are_translated from rpython.jit.metainterp.jitexc import NotAProfitableLoop @@ -705,9 +704,12 @@ rop.VEC_FLOAT_NE: OpToVectorOp((PT_FLOAT_GENERIC,PT_FLOAT_GENERIC), INT_RES), rop.VEC_INT_IS_TRUE: OpToVectorOp((PT_INT_GENERIC,PT_INT_GENERIC), PT_INT_GENERIC), - rop.VEC_RAW_LOAD: LOAD_TRANS, - rop.VEC_GETARRAYITEM_RAW: LOAD_TRANS, - rop.VEC_GETARRAYITEM_GC: LOAD_TRANS, + rop.VEC_RAW_LOAD_I: LOAD_TRANS, + rop.VEC_RAW_LOAD_F: LOAD_TRANS, + rop.VEC_GETARRAYITEM_RAW_I: LOAD_TRANS, + rop.VEC_GETARRAYITEM_RAW_F: LOAD_TRANS, + rop.VEC_GETARRAYITEM_GC_I: LOAD_TRANS, + rop.VEC_GETARRAYITEM_GC_F: LOAD_TRANS, rop.VEC_RAW_STORE: STORE_TRANS, rop.VEC_SETARRAYITEM_RAW: STORE_TRANS, rop.VEC_SETARRAYITEM_GC: STORE_TRANS, diff --git a/rpython/jit/metainterp/optimizeopt/test/test_dependency.py b/rpython/jit/metainterp/optimizeopt/test/test_dependency.py --- a/rpython/jit/metainterp/optimizeopt/test/test_dependency.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_dependency.py @@ -28,7 +28,7 @@ def parse_loop(self, ops): loop = self.parse(ops, postprocess=self.postprocess) token = JitCellToken() - loop.operations = [ResOperation(rop.LABEL, loop.inputargs, None, + loop.operations = [ResOperation(rop.LABEL, loop.inputargs, descr=TargetToken(token))] + loop.operations if loop.operations[-1].getopnum() == rop.JUMP: loop.operations[-1].setdescr(token) @@ -135,7 +135,6 @@ i = IndexVar(b,1,1,0) j = IndexVar(b,1,1,0) assert i.is_identity() - assert not i.less(j) assert i.same_variable(j) assert i.constant_diff(j) == 0 @@ -563,16 +562,7 @@ def getdescr(self): return self.descr -FLOAT = ArrayDescr(lltype.Float) -SFLOAT = ArrayDescr(lltype.SingleFloat) -CHAR = ArrayDescr(rffi.r_signedchar) -UCHAR = ArrayDescr(rffi.r_uchar) -SHORT = ArrayDescr(rffi.r_short) -USHORT = ArrayDescr(rffi.r_ushort) -INT = ArrayDescr(rffi.r_int) -UINT = ArrayDescr(rffi.r_uint) -LONG = ArrayDescr(rffi.r_longlong) -ULONG = ArrayDescr(rffi.r_ulonglong) +FLOAT = ArrayDescr(lltype.GcArray(lltype.Float), None) def memoryref(array, var, mod=(1,1,0), descr=None, raw=False): if descr is None: diff --git a/rpython/jit/metainterp/optimizeopt/vectorize.py b/rpython/jit/metainterp/optimizeopt/vectorize.py --- a/rpython/jit/metainterp/optimizeopt/vectorize.py +++ b/rpython/jit/metainterp/optimizeopt/vectorize.py @@ -10,21 +10,20 @@ from rpython.jit.metainterp.resume import Snapshot from rpython.jit.metainterp.jitexc import NotAVectorizeableLoop, NotAProfitableLoop -from rpython.jit.metainterp.optimizeopt.unroll import optimize_unroll +#from rpython.jit.metainterp.optimizeopt.unroll import optimize_unroll from rpython.jit.metainterp.compile import (ResumeAtLoopHeaderDescr, CompileLoopVersionDescr, invent_fail_descr_for_op, ResumeGuardDescr) -from rpython.jit.metainterp.history import (ConstInt, VECTOR, FLOAT, INT, - BoxVector, BoxFloat, BoxInt, ConstFloat, TargetToken, JitCellToken, Box, - LoopVersion, Accum, AbstractFailDescr) +from rpython.jit.metainterp.history import (INT, FLOAT, VECTOR, ConstInt, ConstFloat, + TargetToken, JitCellToken, LoopVersion, AbstractFailDescr) from rpython.jit.metainterp.optimizeopt.optimizer import Optimizer, Optimization -from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method, Renamer +from rpython.jit.metainterp.optimizeopt.renamer import Renamer from rpython.jit.metainterp.optimizeopt.dependency import (DependencyGraph, MemoryRef, Node, IndexVar) from rpython.jit.metainterp.optimizeopt.schedule import (VecScheduleData, Scheduler, Pack, Pair, AccumPair, vectorbox_outof_box, getpackopnum, getunpackopnum, PackType, determine_input_output_types) from rpython.jit.metainterp.optimizeopt.guard import GuardStrengthenOpt -from rpython.jit.metainterp.resoperation import (rop, ResOperation, GuardResOp) +from rpython.jit.metainterp.resoperation import (rop, ResOperation, GuardResOp, Accum) from rpython.rlib import listsort from rpython.rlib.objectmodel import we_are_translated from rpython.rlib.debug import debug_print, debug_start, debug_stop @@ -36,8 +35,8 @@ """ Enter the world of SIMD instructions. Bails if it cannot transform the trace. """ - optimize_unroll(metainterp_sd, jitdriver_sd, loop, optimizations, - inline_short_preamble, start_state, False) + #optimize_unroll(metainterp_sd, jitdriver_sd, loop, optimizations, + # inline_short_preamble, start_state, False) user_code = not jitdriver_sd.vec and warmstate.vec_all if user_code and user_loop_bail_fast_path(loop, warmstate): return @@ -332,8 +331,6 @@ if memref_a.is_adjacent_after(memref_b): pair = self.packset.can_be_packed(node_a, node_b, None, False) if pair: - if node_a.op.getopnum() == rop.GETARRAYITEM_RAW: - print " => found", memref_a.index_var, memref_b.index_var self.packset.add_pack(pair) def extend_packset(self): 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 @@ -65,7 +65,7 @@ def ResOperation(opnum, args, descr=None): cls = opclasses[opnum] - op = cls(result) + op = cls() op.initarglist(args) if descr is not None: assert isinstance(op, ResOpWithDescr) @@ -527,6 +527,92 @@ from rpython.jit.metainterp import history return history.ConstPtr(self.getref_base()) +class Accum(object): + PLUS = '+' + MULTIPLY = '*' + + def __init__(self, opnum, var, pos): + self.var = var + self.pos = pos + self.operator = Accum.PLUS + if opnum == rop.FLOAT_MUL: + self.operator = Accum.MULTIPLY + + def getoriginalbox(self): + return self.var + + def getop(self): + return self.operator + + def accumulates_value(self): + return True + +class VectorOp(object): + _mixin_ = True + _attrs_ = ('item_type','item_count','item_size','item_signed','accum') + _extended_display = False + + type = 'V' + + #def __init__(self, item_type=FLOAT, item_count=2, item_size=8, item_signed=False, accum=None): + # assert item_type in (FLOAT, INT) + # self.item_type = item_type + # self.item_count = item_count + # self.item_size = item_size + # self.item_signed = item_signed + # self.accum = None + + def gettype(self): + return self.item_type + + def getsize(self): + return self.item_size + + def getsigned(self): + return self.item_signed + + def getcount(self): + return self.item_count + + def fully_packed(self, vec_reg_size): + return self.item_size * self.item_count == vec_reg_size + + def forget_value(self): + raise NotImplementedError("cannot forget value of vector") + + def clonebox(self): + return BoxVector(self.item_type, self.item_count, self.item_size, self.item_signed) + + def constbox(self): + raise NotImplementedError("not possible to have a constant vector box") + + def nonnull(self): + raise NotImplementedError("no value known, nonnull is unkown") + + def repr_rpython(self): + return repr_rpython(self, 'bv') + + def same_shape(self, other): + if not isinstance(other, BoxVector): + return False + # + if other.item_size == -1 or self.item_size == -1: + # fallback for tests that do not specify the size + return True + # + if self.item_type != other.item_type: + return False + if self.item_size != other.item_size: + return False + if self.item_count != other.item_count: + return False + if self.item_signed != other.item_signed: + return False + return True + + def getaccum(self): + return self.accum + class AbstractInputArg(AbstractResOpOrInputArg): def set_forwarded(self, forwarded_to): @@ -753,6 +839,7 @@ 'GUARD_NOT_FORCED_2/0d/n', # same as GUARD_NOT_FORCED, but for finish() 'GUARD_NOT_INVALIDATED/0d/n', 'GUARD_FUTURE_CONDITION/0d/n', + 'GUARD_EARLY_EXIT/0d/n', # is removable, may be patched by an optimization '_GUARD_LAST', # ----- end of guard operations ----- @@ -787,42 +874,43 @@ # vector operations '_VEC_PURE_FIRST', '_VEC_ARITHMETIC_FIRST', - 'VEC_INT_ADD/2', - 'VEC_INT_SUB/2', - 'VEC_INT_MUL/2', - 'VEC_INT_AND/2', - 'VEC_INT_OR/2', - 'VEC_INT_XOR/2', - 'VEC_FLOAT_ADD/2', - 'VEC_FLOAT_SUB/2', - 'VEC_FLOAT_MUL/2', - 'VEC_FLOAT_TRUEDIV/2', - 'VEC_FLOAT_NEG/1', - 'VEC_FLOAT_ABS/1', + 'VEC_INT_ADD/2/i', + 'VEC_INT_SUB/2/i', + 'VEC_INT_MUL/2/i', + 'VEC_INT_AND/2/i', + 'VEC_INT_OR/2/i', + 'VEC_INT_XOR/2/i', + 'VEC_FLOAT_ADD/2/f', + 'VEC_FLOAT_SUB/2/f', + 'VEC_FLOAT_MUL/2/f', + 'VEC_FLOAT_TRUEDIV/2/f', + 'VEC_FLOAT_NEG/1/f', + 'VEC_FLOAT_ABS/1/f', '_VEC_ARITHMETIC_LAST', - 'VEC_FLOAT_EQ/2b', - 'VEC_FLOAT_NE/2b', - 'VEC_INT_IS_TRUE/1b', - 'VEC_INT_NE/2b', - 'VEC_INT_EQ/2b', + 'VEC_FLOAT_EQ/2b/f', + 'VEC_FLOAT_NE/2b/f', + 'VEC_INT_IS_TRUE/1b/i', + 'VEC_INT_NE/2b/i', + 'VEC_INT_EQ/2b/i', '_VEC_CAST_FIRST', - 'VEC_INT_SIGNEXT/2', + 'VEC_INT_SIGNEXT/2/i', # double -> float: v2 = cast(v1, 2) equal to v2 = (v1[0], v1[1], X, X) - 'VEC_CAST_FLOAT_TO_SINGLEFLOAT/1', + 'VEC_CAST_FLOAT_TO_SINGLEFLOAT/1/i', # v4 = cast(v3, 0, 2), v4 = (v3[0], v3[1]) - 'VEC_CAST_SINGLEFLOAT_TO_FLOAT/1', - 'VEC_CAST_FLOAT_TO_INT/1', - 'VEC_CAST_INT_TO_FLOAT/1', + 'VEC_CAST_SINGLEFLOAT_TO_FLOAT/1/f', + 'VEC_CAST_FLOAT_TO_INT/1/i', + 'VEC_CAST_INT_TO_FLOAT/1/f', '_VEC_CAST_LAST', - 'VEC_FLOAT_UNPACK/3', # iX|fX = VEC_FLOAT_UNPACK(vX, index, item_count) - 'VEC_FLOAT_PACK/4', # VEC_FLOAT_PACK(vX, var/const, index, item_count) - 'VEC_INT_UNPACK/3', # iX|fX = VEC_INT_UNPACK(vX, index, item_count) - 'VEC_INT_PACK/4', # VEC_INT_PACK(vX, var/const, index, item_count) - 'VEC_FLOAT_EXPAND/2', # vX = VEC_FLOAT_EXPAND(var/const, item_count) - 'VEC_INT_EXPAND/2', # vX = VEC_INT_EXPAND(var/const, item_count) - 'VEC_BOX/1', + 'VEC_INT_BOX/1/i', + 'VEC_INT_UNPACK/3/i', # iX|fX = VEC_INT_UNPACK(vX, index, item_count) + 'VEC_INT_PACK/4/i', # VEC_INT_PACK(vX, var/const, index, item_count) + 'VEC_INT_EXPAND/2/i', # vX = VEC_INT_EXPAND(var/const, item_count) + 'VEC_FLOAT_BOX/1/f', + 'VEC_FLOAT_UNPACK/3/f', # iX|fX = VEC_FLOAT_UNPACK(vX, index, item_count) + 'VEC_FLOAT_PACK/4/f', # VEC_FLOAT_PACK(vX, var/const, index, item_count) + 'VEC_FLOAT_EXPAND/2/f', # vX = VEC_FLOAT_EXPAND(var/const, item_count) '_VEC_PURE_LAST', # 'INT_LT/2b/i', @@ -872,11 +960,11 @@ '_RAW_LOAD_FIRST', 'GETARRAYITEM_GC/2d/rfi', - 'VEC_GETARRAYITEM_GC/3d', + 'VEC_GETARRAYITEM_GC/3d/fi', 'GETARRAYITEM_RAW/2d/fi', - 'VEC_GETARRAYITEM_RAW/3d', + 'VEC_GETARRAYITEM_RAW/3d/fi', 'RAW_LOAD/2d/fi', - 'VEC_RAW_LOAD/3d', + 'VEC_RAW_LOAD/3d/fi', '_RAW_LOAD_LAST', 'GETINTERIORFIELD_GC/2d/rfi', @@ -899,11 +987,11 @@ 'INCREMENT_DEBUG_COUNTER/1/n', '_RAW_STORE_FIRST', 'SETARRAYITEM_GC/3d/n', - 'VEC_SETARRAYITEM_GC/3d', + 'VEC_SETARRAYITEM_GC/3d/n', 'SETARRAYITEM_RAW/3d/n', - 'VEC_SETARRAYITEM_RAW/3d', + 'VEC_SETARRAYITEM_RAW/3d/n', 'RAW_STORE/3d/n', - 'VEC_RAW_STORE/3d', + 'VEC_RAW_STORE/3d/n', '_RAW_STORE_LAST', 'SETINTERIORFIELD_GC/3d/n', 'SETINTERIORFIELD_RAW/3d/n', # right now, only used by tests @@ -1000,7 +1088,7 @@ for r in result: if len(result) == 1: cls_name = name - else: + else: cls_name = name + '_' + r.upper() setattr(rop, cls_name, i) opname[i] = cls_name @@ -1126,13 +1214,18 @@ rop.PTR_NE: rop.PTR_NE, } _opvector = { - rop.RAW_LOAD: rop.VEC_RAW_LOAD, - rop.GETARRAYITEM_RAW: rop.VEC_GETARRAYITEM_RAW, - rop.GETARRAYITEM_GC: rop.VEC_GETARRAYITEM_GC, + 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, # note that there is no _PURE operation for vector operations. # reason: currently we do not care if it is pure or not! - rop.GETARRAYITEM_RAW_PURE: rop.VEC_GETARRAYITEM_RAW, - rop.GETARRAYITEM_GC_PURE: rop.VEC_GETARRAYITEM_GC, + rop.GETARRAYITEM_RAW_PURE_I: rop.VEC_GETARRAYITEM_RAW_I, + rop.GETARRAYITEM_RAW_PURE_F: rop.VEC_GETARRAYITEM_RAW_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, _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit