Ignore:
Timestamp:
Nov 18, 2013, 6:21:18 AM (6 years ago)
Author:
cameron
Message:

simd-lib updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icXML/icXML-devel/src/simd-lib/pabloSupport.hpp

    r2720 r3567  
    2323     
    2424
    25 IDISA_ALWAYS_INLINE BitBlock pablo_blk_Advance(BitBlock strm, BitBlock carryin, BitBlock & rslt) {
    26         BitBlock carryout;
     25const BitBlock simd_const_1 = mvmd<BLOCK_SIZE/4>::fill4(0,0,0,1);
     26
     27const BitBlock simd_sign_bit = bitblock::slli<BLOCK_SIZE-1>(simd_const_1);
     28
     29IDISA_ALWAYS_INLINE BitBlock Dequeue_bit(BitBlock & q) {
     30        BitBlock bit = simd_and(q, simd_const_1);
     31        q = simd<64>::srli<1>(q);
     32        return bit;
     33}
     34
     35IDISA_ALWAYS_INLINE carry_t pablo_blk_Advance(BitBlock strm, carry_t carryin, BitBlock & rslt) {
     36        carry_t carryout;
    2737        adv_ci_co(strm, carryin, carryout, rslt);
    2838        return carryout;
    2939}
    3040
    31 template <int n> IDISA_ALWAYS_INLINE BitBlock pablo_blk_Advance_n_(BitBlock strm, BitBlock pending_in, BitBlock & rslt) {
     41template <int n> IDISA_ALWAYS_INLINE carry_t pablo_blk_Advance_n_(BitBlock strm, BitBlock pending_in, BitBlock & rslt) {
    3242        BitBlock half_block_shifted = esimd<BLOCK_SIZE/2>::mergel(strm, pending_in);
    3343        rslt = simd_or(simd<BLOCK_SIZE/2>::srli<(BLOCK_SIZE/2)-n>(half_block_shifted),
     
    3646}
    3747
    38 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
    39         BitBlock carryout, sum;
     48template <int fw, int n> IDISA_ALWAYS_INLINE carry_t pablo_blk_Advance_n_(BitBlock strm, BitBlock pending_in, BitBlock & rslt) {
     49        BitBlock shifted = mvmd<fw>::dslli<1>(strm, pending_in);
     50        rslt = simd_or(simd<BLOCK_SIZE/2>::srli<fw-n>(shifted),
     51                       simd<BLOCK_SIZE/2>::slli<n>(strm));
     52        return strm;
     53}
     54
     55/*  Support for pablo.Lookahead.  2 translation modes:
     56    (a) pablo.Lookahead(ss.strm, n) ==> pablo_blk_Lookahead_n_<n>(ss_curblock.strm, ss_nxtblock.strm);
     57    (b) pablo.Lookahead(ss.strm, n) ==> pablo_blk_Lookahead_n_<n>(ss[0].strm, ss[1].strm);
     58*/
     59template <int n> IDISA_ALWAYS_INLINE carry_t pablo_blk_Lookahead_n_(BitBlock strm, BitBlock lookahead) {
     60        BitBlock half_block_shifted = mvmd<BLOCK_SIZE/2>::dslli<1>(lookahead, strm);
     61        return simd_or(simd<BLOCK_SIZE/2>::slli<(BLOCK_SIZE/2)-n>(half_block_shifted),
     62                       simd<BLOCK_SIZE/2>::srli<n>(strm));
     63}
     64
     65IDISA_ALWAYS_INLINE carry_t pablo_blk_ScanThru(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) {
     66        carry_t carryout;  BitBlock sum;
    4067        add_ci_co(marker, charclass, carryin, carryout, sum);
    4168        rslt = simd_andc(sum, charclass);
     
    4370}
    4471
    45 IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
    46         BitBlock carryout, sum;
     72IDISA_ALWAYS_INLINE carry_t pablo_blk_MatchStar(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) {
     73        carry_t carryout;  BitBlock sum;
     74        add_ci_co(simd_and(charclass, marker), charclass, carryin, carryout, sum);
     75        rslt = simd_or(simd_xor(sum, charclass), marker);
     76        return carryout;
     77}
     78
     79IDISA_ALWAYS_INLINE carry_t pablo_blk_AdvanceThenScanThru(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) {
     80        carry_t carryout;  BitBlock sum;
    4781        add_ci_co(marker, simd_or(charclass, marker), carryin, carryout, sum);
    4882        rslt = simd_andc(sum, charclass);
     
    5084}
    5185
    52 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanTo(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
    53         BitBlock carryout, sum;
     86IDISA_ALWAYS_INLINE carry_t pablo_blk_ScanTo(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) {
     87        carry_t carryout;  BitBlock sum;
    5488        add_ci_co(marker, simd_not(charclass), carryin, carryout, sum);
    5589        rslt = simd_and(sum, charclass);
     
    5791}
    5892
    59 IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanTo(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
    60         BitBlock carryout, sum;
     93IDISA_ALWAYS_INLINE carry_t pablo_blk_AdvanceThenScanTo(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) {
     94        carry_t carryout;  BitBlock sum;
    6195        add_ci_co(marker, simd_or(marker, simd_not(charclass)), carryin, carryout, sum);
    6296        rslt = simd_and(sum, charclass);
     
    6498}
    6599
    66 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanToFirst(BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
    67         BitBlock carryout, sum;
     100IDISA_ALWAYS_INLINE carry_t pablo_blk_ScanToFirst(BitBlock charclass, carry_t carryin, BitBlock & rslt) {
     101        carry_t carryout;  BitBlock sum;
    68102        add_ci_co(simd<BLOCK_SIZE>::constant<0>(), simd_not(charclass), carryin, carryout, sum);
    69103        rslt = simd_and(sum, charclass);
     
    71105}
    72106
    73 IDISA_ALWAYS_INLINE BitBlock pablo_blk_SpanUpTo(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
    74         BitBlock carryout;
     107IDISA_ALWAYS_INLINE carry_t pablo_blk_SpanUpTo(BitBlock starts, BitBlock follows, carry_t carryin, BitBlock & rslt) {
     108        carry_t carryout;
    75109        sub_bi_bo(follows, starts, carryin, carryout, rslt);
    76110        return carryout;
    77111}
    78112
    79 IDISA_ALWAYS_INLINE BitBlock pablo_blk_InclusiveSpan(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
    80         BitBlock carryout, span;
     113IDISA_ALWAYS_INLINE carry_t pablo_blk_InclusiveSpan(BitBlock starts, BitBlock follows, carry_t carryin, BitBlock & rslt) {
     114        carry_t carryout;  BitBlock span;
    81115        sub_bi_bo(follows, starts, carryin, carryout, span);
    82116        rslt = simd_or(span, follows);
     
    84118}
    85119
    86 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ExclusiveSpan(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
    87         BitBlock carryout, span;
     120IDISA_ALWAYS_INLINE carry_t pablo_blk_ExclusiveSpan(BitBlock starts, BitBlock follows, carry_t carryin, BitBlock & rslt) {
     121        carry_t carryout;  BitBlock span;
    88122        sub_bi_bo(follows, starts, carryin, carryout, span);
    89123        rslt = simd_andc(span, starts);
     
    92126
    93127
     128template <typename T> IDISA_ALWAYS_INLINE BitBlock pablo_blk_match(T bytedata[], const T match_str[], BitBlock v, int len) {
     129        union {BitBlock bitblock; ScanWord elems[sizeof(BitBlock)/sizeof(ScanWord)];} u;
     130        u.bitblock = v;
     131        int pos;
     132        ScanWord s, t, bit;
     133        for (unsigned int i = 0; i < sizeof(BitBlock)/sizeof(ScanWord); i++) {
     134                s = u.elems[i];
     135                while (s != 0) {
     136                        pos = scan_forward_zeroes(s);
     137                        t = s;
     138                        s = s & (s - 1); // clear rightmost bit
     139                        if (memcmp((void *) &bytedata[pos], (void *) match_str, len * sizeof(T))) {
     140                                // Strings do not match; filter the result.
     141                                bit = s ^ t;
     142                                u.elems[i] ^= bit;
     143                        }
     144                }
     145        }
     146        return u.bitblock;
     147}
    94148
    95149#endif // PABLOSUPPORT_HPP_
Note: See TracChangeset for help on using the changeset viewer.