def _c(self, x, y, c, temp): spu.and_(temp, x, y) spu.cntb(temp, temp) spu.sumb(temp, temp, 0) spu.a(c, c, temp) return
def _ab(self, x, y, ab, temp): spu.xor(temp, x, y) spu.cntb(temp, temp) spu.sumb(temp, temp, 0) spu.a(ab, ab, temp) return
def popc(self, count, x): """ Add the number of 1 bits in each word in X to the value in count. """ temp = spu.get_active_code().acquire_register() spu.cntb(temp, x) spu.sumb(temp, temp, 0) spu.a(count, count, temp) spu.get_active_code().release_register(temp) return
def _ab_c(self, x, y, ab, c, ab_temp, c_temp): """ Interleave ab and c computations """ spu.xor(ab_temp, x, y) spu.and_(c_temp, x, y) spu.cntb(ab_temp, ab_temp) spu.cntb(c_temp, c_temp) spu.sumb(ab_temp, ab_temp, 0) spu.sumb(c_temp, c_temp, 0) spu.a(ab, ab, ab_temp) spu.a(c, c, c_temp) return