source: trunk/lib/pabloSupport.hpp @ 2705

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

Resolve initialization error.

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