Changeset 3567 for icXML/icXMLdevel/src/simdlib/pabloSupport.hpp
 Timestamp:
 Nov 18, 2013, 6:21:18 AM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

icXML/icXMLdevel/src/simdlib/pabloSupport.hpp
r2720 r3567 23 23 24 24 25 IDISA_ALWAYS_INLINE BitBlock pablo_blk_Advance(BitBlock strm, BitBlock carryin, BitBlock & rslt) { 26 BitBlock carryout; 25 const BitBlock simd_const_1 = mvmd<BLOCK_SIZE/4>::fill4(0,0,0,1); 26 27 const BitBlock simd_sign_bit = bitblock::slli<BLOCK_SIZE1>(simd_const_1); 28 29 IDISA_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 35 IDISA_ALWAYS_INLINE carry_t pablo_blk_Advance(BitBlock strm, carry_t carryin, BitBlock & rslt) { 36 carry_t carryout; 27 37 adv_ci_co(strm, carryin, carryout, rslt); 28 38 return carryout; 29 39 } 30 40 31 template <int n> IDISA_ALWAYS_INLINE BitBlockpablo_blk_Advance_n_(BitBlock strm, BitBlock pending_in, BitBlock & rslt) {41 template <int n> IDISA_ALWAYS_INLINE carry_t pablo_blk_Advance_n_(BitBlock strm, BitBlock pending_in, BitBlock & rslt) { 32 42 BitBlock half_block_shifted = esimd<BLOCK_SIZE/2>::mergel(strm, pending_in); 33 43 rslt = simd_or(simd<BLOCK_SIZE/2>::srli<(BLOCK_SIZE/2)n>(half_block_shifted), … … 36 46 } 37 47 38 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) { 39 BitBlock carryout, sum; 48 template <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<fwn>(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 */ 59 template <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 65 IDISA_ALWAYS_INLINE carry_t pablo_blk_ScanThru(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) { 66 carry_t carryout; BitBlock sum; 40 67 add_ci_co(marker, charclass, carryin, carryout, sum); 41 68 rslt = simd_andc(sum, charclass); … … 43 70 } 44 71 45 IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) { 46 BitBlock carryout, sum; 72 IDISA_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 79 IDISA_ALWAYS_INLINE carry_t pablo_blk_AdvanceThenScanThru(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) { 80 carry_t carryout; BitBlock sum; 47 81 add_ci_co(marker, simd_or(charclass, marker), carryin, carryout, sum); 48 82 rslt = simd_andc(sum, charclass); … … 50 84 } 51 85 52 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanTo(BitBlock marker, BitBlock charclass, BitBlockcarryin, BitBlock & rslt) {53 BitBlock carryout,sum;86 IDISA_ALWAYS_INLINE carry_t pablo_blk_ScanTo(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) { 87 carry_t carryout; BitBlock sum; 54 88 add_ci_co(marker, simd_not(charclass), carryin, carryout, sum); 55 89 rslt = simd_and(sum, charclass); … … 57 91 } 58 92 59 IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanTo(BitBlock marker, BitBlock charclass, BitBlockcarryin, BitBlock & rslt) {60 BitBlock carryout,sum;93 IDISA_ALWAYS_INLINE carry_t pablo_blk_AdvanceThenScanTo(BitBlock marker, BitBlock charclass, carry_t carryin, BitBlock & rslt) { 94 carry_t carryout; BitBlock sum; 61 95 add_ci_co(marker, simd_or(marker, simd_not(charclass)), carryin, carryout, sum); 62 96 rslt = simd_and(sum, charclass); … … 64 98 } 65 99 66 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanToFirst(BitBlock charclass, BitBlockcarryin, BitBlock & rslt) {67 BitBlock carryout,sum;100 IDISA_ALWAYS_INLINE carry_t pablo_blk_ScanToFirst(BitBlock charclass, carry_t carryin, BitBlock & rslt) { 101 carry_t carryout; BitBlock sum; 68 102 add_ci_co(simd<BLOCK_SIZE>::constant<0>(), simd_not(charclass), carryin, carryout, sum); 69 103 rslt = simd_and(sum, charclass); … … 71 105 } 72 106 73 IDISA_ALWAYS_INLINE BitBlock pablo_blk_SpanUpTo(BitBlock starts, BitBlock follows, BitBlockcarryin, BitBlock & rslt) {74 BitBlockcarryout;107 IDISA_ALWAYS_INLINE carry_t pablo_blk_SpanUpTo(BitBlock starts, BitBlock follows, carry_t carryin, BitBlock & rslt) { 108 carry_t carryout; 75 109 sub_bi_bo(follows, starts, carryin, carryout, rslt); 76 110 return carryout; 77 111 } 78 112 79 IDISA_ALWAYS_INLINE BitBlock pablo_blk_InclusiveSpan(BitBlock starts, BitBlock follows, BitBlockcarryin, BitBlock & rslt) {80 BitBlock carryout,span;113 IDISA_ALWAYS_INLINE carry_t pablo_blk_InclusiveSpan(BitBlock starts, BitBlock follows, carry_t carryin, BitBlock & rslt) { 114 carry_t carryout; BitBlock span; 81 115 sub_bi_bo(follows, starts, carryin, carryout, span); 82 116 rslt = simd_or(span, follows); … … 84 118 } 85 119 86 IDISA_ALWAYS_INLINE BitBlock pablo_blk_ExclusiveSpan(BitBlock starts, BitBlock follows, BitBlockcarryin, BitBlock & rslt) {87 BitBlock carryout,span;120 IDISA_ALWAYS_INLINE carry_t pablo_blk_ExclusiveSpan(BitBlock starts, BitBlock follows, carry_t carryin, BitBlock & rslt) { 121 carry_t carryout; BitBlock span; 88 122 sub_bi_bo(follows, starts, carryin, carryout, span); 89 123 rslt = simd_andc(span, starts); … … 92 126 93 127 128 template <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 } 94 148 95 149 #endif // PABLOSUPPORT_HPP_
Note: See TracChangeset
for help on using the changeset viewer.