source: trunk/lib/pabloSupport.hpp @ 2698

Last change on this file since 2698 was 2698, checked in by cameron, 6 years ago

Fixes for advance_n support in experimental mode

File size: 2.9 KB
Line 
1#ifndef PABLOSUPPORT_HPP_
2#define PABLOSUPPORT_HPP_
3
4#include "bitblock.hpp"
5
6#define BitBlock_declare(name)  BitBlock name
7
8#define ubitblock_declare(name, n) ubitblock name[n]
9
10
11IDISA_ALWAYS_INLINE BitBlock pablo_blk_Advance(BitBlock strm, BitBlock carryin, BitBlock & rslt) {
12        BitBlock carryout;
13        adv_ci_co(strm, carryin, carryout, rslt);
14        return carryout;
15}
16
17template <int n> IDISA_ALWAYS_INLINE BitBlock pablo_blk_Advance_n_(BitBlock strm, BitBlock pending_in, BitBlock & rslt) {
18        BitBlock half_block_shifted = esimd<BLOCK_SIZE/2>::mergel(strm, pending_in);
19        rslt = simd_or(simd<BLOCK_SIZE/2>::srli<(BLOCK_SIZE/2)-n>(half_block_shifted),
20                       simd<BLOCK_SIZE/2>::slli<n>(strm));
21        return strm;
22}
23
24IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
25        BitBlock carryout, sum;
26        add_ci_co(marker, charclass, carryin, carryout, sum);
27        rslt = simd_andc(sum, charclass);
28        return carryout;
29}
30
31IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
32        BitBlock carryout, sum;
33        add_ci_co(marker, simd_or(charclass, marker), carryin, carryout, sum);
34        rslt = simd_andc(sum, charclass);
35        return carryout;
36}
37
38IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanTo(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
39        BitBlock carryout, sum;
40        add_ci_co(marker, simd_not(charclass), carryin, carryout, sum);
41        rslt = simd_and(sum, charclass);
42        return carryout;
43}
44
45IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanTo(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
46        BitBlock carryout, sum;
47        add_ci_co(marker, simd_or(marker, simd_not(charclass)), carryin, carryout, sum);
48        rslt = simd_and(sum, charclass);
49        return carryout;
50}
51
52IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanToFirst(BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
53        BitBlock carryout, sum;
54        add_ci_co(simd<BLOCK_SIZE>::constant<0>(), simd_not(charclass), carryin, carryout, sum);
55        rslt = simd_and(sum, charclass);
56        return carryout;
57}
58
59IDISA_ALWAYS_INLINE BitBlock pablo_blk_SpanUpTo(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
60        BitBlock carryout;
61        sub_bi_bo(follows, starts, carryin, carryout, rslt);
62        return carryout;
63}
64
65IDISA_ALWAYS_INLINE BitBlock pablo_blk_InclusiveSpan(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
66        BitBlock carryout, span;
67        sub_bi_bo(follows, starts, carryin, carryout, span);
68        rslt = simd_or(span, follows);
69        return carryout;
70}
71
72IDISA_ALWAYS_INLINE BitBlock pablo_blk_ExclusiveSpan(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
73        BitBlock carryout, span;
74        sub_bi_bo(follows, starts, carryin, carryout, span);
75        rslt = simd_andc(span, starts);
76        return carryout;
77}
78
79
80
81#endif // PABLOSUPPORT_HPP_
Note: See TracBrowser for help on using the repository browser.