source: trunk/lib/carryQ.h @ 778

Last change on this file since 778 was 778, checked in by cameron, 9 years ago

CarryQ_Adjust initial definition

File size: 2.8 KB
Line 
1//
2// carryQ.h
3// Robert D. Cameron
4// November 29, 2010 - first version without actual queueing.
5//
6
7#include "block_carry.h"
8
9#define CarryQtype CarryType *
10
11#define CarryDeclare(name, count)\
12CarryType name[count];\
13
14#define CarryInit(name, count)\
15for (int j=0; j < count; j++) name[j] = Carry0
16
17static inline BitBlock BitBlock_advance_ci_co(BitBlock strm, CarryQtype cq, int carryno) {
18 BitBlock rslt;
19 advance_with_carry(strm, cq[carryno], rslt);
20 return rslt;
21}
22
23static inline BitBlock BitBlock_advance_co(BitBlock strm, CarryQtype cq, int carryno) {
24 BitBlock rslt;
25 cq[carryno] = Carry0;
26 advance_with_carry(strm, cq[carryno], rslt);
27 return rslt;
28}
29
30static inline BitBlock BitBlock_add_ci_co(BitBlock strm1, BitBlock strm2, CarryQtype cq, int carryno) {
31 BitBlock sum;
32 adc128(strm1, strm2, cq[carryno], sum);
33 return sum;
34}
35
36static inline BitBlock BitBlock_add_co(BitBlock strm1, BitBlock strm2, CarryQtype cq, int carryno) {
37 BitBlock sum;
38 cq[carryno] = Carry0;
39 adc128(strm1, strm2, cq[carryno], sum);
40 return sum;
41}
42
43static inline BitBlock BitBlock_sub_ci_co(BitBlock strm1, BitBlock strm2, CarryQtype cq, int carryno) {
44 BitBlock diff;
45 sbb128(strm1, strm2, cq[carryno], diff);
46 return diff;
47}
48
49static inline BitBlock BitBlock_sub_co(BitBlock strm1, BitBlock strm2, CarryQtype cq, int carryno) {
50 BitBlock diff;
51 cq[carryno] = Carry0;
52 sbb128(strm1, strm2, cq[carryno], diff);
53 return diff;
54}
55
56static inline BitBlock BitBlock_scanthru_ci_co(BitBlock markers0, BitBlock charclass, CarryQtype cq, int carryno) {
57 BitBlock markers1;
58 adc128(markers0, charclass, cq[carryno], markers1);
59 return simd_andc(markers1, charclass);
60}
61
62static inline BitBlock BitBlock_scanthru_co(BitBlock markers0, BitBlock charclass, CarryQtype cq, int carryno) {
63 BitBlock markers1;
64 cq[carryno] = Carry0;
65 adc128(markers0, charclass, cq[carryno], markers1);
66 return simd_andc(markers1, charclass);
67}
68
69static inline bool CarryTest(CarryQtype cq, int carryno, int carry_count) {
70  CarryType c1 = cq[carryno];
71  int i;
72  for (i = carryno + 1; i < carryno + carry_count; i++) {
73    c1 = carry_or(c1, cq[i]);
74  }
75  return test_carry(c1);
76}
77
78static inline void CarryDequeueEnqueue(CarryQtype cq, int carryno, int carry_count) {
79  // Given carryin queue with carry_count carries starting from carryno are 0,
80  // ensure that the carryout queue has carry_count carries starting from carryno set to 0.
81  // Nothing to do when the queues are the same!
82  return;
83}
84
85static inline void CarryQ_Adjust(CarryQtype cq, int carry_count) {
86  // Adjust the carryQ so that carries enqueued are readied for dequeiing.
87  // Nothing to do with indexed queues.
88  return;
89}
90
91static inline void CarryCombine(CarryQtype cq, CarryQtype local_cq, int carryno, int carry_count) {
92  int i;
93  for (i = 0; i < carry_count; i++) {
94    cq[carryno+i] = carry_or(cq[carryno+i], local_cq[i]);
95  }
96}
97
Note: See TracBrowser for help on using the repository browser.