Changeset 784


Ignore:
Timestamp:
Dec 6, 2010, 5:09:20 AM (8 years ago)
Author:
cameron
Message:

Add _ci_co and _co modes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/carryQ.h

    r783 r784  
    112112SIMD_type carryQ_co_mask = sisd_slli(carryQ_ci_mask, 127);
    113113
    114 #define carryQ_adc128(x, y, carryQ,  sum) \
     114#define carryQ_adc128_ci_co(x, y, carryQ,  sum) \
    115115do{ \
    116116  SIMD_type gen = simd_and(x, y); \
     
    123123} while(0)
    124124
    125 #define carryQ_sbb128(x, y, carryQ, difference) \
     125#define carryQ_adc128_co(x, y, carryQ,  sum) \
     126do{ \
     127  SIMD_type gen = simd_and(x, y); \
     128  SIMD_type prop = simd_or(x, y); \
     129  SIMD_type partial = simd_add_64(x, y); \
     130  carryQ = simd_srli_64(carryQ, 1); \
     131  SIMD_type c1 = sisd_slli(simd_srli_64(simd_or(gen, simd_andc(prop, partial)), 63), 64); \
     132  sum = simd_add_64(c1, partial); \
     133  carryQ = simd_or(carryQ, simd_and(simd_or(gen, simd_andc(prop, sum)), carryQ_co_mask)); \
     134} while(0)
     135
     136#define carryQ_sbb128_ci_co(x, y, carryQ, difference) \
    126137do {\
    127138  SIMD_type gen = simd_andc(y, x); \
     
    134145}while(0)
    135146
    136 #define carryQ_advance_with_carry(cursor, carryQ, rslt)\
     147#define carryQ_sbb128_co(x, y, carryQ, difference) \
     148do {\
     149  SIMD_type gen = simd_andc(y, x); \
     150  SIMD_type prop = simd_not(simd_xor(x, y)); \
     151  SIMD_type partial = simd_sub_64(x, y); \
     152  carryQ = simd_srli_64(carryQ, 1); \
     153  SIMD_type b1 = sisd_slli(simd_srli_64(simd_or(gen, simd_and(prop, partial)), 63), 64); \
     154  difference = simd_sub_64(partial, b1); \
     155  carryQ = simd_or(carryQ, simd_and(simd_or(gen, simd_and(prop, difference)), carryQ_co_mask)); \
     156}while(0)
     157
     158#define carryQ_advance_with_carry_ci_co(cursor, carryQ, rslt)\
    137159do {\
    138160  SIMD_type carry_out = simd_and(cursor, carryQ_co_mask);\
     
    144166} while(0)
    145167
     168#define carryQ_advance_with_carry_co(cursor, carryQ, rslt)\
     169do {\
     170  SIMD_type carry_out = simd_and(cursor, carryQ_co_mask);\
     171  carryQ = simd_or(simd_srli_64(carryQ, 1), carry_out); \
     172  SIMD_type shift_out = simd_srli_64(cursor, 63);\
     173  SIMD_type low_bits = simd_mergel_64(shift_out, simd_const_1(0));\
     174  rslt = simd_or(simd_add_64(cursor, cursor), low_bits);\
     175} while(0)
     176
    146177static inline BitBlock BitBlock_advance_ci_co(BitBlock strm, CarryQtype & cq, int carryno) {
    147178 BitBlock rslt;
    148  carryQ_advance_with_carry(strm, cq, rslt);
     179 carryQ_advance_with_carry_ci_co(strm, cq, rslt);
    149180 return rslt;
    150181}
     
    152183static inline BitBlock BitBlock_advance_co(BitBlock strm, CarryQtype & cq, int carryno) {
    153184 BitBlock rslt;
    154  carryQ_advance_with_carry(strm, cq, rslt);
     185 carryQ_advance_with_carry_co(strm, cq, rslt);
    155186 return rslt;
    156187}
     
    158189static inline BitBlock BitBlock_add_ci_co(BitBlock strm1, BitBlock strm2, CarryQtype & cq, int carryno) {
    159190 BitBlock sum;
    160  carryQ_adc128(strm1, strm2, cq, sum);
     191 carryQ_adc128_ci_co(strm1, strm2, cq, sum);
    161192 return sum;
    162193}
     
    164195static inline BitBlock BitBlock_add_co(BitBlock strm1, BitBlock strm2, CarryQtype & cq, int carryno) {
    165196 BitBlock sum;
    166  carryQ_adc128(strm1, strm2, cq, sum);
     197 carryQ_adc128_co(strm1, strm2, cq, sum);
    167198 return sum;
    168199}
     
    170201static inline BitBlock BitBlock_sub_ci_co(BitBlock strm1, BitBlock strm2, CarryQtype & cq, int carryno) {
    171202 BitBlock diff;
    172  carryQ_sbb128(strm1, strm2, cq, diff);
     203 carryQ_sbb128_ci_co(strm1, strm2, cq, diff);
    173204 return diff;
    174205}
     
    176207static inline BitBlock BitBlock_sub_co(BitBlock strm1, BitBlock strm2, CarryQtype & cq, int carryno) {
    177208 BitBlock diff;
    178  carryQ_sbb128(strm1, strm2, cq, diff);
     209 carryQ_sbb128_co(strm1, strm2, cq, diff);
    179210 return diff;
    180211}
     
    182213static inline BitBlock BitBlock_scanthru_ci_co(BitBlock markers0, BitBlock charclass, CarryQtype & cq, int carryno) {
    183214 BitBlock markers1;
    184  carryQ_adc128(markers0, charclass, cq, markers1);
     215 carryQ_adc128_ci_co(markers0, charclass, cq, markers1);
    185216 return simd_andc(markers1, charclass);
    186217}
     
    188219static inline BitBlock BitBlock_scanthru_co(BitBlock markers0, BitBlock charclass, CarryQtype & cq, int carryno) {
    189220 BitBlock markers1;
    190  carryQ_adc128(markers0, charclass, cq, markers1);
     221 carryQ_adc128_co(markers0, charclass, cq, markers1);
    191222 return simd_andc(markers1, charclass);
    192223}
Note: See TracChangeset for help on using the changeset viewer.