original_docstring: Select the next mod/rm location to use for the new operation 'v'.
          If 'v' is None, this will always return a register; else it might
          decide to immediately create 'v' in a stack location.
          
docstring: Select the next mod/rm location to use for the new operation 'v'.
  If 'v' is None, this will always return a register; else it might
  decide to immediately create 'v' in a stack location.
docstring_tokens: Select the next mod / rm location to use for the new operation ' v ' . If ' v ' is None this will always return a register ; else it might decide to immediately create ' v ' in a stack location .
code: def _use_next_modrm(self, v, regnum_must_be_before=8):
          """Select the next mod/rm location to use for the new operation 'v'.
          If 'v' is None, this will always return a register; else it might
          decide to immediately create 'v' in a stack location.
          """
          #print self.registers_free
          if self.registers_free:
              for i in range(regnum_must_be_before-1, -1, -1):
                  if self.registers_free & (1 << i):
                      self.registers_free &= ~ (1 << i)
                      return registers[i]
          # spill the register holding the variable that has the longest
          # time remaining to live (it may be our 'v' itself)
          if v is None:
              dyinglimit = self.operationindex  # must pick vars dying after that
              spillvar = None
          else:
              dyinglimit = self.lifetime[v]
              spillvar = v  # initial guess, can be overridden in the loop below
          regloc = None
          for v1, dying in self.vars_in_use.iteritems():
              if dying > dyinglimit:
                  loc = self.var2loc[v1]
                  if not isinstance(loc, REG):
                      continue
                  if loc.op >= regnum_must_be_before:
                      continue   # never reached if regnum_must_be_before == 8
                  if loc.bitmask & self.registers_pinned:
                      continue   # don't spill this register
                  regloc = loc
                  dyinglimit = dying
                  spillvar = v1
          if spillvar is None:
              raise OutOfRegistersError
          #print 'time span of %s: now is %d, lives until %d' % (
          #    v, self.operationindex, self.lifetime[v])
          if spillvar is v:
              return self._use_another_stack_loc()
          else:
              assert regloc is not None
              self._spill(spillvar, regloc)
              return regloc
code_tokens: def _use_next_modrm ( self , v , regnum_must_be_before = 8 ) : if self . registers_free : for i in range ( regnum_must_be_before - 1 , - 1 , - 1 ) : if self . registers_free & ( 1 << i ) : self . registers_free &= ~ ( 1 << i ) return registers [ i ] if v is None : dyinglimit = self . operationindex spillvar = None else : dyinglimit = self . lifetime [ v ] spillvar = v regloc = None for v1 , dying in self . vars_in_use . iteritems ( ) : if dying > dyinglimit : loc = self . var2loc [ v1 ] if not isinstance ( loc , REG ) : continue if loc . op >= regnum_must_be_before : continue if loc . bitmask & self . registers_pinned : continue regloc = loc dyinglimit = dying spillvar = v1 if spillvar is None : raise OutOfRegistersError if spillvar is v : return self . _use_another_stack_loc ( ) else : assert regloc is not None self . _spill ( spillvar , regloc ) return regloc
short_docstring: Select the next mod/rm location to use for the new operation 'v'.
short_docstring_tokens: Select the next mod / rm location to use for the new operation ' v ' .
comment: """Select the next mod/rm location to use for the new operation 'v'.
          If 'v' is None, this will always return a register; else it might
          decide to immediately create 'v' in a stack location.
          """$SEP$#print self.registers_free$SEP$# spill the register holding the variable that has the longest$SEP$# time remaining to live (it may be our 'v' itself)$SEP$# must pick vars dying after that$SEP$# initial guess, can be overridden in the loop below$SEP$# never reached if regnum_must_be_before == 8$SEP$# don't spill this register$SEP$#print 'time span of %s: now is %d, lives until %d' % ($SEP$#    v, self.operationindex, self.lifetime[v])