Пример #1
0
 def gen_assign(n, g=True):
     slot = c.Var('memory_slot_%d' % n)
     self.define_objective('memory_slot_%d' % n, None)
     return c.ExecuteChain() \
             .cond('if') \
             .score_range(mar, c.ScoreRange(n, n)) \
             .run(c.OpAssign(mbr if g else slot, slot if g else mbr))
Пример #2
0
 def scale_other_to_this(self, other, otherref, out):
     factor = self.type.scale / other.type.scale
     op = c.OpMul
     if factor < 1:
         factor = 1 / factor
         op = c.OpDiv
     factor = int(factor)
     if factor == 1:
         return otherref, False
     scaled = out.allocate_temp()
     out.write(c.OpAssign(scaled, otherref))
     # TODO extract to constant reference
     scaleparam = out.allocate_temp()
     out.write(c.SetConst(scaleparam, factor))
     out.write(op(scaled, scaleparam))
     out.free_temp(scaleparam)
     return scaled, True
Пример #3
0
 def _write_to_reference(self, ref, out):
     out.write(c.OpAssign(ref, self.ref))
Пример #4
0
 def _read_from_reference(self, ref, out):
     out.write(c.OpAssign(self.ref, ref))