source: icXML/icXML-devel/src/simd-lib/pabloSupport.hpp @ 2720

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

Initial check-in of icXML 0.8 source files

File size: 3.4 KB
Line 
1/*=============================================================================
2  pabloSupport.hpp - Pablo compiler support for carry introduction.
3  Will replace deprecated carryQ.hpp
4  Copyright (C) 2012, Robert D. Cameron
5    Licensed to the public under the Open Software License 3.0.
6    Licensed to International Characters Inc.
7       under the Academic Free License version 3.0.
8  December 2012
9=============================================================================*/
10#ifndef PABLOSUPPORT_HPP_
11#define PABLOSUPPORT_HPP_
12
13#include "bitblock.hpp"
14
15#define BitBlock_declare(name)  BitBlock name
16
17#define ubitblock_declare(name, n) \
18  ubitblock name[n];\
19  do {int i;\
20      for (i = 0; i < n; i++) name[i]._128 = simd<1>::constant<0>();\
21     }\
22  while (0)
23     
24
25IDISA_ALWAYS_INLINE BitBlock pablo_blk_Advance(BitBlock strm, BitBlock carryin, BitBlock & rslt) {
26        BitBlock carryout;
27        adv_ci_co(strm, carryin, carryout, rslt);
28        return carryout;
29}
30
31template <int n> IDISA_ALWAYS_INLINE BitBlock pablo_blk_Advance_n_(BitBlock strm, BitBlock pending_in, BitBlock & rslt) {
32        BitBlock half_block_shifted = esimd<BLOCK_SIZE/2>::mergel(strm, pending_in);
33        rslt = simd_or(simd<BLOCK_SIZE/2>::srli<(BLOCK_SIZE/2)-n>(half_block_shifted),
34                       simd<BLOCK_SIZE/2>::slli<n>(strm));
35        return strm;
36}
37
38IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
39        BitBlock carryout, sum;
40        add_ci_co(marker, charclass, carryin, carryout, sum);
41        rslt = simd_andc(sum, charclass);
42        return carryout;
43}
44
45IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanThru(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
46        BitBlock carryout, sum;
47        add_ci_co(marker, simd_or(charclass, marker), carryin, carryout, sum);
48        rslt = simd_andc(sum, charclass);
49        return carryout;
50}
51
52IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanTo(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
53        BitBlock carryout, sum;
54        add_ci_co(marker, simd_not(charclass), carryin, carryout, sum);
55        rslt = simd_and(sum, charclass);
56        return carryout;
57}
58
59IDISA_ALWAYS_INLINE BitBlock pablo_blk_AdvanceThenScanTo(BitBlock marker, BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
60        BitBlock carryout, sum;
61        add_ci_co(marker, simd_or(marker, simd_not(charclass)), carryin, carryout, sum);
62        rslt = simd_and(sum, charclass);
63        return carryout;
64}
65
66IDISA_ALWAYS_INLINE BitBlock pablo_blk_ScanToFirst(BitBlock charclass, BitBlock carryin, BitBlock & rslt) {
67        BitBlock carryout, sum;
68        add_ci_co(simd<BLOCK_SIZE>::constant<0>(), simd_not(charclass), carryin, carryout, sum);
69        rslt = simd_and(sum, charclass);
70        return carryout;
71}
72
73IDISA_ALWAYS_INLINE BitBlock pablo_blk_SpanUpTo(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
74        BitBlock carryout;
75        sub_bi_bo(follows, starts, carryin, carryout, rslt);
76        return carryout;
77}
78
79IDISA_ALWAYS_INLINE BitBlock pablo_blk_InclusiveSpan(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
80        BitBlock carryout, span;
81        sub_bi_bo(follows, starts, carryin, carryout, span);
82        rslt = simd_or(span, follows);
83        return carryout;
84}
85
86IDISA_ALWAYS_INLINE BitBlock pablo_blk_ExclusiveSpan(BitBlock starts, BitBlock follows, BitBlock carryin, BitBlock & rslt) {
87        BitBlock carryout, span;
88        sub_bi_bo(follows, starts, carryin, carryout, span);
89        rslt = simd_andc(span, starts);
90        return carryout;
91}
92
93
94
95#endif // PABLOSUPPORT_HPP_
Note: See TracBrowser for help on using the repository browser.