Пример #1
0
 def export_state(self, start_label, original_label_args, renamed_inputargs,
                  memo):
     end_args = [self.optimizer.force_box_for_end_of_preamble(a)
                 for a in original_label_args]
     self.optimizer.flush()
     virtual_state = self.get_virtual_state(end_args)
     end_args = [self.get_box_replacement(arg) for arg in end_args]
     infos = {}
     for arg in end_args:
         self._expand_info(arg, infos)
     label_args, virtuals = virtual_state.make_inputargs_and_virtuals(
         end_args, self.optimizer)
     for arg in label_args:
         self._expand_info(arg, infos)
     sb = ShortBoxes()
     short_boxes = sb.create_short_boxes(self.optimizer, renamed_inputargs,
                                         label_args + virtuals)
     short_inputargs = sb.create_short_inputargs(label_args + virtuals)
     for produced_op in short_boxes:
         op = produced_op.short_op.res
         if not isinstance(op, Const):
             self._expand_info(op, infos)
     self.optimizer._clean_optimization_info(end_args)
     self.optimizer._clean_optimization_info(start_label.getarglist())
     return ExportedState(label_args, end_args, virtual_state, infos,
                          short_boxes, renamed_inputargs,
                          short_inputargs, memo)
Пример #2
0
 def test_pure_ops_does_not_work(self):
     i0 = InputArgInt()
     i1 = InputArgInt()
     op = ResOperation(rop.INT_ADD, [i0, i1])
     sb = ShortBoxes()
     short_boxes = sb.create_short_boxes(Opt([op]), [i0], [i0])
     assert len(short_boxes) == 1 # just inparg
Пример #3
0
 def export_state(self, original_label_args, renamed_inputargs,
                  runtime_boxes, memo):
     end_args = [
         self.optimizer.force_box_for_end_of_preamble(a)
         for a in original_label_args
     ]
     self.optimizer.flush()
     virtual_state = self.get_virtual_state(end_args)
     end_args = [self.get_box_replacement(arg) for arg in end_args]
     infos = {}
     for arg in end_args:
         self._expand_info(arg, infos)
     label_args, virtuals = virtual_state.make_inputargs_and_virtuals(
         end_args, self.optimizer)
     for arg in label_args:
         self._expand_info(arg, infos)
     sb = ShortBoxes()
     short_boxes = sb.create_short_boxes(self.optimizer, renamed_inputargs,
                                         label_args + virtuals)
     short_inputargs = sb.create_short_inputargs(label_args + virtuals)
     for produced_op in short_boxes:
         op = produced_op.short_op.res
         if not isinstance(op, Const):
             self._expand_info(op, infos)
     self.optimizer._clean_optimization_info(end_args)
     return ExportedState(label_args, end_args, virtual_state, infos,
                          short_boxes, renamed_inputargs, short_inputargs,
                          runtime_boxes, memo)
Пример #4
0
 def test_pure_ops(self):
     i0 = InputArgInt()
     i1 = InputArgInt()
     op = ResOperation(rop.INT_ADD, [i0, i1])
     sb = ShortBoxes()
     short_boxes = sb.create_short_boxes(Opt([op]), [i0, i1], [i0, i1])
     assert len(short_boxes) == 3
     short_boxes.sort(key=str)
     # inputarg
     for i in range(3):
         if short_boxes[i].short_op.res is i0:
             assert short_boxes[i].preamble_op is sb.short_inputargs[0]
             break
     else:
         raise Exception("did not find!")
     # pure op
     for i in range(3):
         if short_boxes[2].preamble_op.getarg(0) is sb.short_inputargs[0]:
             assert short_boxes[2].short_op.res is op
             break
     else:
         raise Exception("did not find!")