def produce_op(self, opt, preamble_op, exported_infos, invented_name): optrewrite = opt.optimizer.optrewrite if optrewrite is None: return op = self.res key = make_hashable_int(op.getarg(0).getint()) optrewrite.loop_invariant_results[key] = PreambleOp(op, preamble_op, invented_name)
def produce_op(self, opt, preamble_op, exported_infos, invented_name): optrewrite = opt.optimizer.optrewrite if optrewrite is None: return op = self.res key = make_hashable_int(op.getarg(0).getint()) optrewrite.loop_invariant_results[key] = PreambleOp( op, preamble_op, invented_name)
def optimize_CALL_LOOPINVARIANT_I(self, op): arg = op.getarg(0) # 'arg' must be a Const, because residual_call in codewriter # expects a compile-time constant assert isinstance(arg, Const) key = make_hashable_int(arg.getint()) resvalue = self.loop_invariant_results.get(key, None) if resvalue is not None: resvalue = self.optimizer.force_op_from_preamble(resvalue) self.loop_invariant_results[key] = resvalue self.make_equal_to(op, resvalue) self.last_emitted_operation = REMOVED return # change the op to be a normal call, from the backend's point of view # there is no reason to have a separate operation for this newop = self.replace_op_with(op, OpHelpers.call_for_descr(op.getdescr())) return self.emit_result(CallLoopinvariantOptimizationResult(self, newop, op))
def optimize_CALL_LOOPINVARIANT(self, op): arg = op.getarg(0) # 'arg' must be a Const, because residual_call in codewriter # expects a compile-time constant assert isinstance(arg, Const) key = make_hashable_int(arg.getint()) resvalue = self.loop_invariant_results.get(key, None) if resvalue is not None: self.make_equal_to(op.result, resvalue) self.last_emitted_operation = REMOVED return # change the op to be a normal call, from the backend's point of view # there is no reason to have a separate operation for this self.loop_invariant_producer[key] = op op = op.copy_and_change(rop.CALL) self.emit_operation(op) resvalue = self.getvalue(op.result) self.loop_invariant_results[key] = resvalue
def _callback(self, op, old_op): key = make_hashable_int(op.getarg(0).getint()) self.opt.loop_invariant_producer[key] = self.opt.optimizer.getlastop() self.opt.loop_invariant_results[key] = old_op