Exemple #1
0
 def block(self, d, a, b):
   code = self.get_active_code()
   temp = code.prgm.acquire_register()
   spu.cgt(temp, a, b)
   spu.ceq(d, a, b)
   spu.or_(d, d, temp)
   code.prgm.release_register(temp)
   return
Exemple #2
0
  def end(self, branch = True):
    """Do post-loop iterator code"""
    if self.hint == True:
      self.code.add(spu.hbrr(self.branch_label, self.start_label))

    if self.mode == DEC:
      # branch if r_count is not zero (CR)
      #   Note that this relies on someone (e.g. cleanup()) setting the
      #   condition register properly.
      if branch:
        self.code.add(self.branch_label)
        self.code.add(spu.brnz(self.r_count, self.start_label))

      # Reset the counter in case this is a nested loop
      util.load_word(self.code, self.r_count, self.get_count())

    elif self.mode == INC:
      # branch if r_current < r_stop
      if branch:
        r_cmp_gt = self.code.prgm.acquire_register()

        self.code.add(spu.cgt(r_cmp_gt, self.r_stop, self.r_count))
        self.code.add(self.branch_label)
        self.code.add(spu.brnz(r_cmp_gt, self.start_label))

        self.code.prgm.release_register(r_cmp_gt)        

      # Reset the the current value in case this is a nested loop
      if self._external_start:
        self.code.add(spu.ai(self.r_count, self.r_start, 0))
      else:
        util.load_word(self.code, self.r_count, self.get_start())

    if self.r_count is not None:
      self.code.prgm.release_register(self.r_count)
    if self.r_stop is not None and not self._external_stop:
      self.code.prgm.release_register(self.r_stop)      

    return
Exemple #3
0
 def block(self, d, a, b):
   spu.cgt(d, b, a)
   return